[jboss-cvs] JBossAS SVN: r69175 - in projects/microcontainer/trunk/deployers-structure-spi/src: main/org/jboss/deployers/structure/spi/classloading/helpers and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jan 21 10:38:07 EST 2008
Author: alesj
Date: 2008-01-21 10:38:07 -0500 (Mon, 21 Jan 2008)
New Revision: 69175
Added:
projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/support/DVIVersionComparator.java
projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/support/DummyVersion.java
projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/support/DummyVersionComparator.java
projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/support/ZeroVersion.java
projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/test/AbstractVersionTest.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/VersionComparatorRegistry.java
projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/classloading/helpers/VersionImpl.java
projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/test/VersionComparatorRegistryTestCase.java
projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/test/VersionComparatorTestCase.java
projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/test/VersionImplTestCase.java
Log:
Version impl tests.
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-01-21 15:20:18 UTC (rev 69174)
+++ projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/classloading/Version.java 2008-01-21 15:38:07 UTC (rev 69175)
@@ -33,7 +33,7 @@
public abstract class Version implements Comparable<Version>
{
/** The default version */
- public static final Version DEFAULT_VERSION = VersionImpl.parseVersion(null);
+ public static final Version DEFAULT_VERSION = new VersionImpl(0, 0, 0);
public int compareTo(Version v)
{
Modified: projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/classloading/VersionComparatorRegistry.java
===================================================================
--- projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/classloading/VersionComparatorRegistry.java 2008-01-21 15:20:18 UTC (rev 69174)
+++ projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/classloading/VersionComparatorRegistry.java 2008-01-21 15:38:07 UTC (rev 69175)
@@ -155,7 +155,7 @@
* @return the matching comparator
*/
@SuppressWarnings("unchecked")
- protected VersionComparator getComparator(Class<? extends Version> t, Class<? extends Version> u)
+ public VersionComparator getComparator(Class<? extends Version> t, Class<? extends Version> u)
{
Map<Class<? extends Version>, VersionComparator> map = comparatorMap.get(t);
if (map == null)
Modified: projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/classloading/helpers/VersionImpl.java
===================================================================
--- projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/classloading/helpers/VersionImpl.java 2008-01-21 15:20:18 UTC (rev 69174)
+++ projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/classloading/helpers/VersionImpl.java 2008-01-21 15:38:07 UTC (rev 69175)
@@ -38,7 +38,7 @@
public class VersionImpl extends Version
{
private static final String SEPARATOR = ".";
- private static Pattern QUALIFIER_PATTERN = Pattern.compile("[a-zA-Z0-9_-]*");
+ private static volatile Pattern QUALIFIER_PATTERN;
/**
* The empty version.
@@ -66,7 +66,7 @@
validate();
}
- public VersionImpl(String version)
+ private VersionImpl(String version)
{
if (version == null)
throw new IllegalArgumentException("Null version");
@@ -127,6 +127,10 @@
throw new IllegalArgumentException("negative minor: " + minor);
if (micro < 0)
throw new IllegalArgumentException("negative micro: " + micro);
+
+ if (QUALIFIER_PATTERN == null)
+ QUALIFIER_PATTERN = Pattern.compile("[a-zA-Z0-9_-]*");
+
if (QUALIFIER_PATTERN.matcher(qualifier).matches() == false)
throw new IllegalArgumentException("invalid qualifier: " + qualifier);
}
Added: projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/support/DVIVersionComparator.java
===================================================================
--- projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/support/DVIVersionComparator.java (rev 0)
+++ projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/support/DVIVersionComparator.java 2008-01-21 15:38:07 UTC (rev 69175)
@@ -0,0 +1,38 @@
+/*
+* 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.support;
+
+import org.jboss.deployers.structure.spi.classloading.VersionComparator;
+import org.jboss.deployers.structure.spi.classloading.helpers.VersionImpl;
+
+/**
+ * Dummy+VersionImpl version comparator.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class DVIVersionComparator implements VersionComparator<DummyVersion, VersionImpl>
+{
+ public int compare(DummyVersion d, VersionImpl v)
+ {
+ return d.getVersion() - v.getMajor();
+ }
+}
Added: projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/support/DummyVersion.java
===================================================================
--- projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/support/DummyVersion.java (rev 0)
+++ projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/support/DummyVersion.java 2008-01-21 15:38:07 UTC (rev 69175)
@@ -0,0 +1,44 @@
+/*
+* 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.support;
+
+import org.jboss.deployers.structure.spi.classloading.Version;
+
+/**
+ * Dummy version.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class DummyVersion extends Version
+{
+ private int version;
+
+ public DummyVersion(int version)
+ {
+ this.version = version;
+ }
+
+ public int getVersion()
+ {
+ return version;
+ }
+}
Added: projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/support/DummyVersionComparator.java
===================================================================
--- projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/support/DummyVersionComparator.java (rev 0)
+++ projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/support/DummyVersionComparator.java 2008-01-21 15:38:07 UTC (rev 69175)
@@ -0,0 +1,37 @@
+/*
+* 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.support;
+
+import org.jboss.deployers.structure.spi.classloading.VersionComparator;
+
+/**
+ * Dummy version comparator.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class DummyVersionComparator implements VersionComparator<DummyVersion, DummyVersion>
+{
+ public int compare(DummyVersion d1, DummyVersion d2)
+ {
+ return d1.getVersion() - d2.getVersion();
+ }
+}
Added: projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/support/ZeroVersion.java
===================================================================
--- projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/support/ZeroVersion.java (rev 0)
+++ projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/support/ZeroVersion.java 2008-01-21 15:38:07 UTC (rev 69175)
@@ -0,0 +1,33 @@
+/*
+* 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.support;
+
+import org.jboss.deployers.structure.spi.classloading.Version;
+
+/**
+ * Zero version.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ZeroVersion extends Version
+{
+}
Added: projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/test/AbstractVersionTest.java
===================================================================
--- projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/test/AbstractVersionTest.java (rev 0)
+++ projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/test/AbstractVersionTest.java 2008-01-21 15:38:07 UTC (rev 69175)
@@ -0,0 +1,107 @@
+/*
+* 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 org.jboss.deployers.structure.spi.classloading.Version;
+import org.jboss.deployers.structure.spi.classloading.VersionComparatorRegistry;
+import org.jboss.deployers.structure.spi.classloading.helpers.VersionImpl;
+import org.jboss.test.BaseTestCase;
+import org.jboss.test.deployers.structure.version.support.DVIVersionComparator;
+import org.jboss.test.deployers.structure.version.support.DummyVersion;
+import org.jboss.test.deployers.structure.version.support.DummyVersionComparator;
+
+/**
+ * Abstarct Version test.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class AbstractVersionTest extends BaseTestCase
+{
+ protected AbstractVersionTest(String name)
+ {
+ super(name);
+ }
+
+ protected void registerVersionComparators() throws Exception
+ {
+ VersionComparatorRegistry registry = VersionComparatorRegistry.getInstance();
+
+ DummyVersionComparator dummyVersionComparator = new DummyVersionComparator();
+ DVIVersionComparator dviVersionComparator = new DVIVersionComparator();
+
+ registry.registerVersionComparator(DummyVersion.class, dummyVersionComparator);
+ registry.registerVersionComparator(DummyVersion.class, VersionImpl.class, dviVersionComparator);
+ }
+
+ protected void clearVersionComparators() throws Exception
+ {
+ VersionComparatorRegistry registry = VersionComparatorRegistry.getInstance();
+
+ registry.removeVersionComparator(DummyVersion.class);
+ assertNull(registry.getComparator(DummyVersion.class, DummyVersion.class));
+ registry.removeVersionComparator(DummyVersion.class, VersionImpl.class);
+ assertNull(registry.getComparator(DummyVersion.class, VersionImpl.class));
+ }
+
+ protected void assertFailVersion(int major, int minor, int micro, String qualifier)
+ {
+ try
+ {
+ VersionImpl version = new VersionImpl(major, minor, micro, qualifier);
+ fail("Should not be here: " + version);
+ }
+ catch(Exception e)
+ {
+ assertInstanceOf(e, IllegalArgumentException.class);
+ }
+ }
+
+ protected void assertFailVersion(Version v1, Version v2)
+ {
+ try
+ {
+ assertNotNull(v1);
+ assertNotNull(v2);
+ v1.compareTo(v2);
+ fail("Should not be here.");
+ }
+ catch(Exception e)
+ {
+ assertInstanceOf(e, IllegalArgumentException.class);
+ }
+ }
+
+ protected void assertGreater(Version v1, Version v2)
+ {
+ assertTrue(v1.compareTo(v2) > 0);
+ }
+
+ protected void assertLess(Version v1, Version v2)
+ {
+ assertTrue(v1.compareTo(v2) < 0);
+ }
+
+ protected void assertEquals(Version v1, Version v2)
+ {
+ assertTrue(v1.compareTo(v2) == 0);
+ }
+}
Modified: projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/test/VersionComparatorRegistryTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/test/VersionComparatorRegistryTestCase.java 2008-01-21 15:20:18 UTC (rev 69174)
+++ projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/test/VersionComparatorRegistryTestCase.java 2008-01-21 15:38:07 UTC (rev 69175)
@@ -22,14 +22,20 @@
package org.jboss.test.deployers.structure.version.test;
import junit.framework.Test;
-import org.jboss.test.BaseTestCase;
+import org.jboss.deployers.structure.spi.classloading.VersionComparatorRegistry;
+import org.jboss.deployers.structure.spi.classloading.helpers.VersionImpl;
+import org.jboss.deployers.structure.spi.classloading.helpers.VersionImplComparator;
+import org.jboss.test.deployers.structure.version.support.DVIVersionComparator;
+import org.jboss.test.deployers.structure.version.support.DummyVersion;
+import org.jboss.test.deployers.structure.version.support.DummyVersionComparator;
+import org.jboss.test.deployers.structure.version.support.ZeroVersion;
/**
* Version comparator registry tests.
*
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
-public class VersionComparatorRegistryTestCase extends BaseTestCase
+public class VersionComparatorRegistryTestCase extends AbstractVersionTest
{
public VersionComparatorRegistryTestCase(String name)
{
@@ -41,18 +47,33 @@
return suite(VersionComparatorRegistryTestCase.class);
}
- public void testRegisterComparator() throws Exception
+ public void testRegistry() throws Exception
{
- // todo
- }
+ VersionComparatorRegistry registry = VersionComparatorRegistry.getInstance();
- public void testRemoveComparator() throws Exception
- {
- // todo
- }
+ DummyVersionComparator dummyVersionComparator = new DummyVersionComparator();
+ DVIVersionComparator dviVersionComparator = new DVIVersionComparator();
+ try
+ {
+ registry.registerVersionComparator(DummyVersion.class, dummyVersionComparator);
+ registry.registerVersionComparator(DummyVersion.class, VersionImpl.class, dviVersionComparator);
- public void testGetComparator() throws Exception
- {
- // todo
+ assertSame(dummyVersionComparator, registry.getComparator(DummyVersion.class, DummyVersion.class));
+ assertSame(dviVersionComparator, registry.getComparator(DummyVersion.class, VersionImpl.class));
+ // expecting pre-registered
+ assertInstanceOf(registry.getComparator(VersionImpl.class, VersionImpl.class), VersionImplComparator.class);
+ // expecting switch
+ assertNotNull(registry.getComparator(VersionImpl.class, DummyVersion.class));
+ // expecting nulls
+ assertNull(registry.getComparator(ZeroVersion.class, ZeroVersion.class));
+ assertNull(registry.getComparator(ZeroVersion.class, DummyVersion.class));
+ assertNull(registry.getComparator(ZeroVersion.class, VersionImpl.class));
+ assertNull(registry.getComparator(DummyVersion.class, ZeroVersion.class));
+ assertNull(registry.getComparator(VersionImpl.class, ZeroVersion.class));
+ }
+ finally
+ {
+ clearVersionComparators();
+ }
}
}
Modified: projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/test/VersionComparatorTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/test/VersionComparatorTestCase.java 2008-01-21 15:20:18 UTC (rev 69174)
+++ projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/test/VersionComparatorTestCase.java 2008-01-21 15:38:07 UTC (rev 69175)
@@ -22,14 +22,17 @@
package org.jboss.test.deployers.structure.version.test;
import junit.framework.Test;
-import org.jboss.test.BaseTestCase;
+import org.jboss.deployers.structure.spi.classloading.Version;
+import org.jboss.deployers.structure.spi.classloading.helpers.VersionImpl;
+import org.jboss.test.deployers.structure.version.support.DummyVersion;
+import org.jboss.test.deployers.structure.version.support.ZeroVersion;
/**
* Version comparator tests.
*
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
-public class VersionComparatorTestCase extends BaseTestCase
+public class VersionComparatorTestCase extends AbstractVersionTest
{
public VersionComparatorTestCase(String name)
{
@@ -43,11 +46,57 @@
public void testSameImpl() throws Exception
{
- // todo
+ registerVersionComparators();
+ try
+ {
+ Version vi1 = VersionImpl.parseVersion("1.2.3");
+ Version vi2 = VersionImpl.parseVersion("2.0.0.GA");
+ assertLess(vi1, vi2);
+ assertGreater(vi2, vi1);
+ assertEquals(vi2, new VersionImpl(2, 0, 0, "GA"));
+
+ DummyVersion dv1 = new DummyVersion(1);
+ DummyVersion dv2 = new DummyVersion(2);
+ DummyVersion dv3 = new DummyVersion(2);
+ assertLess(dv1, dv2);
+ assertGreater(dv2, dv1);
+ assertEquals(dv2, dv3);
+ }
+ finally
+ {
+ clearVersionComparators();
+ }
}
public void testDifferentImpl() throws Exception
{
- // todo
+ registerVersionComparators();
+ try
+ {
+ Version vi1 = VersionImpl.parseVersion("1.2.3");
+ Version vi2 = VersionImpl.parseVersion("2.0.0.GA");
+ DummyVersion dv1 = new DummyVersion(1);
+ DummyVersion dv2 = new DummyVersion(2);
+
+ assertLess(dv1, vi2);
+ assertLess(vi1, dv2);
+ assertGreater(vi2, dv1);
+ assertGreater(dv2, vi1);
+ assertEquals(vi2, dv2);
+ assertEquals(dv2, vi2);
+ }
+ finally
+ {
+ clearVersionComparators();
+ }
}
+
+ public void testFailure() throws Exception
+ {
+ ZeroVersion z1 = new ZeroVersion();
+ assertFailVersion(z1, Version.DEFAULT_VERSION);
+ assertFailVersion(z1, new DummyVersion(0));
+ assertFailVersion(Version.DEFAULT_VERSION, z1);
+ assertFailVersion(new DummyVersion(0), z1);
+ }
}
Modified: projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/test/VersionImplTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/test/VersionImplTestCase.java 2008-01-21 15:20:18 UTC (rev 69174)
+++ projects/microcontainer/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/version/test/VersionImplTestCase.java 2008-01-21 15:38:07 UTC (rev 69175)
@@ -22,14 +22,15 @@
package org.jboss.test.deployers.structure.version.test;
import junit.framework.Test;
-import org.jboss.test.BaseTestCase;
+import org.jboss.deployers.structure.spi.classloading.Version;
+import org.jboss.deployers.structure.spi.classloading.helpers.VersionImpl;
/**
* Version impl tests.
*
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
-public class VersionImplTestCase extends BaseTestCase
+public class VersionImplTestCase extends AbstractVersionTest
{
public VersionImplTestCase(String name)
{
@@ -41,18 +42,53 @@
return suite(VersionImplTestCase.class);
}
+ protected void assertVersion(VersionImpl version)
+ {
+ assertEquals(1, version.getMajor());
+ assertEquals(2, version.getMinor());
+ assertEquals(3, version.getMicro());
+ assertEquals("CR1", version.getQualifier());
+ assertEquals(new VersionImpl(1, 2, 3, "CR1"), version);
+ }
+
public void testSimpleVersion() throws Exception
{
- // todo
+ assertVersion(new VersionImpl(1, 2, 3, "CR1"));
+ assertVersion(VersionImpl.parseVersion("1.2.3.CR1"));
+ assertEquals(Version.DEFAULT_VERSION, VersionImpl.parseVersion(null));
+ assertEquals(new VersionImpl(1, 2, 3), VersionImpl.parseVersion("1.2.3"));
}
public void testIllegalVersion() throws Exception
{
- // todo
+ assertFailVersion(-1, 2, 3, "Beta10");
+ assertFailVersion(1, -2, 3, "CR1");
+ assertFailVersion(1, 2, -3, "CR2");
+ assertFailVersion(1, 2, 3, "GA@");
}
public void testCompareVersion() throws Exception
{
- // todo
+ VersionImpl v1 = new VersionImpl(1, 2, 3);
+ VersionImpl v2 = new VersionImpl(1, 2, 4);
+ assertLess(v1, v2);
+ assertGreater(v2, v1);
+ assertEquals(v1, VersionImpl.parseVersion("1.2.3"));
+
+ VersionImpl v3 = new VersionImpl(1, 2, 3, "CR1");
+ VersionImpl v4 = new VersionImpl(1, 2, 3, "CR2");
+ assertLess(v3, v4);
+ assertGreater(v4, v3);
+ assertEquals(v3, VersionImpl.parseVersion("1.2.3.CR1"));
+
+ VersionImpl v5 = new VersionImpl(1, 2, 3);
+ VersionImpl v6 = new VersionImpl(1, 3, 0);
+ assertLess(v5, v6);
+ assertGreater(v6, v5);
+
+ VersionImpl v7 = new VersionImpl(1, 2, 3);
+ VersionImpl v8 = new VersionImpl(2, 0, 0);
+ assertLess(v7, v8);
+ assertGreater(v8, v7);
}
}
More information about the jboss-cvs-commits
mailing list