Author: rwhitcomb Date: Mon Aug 6 16:30:29 2018 New Revision: 1837541 URL: http://svn.apache.org/viewvc?rev=1837541&view=rev Log: PIVOT-1039: Address test failure with Java 10: * Update Version to have a new "simpleToString" method that formats just the "major.minor.maint" value. * Use that to do the comparison because the full formatted string from Version.toString() doesn't match the new version format from the Oracle JVM.
Modified: pivot/trunk/core/src/org/apache/pivot/util/Version.java pivot/trunk/core/test/org/apache/pivot/util/test/VersionTest.java Modified: pivot/trunk/core/src/org/apache/pivot/util/Version.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/util/Version.java?rev=1837541&r1=1837540&r2=1837541&view=diff ============================================================================== --- pivot/trunk/core/src/org/apache/pivot/util/Version.java (original) +++ pivot/trunk/core/src/org/apache/pivot/util/Version.java Mon Aug 6 16:30:29 2018 @@ -103,6 +103,16 @@ public class Version implements Comparab return string; } + /** + * @return A three-component string with "major.minor.maintenance". + */ + public String simpleToString() { + return String.format("%1$d.%2$d.%3$d", + this.majorRevision, + this.minorRevision, + this.maintenanceRevision); + } + public static Version decode(String string) { Version version = null; Modified: pivot/trunk/core/test/org/apache/pivot/util/test/VersionTest.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/test/org/apache/pivot/util/test/VersionTest.java?rev=1837541&r1=1837540&r2=1837541&view=diff ============================================================================== --- pivot/trunk/core/test/org/apache/pivot/util/test/VersionTest.java (original) +++ pivot/trunk/core/test/org/apache/pivot/util/test/VersionTest.java Mon Aug 6 16:30:29 2018 @@ -18,6 +18,8 @@ package org.apache.pivot.util.test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import java.util.regex.*; import org.junit.Test; @@ -114,12 +116,16 @@ public class VersionTest { parsedToString, PIVOT_996_OUTPUT); assertEquals("PIVOT-996 toString", parsedToString, PIVOT_996_OUTPUT); + Pattern versionPattern = Pattern.compile("(\\d+\\.\\d+\\.\\d+).*"); String sysJavaVersion = System.getProperty("java.runtime.version"); Version javaVersion = Version.decode(sysJavaVersion); String formattedJavaVersion = javaVersion.toString(); System.out.format("Java Runtime version (parsed and formatted): %1$s, raw: %2$s%n", formattedJavaVersion, sysJavaVersion); - assertEquals("Java Runtime version", sysJavaVersion, formattedJavaVersion); + Matcher sysMatcher = versionPattern.matcher(sysJavaVersion); + boolean matches = sysMatcher.matches() + && sysMatcher.group(1).equals(javaVersion.simpleToString()); + assertTrue("Java Runtime version match", matches); String newJava9Version = "9-ea+19"; Version newJava9 = Version.decode(newJava9Version);