VersionInfo { public static boolean isCompatible(String thisVersion, String requiredVersion) { String[] thisVersionComponent = normalizeVersion(thisVersion).split("\\."); String[] requiredVersionComponent = normalizeVersion(requiredVersion).split("\\."); if (!thisVersionComponent[0].equals(requiredVersionComponent[0])) { return false; } if (Integer.parseInt(thisVersionComponent[1]) < Integer.parseInt(requiredVersionComponent[1])) { return false; } return true; } VersionInfo(Class<?> classInJar, String groupId, String artifactId, String gitPropertiesResource); String getVersion(); String getDate(); String getUser(); String getRevision(); String getBuildVersion(); static int compare(String str1, String str2); static boolean isCompatible(String thisVersion, String requiredVersion); @SuppressWarnings("UseOfSystemOutOrSystemErr") static void main(String[] args); static final VersionInfo APEX_VERSION; }
@Test public void testCompatibleVersion() { Assert.assertFalse(VersionInfo.isCompatible("1.0", "1.1")); Assert.assertTrue(VersionInfo.isCompatible("1.10", "1.2")); Assert.assertTrue(VersionInfo.isCompatible("1.10.0", "1.10.34")); Assert.assertTrue(VersionInfo.isCompatible("1.10.55", "1.10.3")); Assert.assertTrue(VersionInfo.isCompatible("1.10.55", "1.10.55")); Assert.assertFalse(VersionInfo.isCompatible("1.10.55", "2.10.55")); Assert.assertFalse(VersionInfo.isCompatible("2.10.55", "1.10.55")); }