JBoss Cache SVN: r7973 - core/branches/1.4.X/tests/functional/org/jboss/cache.
by jbosscache-commits@lists.jboss.org
Author: jiwils
Date: 2009-04-02 11:42:33 -0400 (Thu, 02 Apr 2009)
New Revision: 7973
Modified:
core/branches/1.4.X/tests/functional/org/jboss/cache/VersionConversionTest.java
Log:
Fixed VersionConversionTest to ignore -SNAPSHOT at the end of release version information.
Modified: core/branches/1.4.X/tests/functional/org/jboss/cache/VersionConversionTest.java
===================================================================
--- core/branches/1.4.X/tests/functional/org/jboss/cache/VersionConversionTest.java 2009-04-02 14:03:46 UTC (rev 7972)
+++ core/branches/1.4.X/tests/functional/org/jboss/cache/VersionConversionTest.java 2009-04-02 15:42:33 UTC (rev 7973)
@@ -9,24 +9,24 @@
{
super(name);
}
-
+
public void testStringToShort()
{
- try
+ try
{
Version.getVersionShort("1.2.4SP1");
fail("Correctly did not accept versionString '1.2.4SP1'");
}
catch (IllegalArgumentException ok) {}
-
- try
+
+ try
{
Version.getVersionShort("1.2.4 SP1");
fail("Correctly did not accept versionString '1.2.4 SP1'");
}
catch (IllegalArgumentException ok) {}
-
- try
+
+ try
{
Version.getVersionShort("1.3.alpha");
fail("Correctly did not accept versionString '1.3.alpha'");
@@ -41,29 +41,29 @@
assertEquals("1.1 correct", (short) (Math.pow(2,11) + Math.pow(2,6)), Version.getVersionShort("1.1"));
assertEquals("1.1.1 correct", (short) (Math.pow(2,11) + Math.pow(2,6)) + 1, Version.getVersionShort("1.1.1"));
assertEquals("2.0 correct", (short) Math.pow(2,12), Version.getVersionShort("2.0"));
-
+
// Ignore final qualifiers
assertEquals("1.3.0.alpha correct", (short) (Math.pow(2,11) + Math.pow(2,7) + Math.pow(2,6)), Version.getVersionShort("1.3.0.alpha"));
assertEquals("1.3.0.RC1 correct", (short) (Math.pow(2,11) + Math.pow(2,7) + Math.pow(2,6)), Version.getVersionShort("1.3.0.RC1"));
assertEquals("1.3.0.SP1 correct", (short) (Math.pow(2,11) + Math.pow(2,7) + Math.pow(2,6)), Version.getVersionShort("1.3.0.SP1"));
-
+
// Special cases
assertEquals("1.2.4.SP2 correct", (short) 124, Version.getVersionShort("1.2.4"));
assertEquals("1.2.4.SP2 correct", (short) 1241, Version.getVersionShort("1.2.4.SP1"));
assertEquals("1.2.4.SP2 correct", (short) (Math.pow(2,11) + Math.pow(2,7)) + 4, Version.getVersionShort("1.2.4.SP2"));
}
-
+
public void testShortToString()
{
assertEquals("0.0.1 correct", "0.0.1", Version.getVersionString(Version.getVersionShort("0.0.1")));
assertEquals("1.3.0 correct", "1.3.0", Version.getVersionString(Version.getVersionShort("1.3.0")));
-
+
// Special cases
assertEquals("1.2.4 correct", "1.2.4", Version.getVersionString((short) 124));
assertEquals("1.2.4.SP1 correct", "1.2.4.SP1", Version.getVersionString((short) 1241));
assertEquals("1.2.4.SP2 correct", "1.2.4.SP2", Version.getVersionString(Version.getVersionShort("1.2.4.SP2")));
}
-
+
public void testDefault()
{
short defaultShort = Version.getVersionShort();
@@ -72,18 +72,24 @@
String versionToCompareAgainst = Version.version;
String lastElement = versionToCompareAgainst.substring(versionToCompareAgainst.lastIndexOf('.')+1).toUpperCase();
- if (lastElement.startsWith("GA")
- || lastElement.startsWith("CR")
- || lastElement.startsWith("RC")
- || lastElement.startsWith("DR")
- || lastElement.startsWith("ALPHA")
- || lastElement.startsWith("BETA")
+ if (lastElement.startsWith("GA")
+ || lastElement.startsWith("CR")
+ || lastElement.startsWith("RC")
+ || lastElement.startsWith("DR")
+ || lastElement.startsWith("ALPHA")
+ || lastElement.startsWith("BETA")
|| lastElement.startsWith("SP"))
{
// strip the last element
versionToCompareAgainst = versionToCompareAgainst.substring(0, versionToCompareAgainst.lastIndexOf('.'));
}
+ if (lastElement.endsWith("-SNAPSHOT"))
+ {
+ // strip off -SNAPSHOT
+ versionToCompareAgainst = versionToCompareAgainst.substring(0, versionToCompareAgainst.lastIndexOf("-SNAPSHOT"));
+ }
+
assertEquals("Round-trip conversion consistent", versionToCompareAgainst, versionString);
}
}