String version9="a.b.c";
String version10=null;
String version11="";
String version12="\"[1.2.3, 4.5.6]\"";
VersionRange vr = ManifestHeaderProcessor.parseVersionRange(version1);
assertEquals("The value is wrong", "1.2.3", vr.getMinimumVersion().toString());
assertFalse("The value is wrong", vr.isMinimumExclusive());
assertEquals("The value is wrong", "4.5.6", vr.getMaximumVersion().toString());
assertFalse("The value is wrong", vr.isMaximumExclusive());
vr = ManifestHeaderProcessor.parseVersionRange(version2);
assertEquals("The value is wrong", "1.0.0", vr.getMinimumVersion().toString());
assertTrue("The value is wrong", vr.isMinimumExclusive());
assertEquals("The value is wrong", "2.0.0", vr.getMaximumVersion().toString());
assertFalse("The value is wrong", vr.isMaximumExclusive());
vr = ManifestHeaderProcessor.parseVersionRange(version3);
assertEquals("The value is wrong", "2.0.0", vr.getMinimumVersion().toString());
assertFalse("The value is wrong", vr.isMinimumExclusive());
assertEquals("The value is wrong", "4.0.0", vr.getMaximumVersion().toString());
assertTrue("The value is wrong", vr.isMaximumExclusive());
vr = ManifestHeaderProcessor.parseVersionRange(version4);
assertEquals("The value is wrong", "1.0.0", vr.getMinimumVersion().toString());
assertTrue("The value is wrong", vr.isMinimumExclusive());
assertEquals("The value is wrong", "2.0.0", vr.getMaximumVersion().toString());
assertTrue("The value is wrong", vr.isMaximumExclusive());
vr = ManifestHeaderProcessor.parseVersionRange(version5);
assertEquals("The value is wrong", "2.0.0", vr.getMinimumVersion().toString());
assertFalse("The value is wrong", vr.isMinimumExclusive());
assertNull("The value is wrong", vr.getMaximumVersion());
assertFalse("The value is wrong", vr.isMaximumExclusive());
vr = ManifestHeaderProcessor.parseVersionRange(version6);
assertEquals("The value is wrong", "2.3.0", vr.getMinimumVersion().toString());
assertFalse("The value is wrong", vr.isMinimumExclusive());
assertNull("The value is wrong", vr.getMaximumVersion());
assertFalse("The value is wrong", vr.isMaximumExclusive());
vr = ManifestHeaderProcessor.parseVersionRange(version7);
assertEquals("The value is wrong", "1.2.3.q", vr.getMinimumVersion().toString());
assertFalse("The value is wrong", vr.isMinimumExclusive());
assertEquals("The value is wrong", "2.3.4.p", vr.getMaximumVersion().toString());
assertTrue("The value is wrong", vr.isMaximumExclusive());
vr = ManifestHeaderProcessor.parseVersionRange(version8);
assertEquals("The value is wrong", "1.2.2.5", vr.getMinimumVersion().toString());
assertFalse("The value is wrong", vr.isMinimumExclusive());
assertNull("The value is wrong", vr.getMaximumVersion());
assertFalse("The value is wrong", vr.isMaximumExclusive());
boolean exception = false;
try {
vr = ManifestHeaderProcessor.parseVersionRange(version9);
} catch (Exception e){
exception = true;
}
assertTrue("The value is wrong", exception);
boolean exceptionNull = false;
try {
vr = ManifestHeaderProcessor.parseVersionRange(version10);
} catch (Exception e){
exceptionNull = true;
}
assertTrue("The value is wrong", exceptionNull);
// empty version should be defaulted to >=0.0.0
vr = ManifestHeaderProcessor.parseVersionRange(version11);
assertEquals("The value is wrong", "0.0.0", vr.getMinimumVersion().toString());
assertFalse("The value is wrong", vr.isMinimumExclusive());
assertNull("The value is wrong", vr.getMaximumVersion());
assertFalse("The value is wrong", vr.isMaximumExclusive());
vr = ManifestHeaderProcessor.parseVersionRange(version12);
assertEquals("The value is wrong", "1.2.3", vr.getMinimumVersion().toString());
assertFalse("The value is wrong", vr.isMinimumExclusive());
assertEquals("The value is wrong", "4.5.6", vr.getMaximumVersion().toString());
assertFalse("The value is wrong", vr.isMaximumExclusive());
}