[jboss-cvs] JBossAS SVN: r69674 - in projects/microcontainer/trunk/deployers-structure-spi/src: tests/org/jboss/test/deployers/structure/version/test and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Feb 6 16:49:43 EST 2008


Author: alesj
Date: 2008-02-06 16:49:42 -0500 (Wed, 06 Feb 2008)
New Revision: 69674

Added:
   projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/test/VersionRangeTestCase.java
Modified:
   projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/classloading/Version.java
   projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/classloading/VersionRange.java
   projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/test/VersionTestSuite.java
Log:
VersionRange is wrong.

Modified: projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/classloading/Version.java
===================================================================
--- projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/classloading/Version.java	2008-02-06 21:35:44 UTC (rev 69673)
+++ projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/classloading/Version.java	2008-02-06 21:49:42 UTC (rev 69674)
@@ -40,4 +40,20 @@
       VersionComparatorRegistry registry = VersionComparatorRegistry.getInstance();
       return registry.compare(this, v);
    }
+
+/*
+   public boolean equals(Object obj)
+   {
+      if (obj instanceof Version == false)
+         return false;
+
+      VersionComparatorRegistry registry = VersionComparatorRegistry.getInstance();
+      return registry.compare(this, Version.class.cast(obj)) == 0;
+   }
+
+   public int hashCode()
+   {
+      return toString().hashCode();
+   }
+*/
 }

Modified: projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/classloading/VersionRange.java
===================================================================
--- projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/classloading/VersionRange.java	2008-02-06 21:35:44 UTC (rev 69673)
+++ projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/classloading/VersionRange.java	2008-02-06 21:49:42 UTC (rev 69674)
@@ -137,7 +137,7 @@
       if (low != null)
       {
          comparison = low.compareTo(version);
-         if (comparison < 0)
+         if (comparison > 0)
             return false;
          if (lowInclusive == false && comparison == 0)
             return false;
@@ -145,7 +145,7 @@
       if (high != null)
       {
          comparison = high.compareTo(version);
-         if (comparison > 0)
+         if (comparison < 0)
             return false;
          if (highInclusive == false && comparison == 0)
             return false;

Added: projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/test/VersionRangeTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/test/VersionRangeTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/test/VersionRangeTestCase.java	2008-02-06 21:49:42 UTC (rev 69674)
@@ -0,0 +1,103 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.deployers.structure.version.test;
+
+import junit.framework.Test;
+import org.jboss.deployers.structure.spi.classloading.Version;
+import org.jboss.deployers.structure.spi.classloading.VersionRange;
+import org.jboss.deployers.structure.spi.classloading.helpers.VersionImpl;
+import org.jboss.test.deployers.structure.version.support.DummyVersion;
+
+/**
+ * Test version range.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class VersionRangeTestCase extends AbstractVersionTest
+{
+   public VersionRangeTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(VersionRangeTestCase.class);
+   }
+
+   public void testRange() throws Exception
+   {
+      registerVersionComparators();
+      try
+      {
+         Version low1 = VersionImpl.parseVersion("1");
+         Version high1 = VersionImpl.parseVersion("2");
+         Version v1 = VersionImpl.parseVersion("1");
+         Version v2 = VersionImpl.parseVersion("1.5");
+         Version v3 = VersionImpl.parseVersion("2");
+
+         VersionRange vr1 = new VersionRange(low1, true, high1, true); // [1,2]
+         VersionRange vr2 = new VersionRange(low1, false, high1, true); // (1,2]
+         VersionRange vr3 = new VersionRange(low1, true, high1, false); // [1,2)
+         VersionRange vr4 = new VersionRange(low1, false, high1, false); // (1,2)
+
+         assertTrue(vr1.isInRange(v1));
+         assertTrue(vr1.isInRange(v2));
+         assertTrue(vr1.isInRange(v3));
+
+         assertFalse(vr2.isInRange(v1));
+         assertTrue(vr2.isInRange(v2));
+         assertTrue(vr2.isInRange(v3));
+
+         assertTrue(vr3.isInRange(v1));
+         assertTrue(vr3.isInRange(v2));
+         assertFalse(vr3.isInRange(v3));
+
+         assertFalse(vr4.isInRange(v1));
+         assertTrue(vr4.isInRange(v2));
+         assertFalse(vr4.isInRange(v3));
+
+         v1 = new DummyVersion(1);
+         v3 = new DummyVersion(2);
+
+         assertTrue(vr1.isInRange(v1));
+         assertTrue(vr1.isInRange(v2));
+         assertTrue(vr1.isInRange(v3));
+
+         assertFalse(vr2.isInRange(v1));
+         assertTrue(vr2.isInRange(v2));
+         assertTrue(vr2.isInRange(v3));
+
+         assertTrue(vr3.isInRange(v1));
+         assertTrue(vr3.isInRange(v2));
+         assertFalse(vr3.isInRange(v3));
+
+         assertFalse(vr4.isInRange(v1));
+         assertTrue(vr4.isInRange(v2));
+         assertFalse(vr4.isInRange(v3));
+      }
+      finally
+      {
+         clearVersionComparators();
+      }
+   }
+}

Modified: projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/test/VersionTestSuite.java
===================================================================
--- projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/test/VersionTestSuite.java	2008-02-06 21:35:44 UTC (rev 69673)
+++ projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/test/VersionTestSuite.java	2008-02-06 21:49:42 UTC (rev 69674)
@@ -44,6 +44,7 @@
       suite.addTest(VersionImplTestCase.suite());
       suite.addTest(VersionComparatorTestCase.suite());
       suite.addTest(VersionComparatorRegistryTestCase.suite());
+      suite.addTest(VersionRangeTestCase.suite());
 
       return suite;
    }




More information about the jboss-cvs-commits mailing list