JavaVersionParser { public static JavaVersion getCurrentJavaVersion() { return currentJavaVersion; } private  JavaVersionParser(); static JavaVersion getCurrentJavaVersion(); static JavaVersion parseJavaVersion(final String fullVersionString); static final String JAVA_VERSION_PROPERTY; }
@Test public void getCurrentVersion_VersionIsCachedInMemory() { System.setProperty(JAVA_VERSION_PROPERTY, "1.6.0_40"); JavaVersion currentVersion = JavaVersionParser.getCurrentJavaVersion(); System.setProperty(JAVA_VERSION_PROPERTY, "1.7.1_80"); JavaVersion versionAfterChangingProperty = JavaVersionParser.getCurrentJavaVersion(); assertEquals(currentVersion, versionAfterChangingProperty); }