VersionChecker { public int compareVersions() throws IOException { final String remoteVersion = getRemoteVersion(); if (localVersionStr == null) { localVersionStr = getLocalVersion(); } return compareVersions(localVersionStr, remoteVersion); } VersionChecker();  VersionChecker(File localVersionFile, String remoteVersionUrlString); String getRemoteVersionUrlString(); void setRemoteVersionUrlString(String remoteVersionUrlString); File getLocalVersionFile(); void setLocalVersionFile(File localVersionFile); void setLocalVersion(final String ver); int compareVersions(); String getLocalVersion(); String getRemoteVersion();  }
@Test public void testCompare() { assertTrue(VersionChecker.compareVersions("VERSION 4.7", "VERSION 4.7") == 0); assertTrue(VersionChecker.compareVersions("VERSION 4.7", "VERSION 3.7") > 0); assertTrue(VersionChecker.compareVersions("VERSION 4.7", "VERSION 4.7-SNAPSHOT") > 0); assertTrue(VersionChecker.compareVersions("VERSION 4.2.0", "VERSION 4.2") == 0); assertTrue(VersionChecker.compareVersions("VERSION 4.2", "VERSION 4.2.0") == 0); assertTrue(VersionChecker.compareVersions("VERSION 4.6.999", "VERSION 4.7") < 0); assertTrue(VersionChecker.compareVersions("VERSION 4.7", "VERSION 4.7-RC1") > 0); assertTrue(VersionChecker.compareVersions("VERSION 4.7-RC1", "VERSION 4.7") < 0); assertTrue(VersionChecker.compareVersions("VERSION 4.7-RC1", "VERSION 4.7-RC2") < 0); assertTrue(VersionChecker.compareVersions("VERSION 4.7.1", "VERSION 4.7-RC2") > 0); assertTrue(VersionChecker.compareVersions("VERSION 4.7.2", "VERSION 4.7-RC1") > 0); assertTrue(VersionChecker.compareVersions("VERSION 4.9.1", "VERSION 4.9.0") > 0); assertTrue(VersionChecker.compareVersions("VERSION 4.9.0.1", "VERSION 4.9.0") > 0); assertTrue(VersionChecker.compareVersions("VERSION 4.9.0.1", "VERSION 4.9") > 0); assertTrue(VersionChecker.compareVersions("VERSION 4.9.0.1", "VERSION 4.9.1") < 0); }