6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 8141609
27 * @summary Verify JDK 8 can use jrt-fs.jar to work with jrt file system.
28 * @run main RemoteRuntimeImageTest
29 */
30
31 import java.io.File;
32 import java.io.FileInputStream;
33 import java.io.FileNotFoundException;
34 import java.io.IOException;
35 import java.nio.file.FileSystems;
36 import java.nio.file.Files;
37 import java.nio.file.Path;
38 import java.nio.file.Paths;
39 import java.util.Arrays;
40 import java.util.List;
41 import java.util.Properties;
42 public class RemoteRuntimeImageTest {
43 //the jrt-fs.jar shipped together with jdk
44 private static final String JRTFS_JAR = "jrt-fs.jar";
45 private static final String SRC_DIR = System.getProperty("test.src");
46 private static final String CLASSES_DIR = "classes";
47 private static final String TEST_JAVAHOME = System.getProperty("test.jdk");
48
49 public static void main(String[] args) throws Exception {
50 // By default, set to ${JT_JAVA}
51 String jdk8Home = System.getenv("JDK8_HOME");
52 if (jdk8Home == null || jdk8Home.isEmpty()) {
53 System.err.println("Failed to locate JDK8 with system "
54 + "environment variable 'JDK8_HOME'. Skip testing!");
55 return;
56 }
57
58 Path jdk8Path = getJdk8Path(jdk8Home);
59 if (!isJdk8(jdk8Path)) {
60 System.err.println("This test is only for JDK 8. Skip testing");
61 return;
62 }
63
64 String java = jdk8Path.resolve("bin/java").toAbsolutePath().toString();
65 String javac = jdk8Path.resolve("bin/javac").toAbsolutePath().toString();
66
67 Files.createDirectories(Paths.get(".", CLASSES_DIR));
68 String jrtJar = Paths.get(TEST_JAVAHOME, JRTFS_JAR).toAbsolutePath().toString();
69
70 // Compose command-lines for compiling and executing tests
71 List<List<String>> cmds = Arrays.asList(
72 // Commands to compile test classes
73 Arrays.asList(javac, "-d", CLASSES_DIR, "-cp", jrtJar,
74 SRC_DIR + File.separatorChar + "Main.java"),
75 // Run test
76 Arrays.asList(java, "-cp", CLASSES_DIR, "Main", TEST_JAVAHOME),
77 // Run test with jrtfs.jar in class path,
78 // which means to install jrt FileSystem provider
79 Arrays.asList(java, "-cp", CLASSES_DIR + File.pathSeparatorChar + jrtJar,
80 "Main", TEST_JAVAHOME, "installed")
81 );
82
83 cmds.forEach(cmd -> execCmd(cmd));
84 }
85
86 private static void execCmd(List<String> command){
|
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 8141609 8154403
27 * @summary Verify JDK 8 can use jrt-fs.jar to work with jrt file system.
28 * @run main RemoteRuntimeImageTest
29 */
30
31 import java.io.File;
32 import java.io.FileInputStream;
33 import java.io.FileNotFoundException;
34 import java.io.IOException;
35 import java.nio.file.FileSystems;
36 import java.nio.file.Files;
37 import java.nio.file.Path;
38 import java.nio.file.Paths;
39 import java.util.Arrays;
40 import java.util.List;
41 import java.util.Properties;
42 public class RemoteRuntimeImageTest {
43 //the jrt-fs.jar shipped together with jdk
44 private static final String JRTFS_JAR = "jrt-fs.jar";
45 private static final String SRC_DIR = System.getProperty("test.src");
46 private static final String CLASSES_DIR = "classes";
47 private static final String TEST_JAVAHOME = System.getProperty("test.jdk");
48
49 public static void main(String[] args) throws Exception {
50 // By default, set to ${JT_JAVA}
51 String jdk8Home = System.getenv("JDK8_HOME");
52 if (jdk8Home == null || jdk8Home.isEmpty()) {
53 System.err.println("Failed to locate JDK8 with system "
54 + "environment variable 'JDK8_HOME'. Skip testing!");
55 return;
56 }
57
58 Path jdk8Path = getJdk8Path(jdk8Home);
59 if (!isJdk8(jdk8Path)) {
60 System.err.println("This test is only for JDK 8. Skip testing");
61 return;
62 }
63
64 String java = jdk8Path.resolve("bin/java").toAbsolutePath().toString();
65 String javac = jdk8Path.resolve("bin/javac").toAbsolutePath().toString();
66 Files.createDirectories(Paths.get(".", CLASSES_DIR));
67 String jrtJar = Paths.get(TEST_JAVAHOME, JRTFS_JAR).toAbsolutePath().toString();
68
69 // Compose command-lines for compiling and executing tests
70 List<List<String>> cmds = Arrays.asList(
71 // Commands to compile test classes
72 Arrays.asList(javac, "-d", CLASSES_DIR, "-cp", jrtJar,
73 SRC_DIR + File.separatorChar + "Main.java"),
74 // Run test
75 Arrays.asList(java, "-cp", CLASSES_DIR, "Main", TEST_JAVAHOME),
76 // Run test with jrtfs.jar in class path,
77 // which means to install jrt FileSystem provider
78 Arrays.asList(java, "-cp", CLASSES_DIR + File.pathSeparatorChar + jrtJar,
79 "Main", TEST_JAVAHOME, "installed")
80 );
81
82 cmds.forEach(cmd -> execCmd(cmd));
83 }
84
85 private static void execCmd(List<String> command){
|