[jboss-cvs] JBossAS SVN: r62295 - in projects/microcontainer/trunk/osgi-int: src/main/org/jboss/osgi/plugins/metadata and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Apr 12 05:10:25 EDT 2007


Author: alesj
Date: 2007-04-12 05:10:25 -0400 (Thu, 12 Apr 2007)
New Revision: 62295

Added:
   projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/OSGiAllTestSuite.java
   projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/BundleTestSuite.java
   projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/metadata/
   projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/metadata/VersionRangeTestCase.java
Removed:
   projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/TestBundleHeaders.java
   projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/TestVersionRange.java
   projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/forexport/
   projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/forimport/
   projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/
Modified:
   projects/microcontainer/trunk/osgi-int/pom.xml
   projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractVersionRange.java
Log:
Initial test cases - based on junit 3.8.1.

Modified: projects/microcontainer/trunk/osgi-int/pom.xml
===================================================================
--- projects/microcontainer/trunk/osgi-int/pom.xml	2007-04-12 08:49:53 UTC (rev 62294)
+++ projects/microcontainer/trunk/osgi-int/pom.xml	2007-04-12 09:10:25 UTC (rev 62295)
@@ -56,11 +56,17 @@
       <version>1.0</version>
     </dependency>
     <!-- Test dependencies -->
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>4.1</version>
-      <scope>test</scope>
-    </dependency>
+     <dependency>
+       <groupId>jboss</groupId>
+       <artifactId>jboss-test</artifactId>
+       <version>1.0.3.GA</version>
+       <scope>test</scope>
+     </dependency>
+     <dependency>
+        <groupId>junit</groupId>
+        <artifactId>junit</artifactId>
+        <version>3.8.1</version>
+        <scope>test</scope>
+     </dependency>
   </dependencies>
 </project>

Modified: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractVersionRange.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractVersionRange.java	2007-04-12 08:49:53 UTC (rev 62294)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractVersionRange.java	2007-04-12 09:10:25 UTC (rev 62295)
@@ -96,8 +96,15 @@
 
       }
       // check for parenthesis
-      if (mid && (floorIsGreaterThan == null || ceilingIsLessThan == null))
-         throw new IllegalArgumentException("Missing parenthesis: " + rangeSpec);
+      if (floorIsGreaterThan == null || ceilingIsLessThan == null)
+      {
+         // non-empty interval usage
+         if (mid)
+            throw new IllegalArgumentException("Missing parenthesis: " + rangeSpec);
+         // single value
+         floorIsGreaterThan = false;
+         ceilingIsLessThan = false;
+      }
 
       return new AbstractVersionRange(rangeSpec, floor, ceiling, floorIsGreaterThan, ceilingIsLessThan);
    }

Added: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/OSGiAllTestSuite.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/OSGiAllTestSuite.java	                        (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/OSGiAllTestSuite.java	2007-04-12 09:10:25 UTC (rev 62295)
@@ -0,0 +1,49 @@
+/*
+* 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;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+import org.jboss.test.bundle.BundleTestSuite;
+
+/**
+ * OSGi All Test Suite
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class OSGiAllTestSuite extends TestSuite
+{
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("OSGi All Tests");
+
+      suite.addTest(BundleTestSuite.suite());
+
+      return suite;
+   }
+}

Added: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/BundleTestSuite.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/BundleTestSuite.java	                        (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/BundleTestSuite.java	2007-04-12 09:10:25 UTC (rev 62295)
@@ -0,0 +1,49 @@
+/*
+* 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.bundle;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+import org.jboss.test.bundle.metadata.VersionRangeTestCase;
+
+/**
+ * Bundle Test Suite.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BundleTestSuite extends TestSuite
+{
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("Bundle Tests");
+
+      suite.addTest(VersionRangeTestCase.suite());
+
+      return suite;
+   }
+}

Deleted: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/TestBundleHeaders.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/TestBundleHeaders.java	2007-04-12 08:49:53 UTC (rev 62294)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/TestBundleHeaders.java	2007-04-12 09:10:25 UTC (rev 62295)
@@ -1,118 +0,0 @@
-
-package org.jboss.test.bundle;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.jboss.osgi.plugins.metadata.AbstractVersionRange;
-import org.jboss.osgi.spi.metadata.VersionRange;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import org.junit.Test;
-import org.osgi.framework.Version;
-
-/**
- * Tests of the bundle manifest headers
- * 
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class TestBundleHeaders
-{
-   @Test
-   public void testRangeSpecRE()
-   {
-      String rangeSpec = "1.0.0";
-      //                       ( 1  ) (2 (3)  (4)   ) (5 (6)  (7)    (8)   ) (9 (10) (11)   (12)   (13)        )
-      String versionPat = "\\[?(\\d+)|((\\d+).(\\d+))|((\\d+).(\\d+).(\\d+))|((\\d+).(\\d+).(\\d+).(\\p{Alnum}))\\]";
-      Pattern VERSION_RANGE_RE = Pattern.compile(versionPat);
-      Matcher matcher = VERSION_RANGE_RE.matcher(rangeSpec);
-      if( matcher.matches() == true )
-      {
-         System.out.println("groupCount: "+matcher.groupCount());
-         for(int n = 1; n <= matcher.groupCount(); n ++)
-         {
-            String g = matcher.group(n);
-            System.out.println(n+":"+g);
-         }
-      }
-   }
-
-   @Test
-   public void testExclusiveRanges()
-   {
-      VersionRange v100to110ExclusiveRange = AbstractVersionRange.parseRangeSpec("(1.0.0,1.1.0)");
-      VersionRange v100GAto110GAExclusvieRange = AbstractVersionRange.parseRangeSpec("(1.0.0.GA,1.1.0.GA)");
-      Version v100 = new Version("1.0.0");
-      Version v100ga = new Version("1.0.0.GA");
-      Version v110 = new Version("1.1.0");
-      Version v110ga = new Version("1.1.0.GA");
-      Version v101ga = new Version("1.0.1.GA");
-      Version v102 = new Version("1.0.2");
-      assertFalse("1.0.0 is in "+v100to110ExclusiveRange, v100to110ExclusiveRange.isInRange(v100));
-      assertFalse("1.1.0 is in "+v100to110ExclusiveRange, v100to110ExclusiveRange.isInRange(v110));
-      assertFalse("1.0.0.GA is in "+v100GAto110GAExclusvieRange, v100GAto110GAExclusvieRange.isInRange(v100ga));
-      assertFalse("1.1.0.GA is in "+v100GAto110GAExclusvieRange, v100GAto110GAExclusvieRange.isInRange(v110ga));
-      assertTrue("1.0.1.GA is in "+v100GAto110GAExclusvieRange, v100GAto110GAExclusvieRange.isInRange(v101ga));
-      assertTrue("1.0.2 is in "+v100GAto110GAExclusvieRange, v100GAto110GAExclusvieRange.isInRange(v102));
-   }
-
-   @Test
-   public void testInclusiveRanges()
-   {
-      VersionRange v100to110InclusiveRange = AbstractVersionRange.parseRangeSpec("[1.0.0,1.1.0]");
-      VersionRange v100GAto110GAInclusiveRange = AbstractVersionRange.parseRangeSpec("[1.0.0.GA,1.1.0.GA]");
-      Version v100 = new Version("1.0.0");
-      Version v100ga = new Version("1.0.0.GA");
-      Version v110 = new Version("1.1.0");
-      Version v110ga = new Version("1.1.0.GA");
-      Version v101ga = new Version("1.0.1.GA");
-      Version v102 = new Version("1.0.2");
-      assertTrue("1.0.0 is in "+v100to110InclusiveRange, v100to110InclusiveRange.isInRange(v100));
-      assertTrue("1.1.0 is in "+v100to110InclusiveRange, v100to110InclusiveRange.isInRange(v110));
-      assertTrue("1.0.0.GA is in "+v100GAto110GAInclusiveRange, v100GAto110GAInclusiveRange.isInRange(v100ga));
-      assertTrue("1.1.0.GA is in "+v100GAto110GAInclusiveRange, v100GAto110GAInclusiveRange.isInRange(v110ga));
-      assertTrue("1.0.1.GA is in "+v100GAto110GAInclusiveRange, v100GAto110GAInclusiveRange.isInRange(v101ga));
-      assertTrue("1.0.2 is in "+v100GAto110GAInclusiveRange, v100GAto110GAInclusiveRange.isInRange(v102));
-   }
-
-   @Test
-   public void testMixedRanges()
-   {
-      VersionRange v100to110InclusiveLowerExclusiveUpperRange = AbstractVersionRange.parseRangeSpec("[1.0.0,1.1.0)");
-      VersionRange v100to110ExclusiveLowerInclusiveUpperRange = AbstractVersionRange.parseRangeSpec("(1.0.0,1.1.0]");
-      VersionRange v100GAto110GAInclusiveLowerExclusiveUpperRange = AbstractVersionRange.parseRangeSpec("[1.0.0.GA,1.1.0.GA)");
-      VersionRange v100GAto110GAExclusiveLowerInclusiveUpperRange = AbstractVersionRange.parseRangeSpec("(1.0.0.GA,1.1.0.GA]");
-      Version v100 = new Version("1.0.0");
-      Version v100ga = new Version("1.0.0.GA");
-      Version v110 = new Version("1.1.0");
-      Version v110ga = new Version("1.1.0.GA");
-      Version v101ga = new Version("1.0.1.GA");
-      Version v102 = new Version("1.0.2");
-      assertTrue("1.0.0 is in "+v100to110InclusiveLowerExclusiveUpperRange, v100to110InclusiveLowerExclusiveUpperRange.isInRange(v100));
-      assertFalse("1.0.0 is in "+v100to110ExclusiveLowerInclusiveUpperRange, v100to110ExclusiveLowerInclusiveUpperRange.isInRange(v100));
-      assertFalse("1.1.0 is in "+v100to110InclusiveLowerExclusiveUpperRange, v100to110InclusiveLowerExclusiveUpperRange.isInRange(v110));
-      assertTrue("1.1.0 is in "+v100to110ExclusiveLowerInclusiveUpperRange, v100to110ExclusiveLowerInclusiveUpperRange.isInRange(v110));
-
-      assertTrue("1.0.0.GA is in "+v100GAto110GAInclusiveLowerExclusiveUpperRange, v100GAto110GAInclusiveLowerExclusiveUpperRange.isInRange(v100ga));
-      assertFalse("1.1.0.GA is in "+v100GAto110GAInclusiveLowerExclusiveUpperRange, v100GAto110GAInclusiveLowerExclusiveUpperRange.isInRange(v110ga));
-      assertFalse("1.0.0.GA is in "+v100GAto110GAExclusiveLowerInclusiveUpperRange, v100GAto110GAExclusiveLowerInclusiveUpperRange.isInRange(v100ga));
-      assertTrue("1.1.0.GA is in "+v100GAto110GAExclusiveLowerInclusiveUpperRange, v100GAto110GAExclusiveLowerInclusiveUpperRange.isInRange(v110ga));
-      assertTrue("1.0.1.GA is in "+v100GAto110GAExclusiveLowerInclusiveUpperRange, v100GAto110GAExclusiveLowerInclusiveUpperRange.isInRange(v101ga));
-      assertTrue("1.0.2 is in "+v100GAto110GAExclusiveLowerInclusiveUpperRange, v100GAto110GAExclusiveLowerInclusiveUpperRange.isInRange(v102));
-   }
-
-   @Test
-   public void testSingleRange()
-   {
-      VersionRange v100Range = AbstractVersionRange.parseRangeSpec("1.0.0");
-      Version v100 = new Version("1.0.0");
-      assertTrue("1.0.0 is in "+v100Range, v100Range.isInRange(v100));
-      Version v200 = new Version("2.0.0");
-      assertTrue("2.0.0 is in "+v100Range, v100Range.isInRange(v200));
-      Version v200ga = new Version("2.0.0.GA");
-      assertTrue("2.0.0.GA is in "+v100Range, v100Range.isInRange(v200ga));
-      Version v09beta = new Version("0.9.0.beta");
-      assertFalse("0.9.0.beta is in "+v100Range, v100Range.isInRange(v09beta));
-   }
-}

Deleted: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/TestVersionRange.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/TestVersionRange.java	2007-04-12 08:49:53 UTC (rev 62294)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/TestVersionRange.java	2007-04-12 09:10:25 UTC (rev 62295)
@@ -1,118 +0,0 @@
-
-package org.jboss.test.bundle;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.jboss.osgi.plugins.metadata.AbstractVersionRange;
-import org.jboss.osgi.spi.metadata.VersionRange;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import org.junit.Test;
-import org.osgi.framework.Version;
-
-/**
- * Tests of the version range comparision
- * 
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class TestVersionRange
-{
-   @Test
-   public void testRangeSpecRE()
-   {
-      String rangeSpec = "1.0.0";
-      //                       ( 1  ) (2 (3)  (4)   ) (5 (6)  (7)    (8)   ) (9 (10) (11)   (12)   (13)        )
-      String versionPat = "\\[?(\\d+)|((\\d+).(\\d+))|((\\d+).(\\d+).(\\d+))|((\\d+).(\\d+).(\\d+).(\\p{Alnum}))\\]";
-      Pattern VERSION_RANGE_RE = Pattern.compile(versionPat);
-      Matcher matcher = VERSION_RANGE_RE.matcher(rangeSpec);
-      if( matcher.matches() == true )
-      {
-         System.out.println("groupCount: "+matcher.groupCount());
-         for(int n = 1; n <= matcher.groupCount(); n ++)
-         {
-            String g = matcher.group(n);
-            System.out.println(n+":"+g);
-         }
-      }
-   }
-
-   @Test
-   public void testExclusiveRanges()
-   {
-      VersionRange v100to110ExclusiveRange = AbstractVersionRange.parseRangeSpec("(1.0.0,1.1.0)");
-      VersionRange v100GAto110GAExclusvieRange = AbstractVersionRange.parseRangeSpec("(1.0.0.GA,1.1.0.GA)");
-      Version v100 = new Version("1.0.0");
-      Version v100ga = new Version("1.0.0.GA");
-      Version v110 = new Version("1.1.0");
-      Version v110ga = new Version("1.1.0.GA");
-      Version v101ga = new Version("1.0.1.GA");
-      Version v102 = new Version("1.0.2");
-      assertFalse("1.0.0 is in "+v100to110ExclusiveRange, v100to110ExclusiveRange.isInRange(v100));
-      assertFalse("1.1.0 is in "+v100to110ExclusiveRange, v100to110ExclusiveRange.isInRange(v110));
-      assertFalse("1.0.0.GA is in "+v100GAto110GAExclusvieRange, v100GAto110GAExclusvieRange.isInRange(v100ga));
-      assertFalse("1.1.0.GA is in "+v100GAto110GAExclusvieRange, v100GAto110GAExclusvieRange.isInRange(v110ga));
-      assertTrue("1.0.1.GA is in "+v100GAto110GAExclusvieRange, v100GAto110GAExclusvieRange.isInRange(v101ga));
-      assertTrue("1.0.2 is in "+v100GAto110GAExclusvieRange, v100GAto110GAExclusvieRange.isInRange(v102));
-   }
-
-   @Test
-   public void testInclusiveRanges()
-   {
-      VersionRange v100to110InclusiveRange = AbstractVersionRange.parseRangeSpec("[1.0.0,1.1.0]");
-      VersionRange v100GAto110GAInclusiveRange = AbstractVersionRange.parseRangeSpec("[1.0.0.GA,1.1.0.GA]");
-      Version v100 = new Version("1.0.0");
-      Version v100ga = new Version("1.0.0.GA");
-      Version v110 = new Version("1.1.0");
-      Version v110ga = new Version("1.1.0.GA");
-      Version v101ga = new Version("1.0.1.GA");
-      Version v102 = new Version("1.0.2");
-      assertTrue("1.0.0 is in "+v100to110InclusiveRange, v100to110InclusiveRange.isInRange(v100));
-      assertTrue("1.1.0 is in "+v100to110InclusiveRange, v100to110InclusiveRange.isInRange(v110));
-      assertTrue("1.0.0.GA is in "+v100GAto110GAInclusiveRange, v100GAto110GAInclusiveRange.isInRange(v100ga));
-      assertTrue("1.1.0.GA is in "+v100GAto110GAInclusiveRange, v100GAto110GAInclusiveRange.isInRange(v110ga));
-      assertTrue("1.0.1.GA is in "+v100GAto110GAInclusiveRange, v100GAto110GAInclusiveRange.isInRange(v101ga));
-      assertTrue("1.0.2 is in "+v100GAto110GAInclusiveRange, v100GAto110GAInclusiveRange.isInRange(v102));
-   }
-
-   @Test
-   public void testMixedRanges()
-   {
-      VersionRange v100to110InclusiveLowerExclusiveUpperRange = AbstractVersionRange.parseRangeSpec("[1.0.0,1.1.0)");
-      VersionRange v100to110ExclusiveLowerInclusiveUpperRange = AbstractVersionRange.parseRangeSpec("(1.0.0,1.1.0]");
-      VersionRange v100GAto110GAInclusiveLowerExclusiveUpperRange = AbstractVersionRange.parseRangeSpec("[1.0.0.GA,1.1.0.GA)");
-      VersionRange v100GAto110GAExclusiveLowerInclusiveUpperRange = AbstractVersionRange.parseRangeSpec("(1.0.0.GA,1.1.0.GA]");
-      Version v100 = new Version("1.0.0");
-      Version v100ga = new Version("1.0.0.GA");
-      Version v110 = new Version("1.1.0");
-      Version v110ga = new Version("1.1.0.GA");
-      Version v101ga = new Version("1.0.1.GA");
-      Version v102 = new Version("1.0.2");
-      assertTrue("1.0.0 is in "+v100to110InclusiveLowerExclusiveUpperRange, v100to110InclusiveLowerExclusiveUpperRange.isInRange(v100));
-      assertFalse("1.0.0 is in "+v100to110ExclusiveLowerInclusiveUpperRange, v100to110ExclusiveLowerInclusiveUpperRange.isInRange(v100));
-      assertFalse("1.1.0 is in "+v100to110InclusiveLowerExclusiveUpperRange, v100to110InclusiveLowerExclusiveUpperRange.isInRange(v110));
-      assertTrue("1.1.0 is in "+v100to110ExclusiveLowerInclusiveUpperRange, v100to110ExclusiveLowerInclusiveUpperRange.isInRange(v110));
-
-      assertTrue("1.0.0.GA is in "+v100GAto110GAInclusiveLowerExclusiveUpperRange, v100GAto110GAInclusiveLowerExclusiveUpperRange.isInRange(v100ga));
-      assertFalse("1.1.0.GA is in "+v100GAto110GAInclusiveLowerExclusiveUpperRange, v100GAto110GAInclusiveLowerExclusiveUpperRange.isInRange(v110ga));
-      assertFalse("1.0.0.GA is in "+v100GAto110GAExclusiveLowerInclusiveUpperRange, v100GAto110GAExclusiveLowerInclusiveUpperRange.isInRange(v100ga));
-      assertTrue("1.1.0.GA is in "+v100GAto110GAExclusiveLowerInclusiveUpperRange, v100GAto110GAExclusiveLowerInclusiveUpperRange.isInRange(v110ga));
-      assertTrue("1.0.1.GA is in "+v100GAto110GAExclusiveLowerInclusiveUpperRange, v100GAto110GAExclusiveLowerInclusiveUpperRange.isInRange(v101ga));
-      assertTrue("1.0.2 is in "+v100GAto110GAExclusiveLowerInclusiveUpperRange, v100GAto110GAExclusiveLowerInclusiveUpperRange.isInRange(v102));
-   }
-
-   @Test
-   public void testSingleRange()
-   {
-      VersionRange v100Range = AbstractVersionRange.parseRangeSpec("1.0.0");
-      Version v100 = new Version("1.0.0");
-      assertTrue("1.0.0 is in "+v100Range, v100Range.isInRange(v100));
-      Version v200 = new Version("2.0.0");
-      assertTrue("2.0.0 is in "+v100Range, v100Range.isInRange(v200));
-      Version v200ga = new Version("2.0.0.GA");
-      assertTrue("2.0.0.GA is in "+v100Range, v100Range.isInRange(v200ga));
-      Version v09beta = new Version("0.9.0.beta");
-      assertFalse("0.9.0.beta is in "+v100Range, v100Range.isInRange(v09beta));
-   }
-}

Copied: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/metadata/VersionRangeTestCase.java (from rev 62289, projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/TestVersionRange.java)
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/metadata/VersionRangeTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/metadata/VersionRangeTestCase.java	2007-04-12 09:10:25 UTC (rev 62295)
@@ -0,0 +1,123 @@
+
+package org.jboss.test.bundle.metadata;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.jboss.osgi.plugins.metadata.AbstractVersionRange;
+import org.jboss.osgi.spi.metadata.VersionRange;
+import org.jboss.test.BaseTestCase;
+import org.osgi.framework.Version;
+
+/**
+ * Tests of the version range comparision.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @author Ales.Justin at jboss.org
+ */
+public class VersionRangeTestCase extends BaseTestCase
+{
+   public VersionRangeTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return new TestSuite(VersionRangeTestCase.class);
+   }
+
+   public void testRangeSpecRE() throws Exception
+   {
+      String rangeSpec = "1.0.0";
+      //                       ( 1  ) (2 (3)  (4)   ) (5 (6)  (7)    (8)   ) (9 (10) (11)   (12)   (13)        )
+      String versionPat = "\\[?(\\d+)|((\\d+).(\\d+))|((\\d+).(\\d+).(\\d+))|((\\d+).(\\d+).(\\d+).(\\p{Alnum}))\\]";
+      Pattern VERSION_RANGE_RE = Pattern.compile(versionPat);
+      Matcher matcher = VERSION_RANGE_RE.matcher(rangeSpec);
+      if( matcher.matches() == true )
+      {
+         System.out.println("groupCount: "+matcher.groupCount());
+         for(int n = 1; n <= matcher.groupCount(); n ++)
+         {
+            String g = matcher.group(n);
+            System.out.println(n+":"+g);
+         }
+      }
+   }
+
+   public void testExclusiveRanges() throws Exception
+   {
+      VersionRange v100to110ExclusiveRange = AbstractVersionRange.parseRangeSpec("(1.0.0,1.1.0)");
+      VersionRange v100GAto110GAExclusvieRange = AbstractVersionRange.parseRangeSpec("(1.0.0.GA,1.1.0.GA)");
+      Version v100 = new Version("1.0.0");
+      Version v100ga = new Version("1.0.0.GA");
+      Version v110 = new Version("1.1.0");
+      Version v110ga = new Version("1.1.0.GA");
+      Version v101ga = new Version("1.0.1.GA");
+      Version v102 = new Version("1.0.2");
+      assertFalse("1.0.0 is in "+v100to110ExclusiveRange, v100to110ExclusiveRange.isInRange(v100));
+      assertFalse("1.1.0 is in "+v100to110ExclusiveRange, v100to110ExclusiveRange.isInRange(v110));
+      assertFalse("1.0.0.GA is in "+v100GAto110GAExclusvieRange, v100GAto110GAExclusvieRange.isInRange(v100ga));
+      assertFalse("1.1.0.GA is in "+v100GAto110GAExclusvieRange, v100GAto110GAExclusvieRange.isInRange(v110ga));
+      assertTrue("1.0.1.GA is in "+v100GAto110GAExclusvieRange, v100GAto110GAExclusvieRange.isInRange(v101ga));
+      assertTrue("1.0.2 is in "+v100GAto110GAExclusvieRange, v100GAto110GAExclusvieRange.isInRange(v102));
+   }
+
+   public void testInclusiveRanges() throws Exception
+   {
+      VersionRange v100to110InclusiveRange = AbstractVersionRange.parseRangeSpec("[1.0.0,1.1.0]");
+      VersionRange v100GAto110GAInclusiveRange = AbstractVersionRange.parseRangeSpec("[1.0.0.GA,1.1.0.GA]");
+      Version v100 = new Version("1.0.0");
+      Version v100ga = new Version("1.0.0.GA");
+      Version v110 = new Version("1.1.0");
+      Version v110ga = new Version("1.1.0.GA");
+      Version v101ga = new Version("1.0.1.GA");
+      Version v102 = new Version("1.0.2");
+      assertTrue("1.0.0 is in "+v100to110InclusiveRange, v100to110InclusiveRange.isInRange(v100));
+      assertTrue("1.1.0 is in "+v100to110InclusiveRange, v100to110InclusiveRange.isInRange(v110));
+      assertTrue("1.0.0.GA is in "+v100GAto110GAInclusiveRange, v100GAto110GAInclusiveRange.isInRange(v100ga));
+      assertTrue("1.1.0.GA is in "+v100GAto110GAInclusiveRange, v100GAto110GAInclusiveRange.isInRange(v110ga));
+      assertTrue("1.0.1.GA is in "+v100GAto110GAInclusiveRange, v100GAto110GAInclusiveRange.isInRange(v101ga));
+      assertTrue("1.0.2 is in "+v100GAto110GAInclusiveRange, v100GAto110GAInclusiveRange.isInRange(v102));
+   }
+
+   public void testMixedRanges() throws Exception
+   {
+      VersionRange v100to110InclusiveLowerExclusiveUpperRange = AbstractVersionRange.parseRangeSpec("[1.0.0,1.1.0)");
+      VersionRange v100to110ExclusiveLowerInclusiveUpperRange = AbstractVersionRange.parseRangeSpec("(1.0.0,1.1.0]");
+      VersionRange v100GAto110GAInclusiveLowerExclusiveUpperRange = AbstractVersionRange.parseRangeSpec("[1.0.0.GA,1.1.0.GA)");
+      VersionRange v100GAto110GAExclusiveLowerInclusiveUpperRange = AbstractVersionRange.parseRangeSpec("(1.0.0.GA,1.1.0.GA]");
+      Version v100 = new Version("1.0.0");
+      Version v100ga = new Version("1.0.0.GA");
+      Version v110 = new Version("1.1.0");
+      Version v110ga = new Version("1.1.0.GA");
+      Version v101ga = new Version("1.0.1.GA");
+      Version v102 = new Version("1.0.2");
+      assertTrue("1.0.0 is in "+v100to110InclusiveLowerExclusiveUpperRange, v100to110InclusiveLowerExclusiveUpperRange.isInRange(v100));
+      assertFalse("1.0.0 is in "+v100to110ExclusiveLowerInclusiveUpperRange, v100to110ExclusiveLowerInclusiveUpperRange.isInRange(v100));
+      assertFalse("1.1.0 is in "+v100to110InclusiveLowerExclusiveUpperRange, v100to110InclusiveLowerExclusiveUpperRange.isInRange(v110));
+      assertTrue("1.1.0 is in "+v100to110ExclusiveLowerInclusiveUpperRange, v100to110ExclusiveLowerInclusiveUpperRange.isInRange(v110));
+
+      assertTrue("1.0.0.GA is in "+v100GAto110GAInclusiveLowerExclusiveUpperRange, v100GAto110GAInclusiveLowerExclusiveUpperRange.isInRange(v100ga));
+      assertFalse("1.1.0.GA is in "+v100GAto110GAInclusiveLowerExclusiveUpperRange, v100GAto110GAInclusiveLowerExclusiveUpperRange.isInRange(v110ga));
+      assertFalse("1.0.0.GA is in "+v100GAto110GAExclusiveLowerInclusiveUpperRange, v100GAto110GAExclusiveLowerInclusiveUpperRange.isInRange(v100ga));
+      assertTrue("1.1.0.GA is in "+v100GAto110GAExclusiveLowerInclusiveUpperRange, v100GAto110GAExclusiveLowerInclusiveUpperRange.isInRange(v110ga));
+      assertTrue("1.0.1.GA is in "+v100GAto110GAExclusiveLowerInclusiveUpperRange, v100GAto110GAExclusiveLowerInclusiveUpperRange.isInRange(v101ga));
+      assertTrue("1.0.2 is in "+v100GAto110GAExclusiveLowerInclusiveUpperRange, v100GAto110GAExclusiveLowerInclusiveUpperRange.isInRange(v102));
+   }
+
+   public void testSingleRange() throws Exception
+   {
+      VersionRange v100Range = AbstractVersionRange.parseRangeSpec("1.0.0");
+      Version v100 = new Version("1.0.0");
+      assertTrue("1.0.0 is in "+v100Range, v100Range.isInRange(v100));
+      Version v200 = new Version("2.0.0");
+      assertTrue("2.0.0 is in "+v100Range, v100Range.isInRange(v200));
+      Version v200ga = new Version("2.0.0.GA");
+      assertTrue("2.0.0.GA is in "+v100Range, v100Range.isInRange(v200ga));
+      Version v09beta = new Version("0.9.0.beta");
+      assertFalse("0.9.0.beta is in "+v100Range, v100Range.isInRange(v09beta));
+   }
+}


Property changes on: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/metadata/VersionRangeTestCase.java
___________________________________________________________________
Name: svn:executable
   + *




More information about the jboss-cvs-commits mailing list