8194070: Update various tests to pass under JDK 11
authordarcy
Wed, 31 Jan 2018 11:25:34 -0800
changeset 48690 374c63fbe652
parent 48689 e704f48d8277
child 48691 554cb38e0caf
child 48829 93de07994202
8194070: Update various tests to pass under JDK 11 Reviewed-by: alanb, sherman, psandoz
test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarHttpProperties.java
test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarProperties.java
test/jdk/jdk/nio/zipfs/MultiReleaseJarTest.java
test/jdk/lib/testlibrary/java/util/jar/CreateMultiReleaseTestJars.java
test/jdk/sun/net/www/protocol/jar/MultiReleaseJarURLConnection.java
test/jdk/sun/security/tools/jarsigner/multiRelease/MVJarSigningTest.java
--- a/test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarHttpProperties.java	Wed Jan 31 10:34:59 2018 -0800
+++ b/test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarHttpProperties.java	Wed Jan 31 11:25:34 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8132734
+ * @bug 8132734 8194070
  * @summary Test the System properties for JarFile that support multi-release jar files
  * @library /lib/testlibrary/java/util/jar
  * @modules jdk.jartool
@@ -31,17 +31,14 @@
  *          jdk.httpserver
  * @build Compiler JarBuilder CreateMultiReleaseTestJars SimpleHttpServer
  * @run testng MultiReleaseJarHttpProperties
- * @run testng/othervm -Djdk.util.jar.version=0 MultiReleaseJarHttpProperties
- * @run testng/othervm -Djdk.util.jar.version=8 MultiReleaseJarHttpProperties
- * @run testng/othervm -Djdk.util.jar.version=9 MultiReleaseJarHttpProperties
- * @run testng/othervm -Djdk.util.jar.version=10 MultiReleaseJarHttpProperties
+ * @run testng/othervm -Djdk.util.jar.version=0   MultiReleaseJarHttpProperties
+ * @run testng/othervm -Djdk.util.jar.version=8   MultiReleaseJarHttpProperties
+ * @run testng/othervm -Djdk.util.jar.version=9   MultiReleaseJarHttpProperties
  * @run testng/othervm -Djdk.util.jar.version=100 MultiReleaseJarHttpProperties
- * @run testng/othervm -Djdk.util.jar.version=8 -Djdk.util.jar.enableMultiRelease=false MultiReleaseJarHttpProperties
- * @run testng/othervm -Djdk.util.jar.version=9 -Djdk.util.jar.enableMultiRelease=false MultiReleaseJarHttpProperties
- * @run testng/othervm -Djdk.util.jar.version=10 -Djdk.util.jar.enableMultiRelease=false MultiReleaseJarHttpProperties
- * @run testng/othervm -Djdk.util.jar.version=8 -Djdk.util.jar.enableMultiRelease=force MultiReleaseJarHttpProperties
- * @run testng/othervm -Djdk.util.jar.version=9 -Djdk.util.jar.enableMultiRelease=force MultiReleaseJarHttpProperties
- * @run testng/othervm -Djdk.util.jar.version=10 -Djdk.util.jar.enableMultiRelease=force MultiReleaseJarHttpProperties
+ * @run testng/othervm -Djdk.util.jar.version=8   -Djdk.util.jar.enableMultiRelease=false MultiReleaseJarHttpProperties
+ * @run testng/othervm -Djdk.util.jar.version=9   -Djdk.util.jar.enableMultiRelease=false MultiReleaseJarHttpProperties
+ * @run testng/othervm -Djdk.util.jar.version=8   -Djdk.util.jar.enableMultiRelease=force MultiReleaseJarHttpProperties
+ * @run testng/othervm -Djdk.util.jar.version=9   -Djdk.util.jar.enableMultiRelease=force MultiReleaseJarHttpProperties
  * @run testng/othervm -Djdk.util.jar.enableMultiRelease=false MultiReleaseJarHttpProperties
  * @run testng/othervm -Djdk.util.jar.enableMultiRelease=force MultiReleaseJarHttpProperties
  */
--- a/test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarProperties.java	Wed Jan 31 10:34:59 2018 -0800
+++ b/test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarProperties.java	Wed Jan 31 11:25:34 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,22 +23,19 @@
 
 /*
  * @test
- * @bug 8132734 8144062
+ * @bug 8132734 8144062 8194070
  * @summary Test the System properties for JarFile that support multi-release jar files
  * @library /lib/testlibrary/java/util/jar
  * @build Compiler JarBuilder CreateMultiReleaseTestJars
  * @run testng MultiReleaseJarProperties
- * @run testng/othervm -Djdk.util.jar.version=0 MultiReleaseJarProperties
- * @run testng/othervm -Djdk.util.jar.version=8 MultiReleaseJarProperties
- * @run testng/othervm -Djdk.util.jar.version=9 MultiReleaseJarProperties
- * @run testng/othervm -Djdk.util.jar.version=10 MultiReleaseJarProperties
+ * @run testng/othervm -Djdk.util.jar.version=0   MultiReleaseJarProperties
+ * @run testng/othervm -Djdk.util.jar.version=8   MultiReleaseJarProperties
+ * @run testng/othervm -Djdk.util.jar.version=9   MultiReleaseJarProperties
  * @run testng/othervm -Djdk.util.jar.version=100 MultiReleaseJarProperties
- * @run testng/othervm -Djdk.util.jar.version=8 -Djdk.util.jar.enableMultiRelease=false MultiReleaseJarProperties
- * @run testng/othervm -Djdk.util.jar.version=9 -Djdk.util.jar.enableMultiRelease=false MultiReleaseJarProperties
- * @run testng/othervm -Djdk.util.jar.version=10 -Djdk.util.jar.enableMultiRelease=false MultiReleaseJarProperties
- * @run testng/othervm -Djdk.util.jar.version=8 -Djdk.util.jar.enableMultiRelease=force MultiReleaseJarProperties
- * @run testng/othervm -Djdk.util.jar.version=9 -Djdk.util.jar.enableMultiRelease=force MultiReleaseJarProperties
- * @run testng/othervm -Djdk.util.jar.version=10 -Djdk.util.jar.enableMultiRelease=force MultiReleaseJarProperties
+ * @run testng/othervm -Djdk.util.jar.version=8   -Djdk.util.jar.enableMultiRelease=false MultiReleaseJarProperties
+ * @run testng/othervm -Djdk.util.jar.version=9   -Djdk.util.jar.enableMultiRelease=false MultiReleaseJarProperties
+ * @run testng/othervm -Djdk.util.jar.version=8   -Djdk.util.jar.enableMultiRelease=force MultiReleaseJarProperties
+ * @run testng/othervm -Djdk.util.jar.version=9   -Djdk.util.jar.enableMultiRelease=force MultiReleaseJarProperties
  * @run testng/othervm -Djdk.util.jar.enableMultiRelease=false MultiReleaseJarProperties
  * @run testng/othervm -Djdk.util.jar.enableMultiRelease=force MultiReleaseJarProperties
  */
--- a/test/jdk/jdk/nio/zipfs/MultiReleaseJarTest.java	Wed Jan 31 10:34:59 2018 -0800
+++ b/test/jdk/jdk/nio/zipfs/MultiReleaseJarTest.java	Wed Jan 31 11:25:34 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8144355 8144062 8176709
+ * @bug 8144355 8144062 8176709 8194070
  * @summary Test aliasing additions to ZipFileSystem for multi-release jar files
  * @library /lib/testlibrary/java/util/jar
  * @build Compiler JarBuilder CreateMultiReleaseTestJars
@@ -92,9 +92,9 @@
                 {"0", 8},
                 {"8", 8},
                 {"9", 9},
-                {"10", 10},
-                {"11", 10},
-                {"50", 10}
+                {Integer.toString(MAJOR_VERSION), MAJOR_VERSION},
+                {Integer.toString(MAJOR_VERSION+1), MAJOR_VERSION},
+                {"50", MAJOR_VERSION}
         };
     }
 
@@ -105,9 +105,9 @@
                 {new Integer(0), 8},
                 {new Integer(8), 8},
                 {new Integer(9), 9},
-                {new Integer(10), 10},
-                {new Integer(11), 10},
-                {new Integer(100), 10}
+                {new Integer(MAJOR_VERSION), MAJOR_VERSION},
+                {new Integer(MAJOR_VERSION + 1), MAJOR_VERSION},
+                {new Integer(100), MAJOR_VERSION}
         };
     }
 
@@ -116,9 +116,8 @@
         return new Object[][] {
                 {Version.parse("8"),    8},
                 {Version.parse("9"),    9},
-                {Version.parse("10"),  10},
-                {Version.parse("11"),  10},
-                {Version.parse("100"), 10}
+                {Version.parse("11"),  MAJOR_VERSION},
+                {Version.parse("100"), MAJOR_VERSION}
         };
     }
 
@@ -168,8 +167,8 @@
 
     @Test
     public void testShortJar() throws Throwable {
-        integerEnv.put("multi-release", Integer.valueOf(10));
-        runTest(smruri, integerEnv, 10);
+        integerEnv.put("multi-release", Integer.valueOf(MAJOR_VERSION));
+        runTest(smruri, integerEnv, MAJOR_VERSION);
         integerEnv.put("multi-release", Integer.valueOf(9));
         runTest(smruri, integerEnv, 8);
     }
--- a/test/jdk/lib/testlibrary/java/util/jar/CreateMultiReleaseTestJars.java	Wed Jan 31 10:34:59 2018 -0800
+++ b/test/jdk/lib/testlibrary/java/util/jar/CreateMultiReleaseTestJars.java	Wed Jan 31 11:25:34 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -69,13 +69,15 @@
             + "        return 9;\n"
             + "    }\n"
             + "}\n";
-    final private String java10 = java8.replace("8", "10");
+    final int currentVersion = Runtime.version().major();
+    final String currentVersionStr = Integer.toString(currentVersion);
+    final private String javaCurrent = java8.replace("8", currentVersionStr);
     final String readme8 = "This is the root readme file";
     final String readme9 = "This is the version nine readme file";
-    final String readme10 = "This is the version ten readme file";
+    final String readmeCurrent = "This is the current version readme file";
     private Map<String,byte[]> rootClasses;
     private Map<String,byte[]> version9Classes;
-    private Map<String,byte[]> version10Classes;
+    private Map<String,byte[]> versionCurrentClasses;
 
     public void buildUnversionedJar() throws IOException {
         JarBuilder jb = new JarBuilder("unversioned.jar");
@@ -134,9 +136,9 @@
         jb.addEntry("META-INF/versions/9/version/Version.java", java9.getBytes());
         jb.addEntry("META-INF/versions/9/version/PackagePrivate.java", ppjava9.getBytes());
         jb.addEntry("META-INF/versions/9/version/PackagePrivate.class", version9Classes.get("version.PackagePrivate"));
-        jb.addEntry("META-INF/versions/10/README", readme10.getBytes());
-        jb.addEntry("META-INF/versions/10/version/Version.java", java10.getBytes());
-        jb.addEntry("META-INF/versions/10/version/Version.class", version10Classes.get("version.Version"));
+        jb.addEntry("META-INF/versions/" + currentVersionStr + "/README", readmeCurrent.getBytes());
+        jb.addEntry("META-INF/versions/" + currentVersionStr + "/version/Version.java", javaCurrent.getBytes());
+        jb.addEntry("META-INF/versions/" + currentVersionStr + "/version/Version.class", versionCurrentClasses.get("version.Version"));
     }
 
     public void buildSignedMultiReleaseJar() throws Exception {
@@ -186,7 +188,7 @@
         input.put("version.PackagePrivate", ppjava9);
         version9Classes = (new Compiler(input)).setRelease(9).compile();
         input.clear();
-        input.put("version.Version", java10);
-        version10Classes = (new Compiler(input)).setRelease(9).compile();  // fixme in JDK 10
+        input.put("version.Version", javaCurrent);
+        versionCurrentClasses = (new Compiler(input)).compile();  // Use default release
     }
 }
--- a/test/jdk/sun/net/www/protocol/jar/MultiReleaseJarURLConnection.java	Wed Jan 31 10:34:59 2018 -0800
+++ b/test/jdk/sun/net/www/protocol/jar/MultiReleaseJarURLConnection.java	Wed Jan 31 11:25:34 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8132734 8144062 8159785
+ * @bug 8132734 8144062 8159785 8194070
  * @summary Test that URL connections to multi-release jars can be runtime versioned
  * @library /lib/testlibrary/java/util/jar
  * @modules jdk.compiler
@@ -108,7 +108,8 @@
         Assert.assertTrue(readAndCompare(new URL(baseUrlEntry), "return 8"));
 
         // the following tests will not work with unversioned jars
-        if (style.equals("unversioned")) return;
+        if (style.equals("unversioned"))
+            return;
 
         // direct access to versioned entry
         String versUrlEntry = urlFile + "META-INF/versions/" + Runtime.version().major()
@@ -117,12 +118,6 @@
         // adding any fragment does not change things
         Assert.assertTrue(readAndCompare(new URL(versUrlEntry + "#runtime"), rtreturn));
         Assert.assertTrue(readAndCompare(new URL(versUrlEntry + "#fragment"), rtreturn));
-
-        // it really doesn't change things
-        versUrlEntry = urlFile + "META-INF/versions/10/version/Version.java";
-        Assert.assertTrue(readAndCompare(new URL(versUrlEntry), "return 10"));
-        Assert.assertTrue(readAndCompare(new URL(versUrlEntry + "#runtime"), "return 10"));
-        Assert.assertTrue(readAndCompare(new URL(versUrlEntry + "#fragment"), "return 10"));
     }
 
     @Test(dataProvider = "data")
@@ -225,7 +220,6 @@
         cldr.close();
     }
 
-
     private boolean readAndCompare(URL url, String match) throws Exception {
         boolean result;
         // necessary to do it this way, instead of openStream(), so we can
--- a/test/jdk/sun/security/tools/jarsigner/multiRelease/MVJarSigningTest.java	Wed Jan 31 10:34:59 2018 -0800
+++ b/test/jdk/sun/security/tools/jarsigner/multiRelease/MVJarSigningTest.java	Wed Jan 31 11:25:34 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -81,7 +81,7 @@
     private static final String KEYPASS = "changeit";
     private static final String SIGNED_JAR = "Signed.jar";
     private static final String POLICY_FILE = "SignedJar.policy";
-    private static final String VERSION = "" + Runtime.version().major();
+    private static final String VERSION = Integer.toString(10);
     private static final String VERSION_MESSAGE = "I am running on version " + VERSION;
 
     public static void main(String[] args) throws Throwable {