changeset 14312:bb94cd0c9910

Move tests for Class getResource to java/lang/Class
author alanb
date Sat, 07 Nov 2015 17:41:27 +0000
parents 1c37b2067e4d
children 3f859f4a29bf
files test/java/lang/Class/getResource/Main.java test/java/lang/Class/getResource/ResourcesTest.java test/java/lang/Class/getResource/src/m1/module-info.java test/java/lang/Class/getResource/src/m1/p1/Main.java test/java/lang/Class/getResource/src/m2/module-info.java test/java/lang/Class/getResource/src/m2/p2/Main.java test/java/lang/Class/getResource/src/m3/module-info.java test/java/lang/Class/getResource/src/m3/p3/Main.java test/jdk/jigsaw/etc/resources/Main.java test/jdk/jigsaw/etc/resources/ResourcesTest.java test/jdk/jigsaw/etc/resources/src/m1/module-info.java test/jdk/jigsaw/etc/resources/src/m1/p1/Main.java test/jdk/jigsaw/etc/resources/src/m2/module-info.java test/jdk/jigsaw/etc/resources/src/m2/p2/Main.java test/jdk/jigsaw/etc/resources/src/m3/module-info.java test/jdk/jigsaw/etc/resources/src/m3/p3/Main.java
diffstat 16 files changed, 456 insertions(+), 456 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Class/getResource/Main.java	Sat Nov 07 17:41:27 2015 +0000
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 2015, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.lang.module.Configuration;
+import java.lang.module.ModuleReference;
+import java.lang.reflect.Layer;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+/**
+ * Basic test of Class getResource and getResourceAsStream when invoked from
+ * code in named modules.
+ */
+
+public class Main {
+
+    static final String NAME = "myresource";
+
+    public static void main(String[] args) throws IOException {
+
+        // create m1/myresource containing "m1"
+        Path file = directoryFor("m1").resolve(NAME);
+        Files.write(file, "m1".getBytes("UTF-8"));
+
+        // create m2/myresource containing "m2"
+        file = directoryFor("m2").resolve(NAME);
+        Files.write(file, "m2".getBytes("UTF-8"));
+
+        // check that m3/myresource does not exist
+        assertTrue(Files.notExists(directoryFor("m3").resolve(NAME)));
+
+        // invoke Class getResource from the unnamed module
+        URL url0 = Main.class.getResource("/" + NAME);
+        assertNull(url0);
+
+        // invoke Class getResource from modules m1-m3
+        URL url1 = p1.Main.getResource("/" + NAME);
+        URL url2 = p2.Main.getResource("/" + NAME);
+        URL url3 = p3.Main.getResource("/" + NAME);
+        assertNotNull(url1);
+        assertNotNull(url2);
+        assertNull(url3);
+
+        // check contents of resurces at url1 and url2
+        assertEquals(new String(readAll(url1), "UTF-8"), "m1");
+        assertEquals(new String(readAll(url2), "UTF-8"), "m2");
+
+        // invoke Class getResourceAsStream from the unnamed module
+        InputStream in0 = Main.class.getResourceAsStream("/" + NAME);
+        assertNull(in0);
+
+        // invoke Class getResourceAsStream from modules m1-m3
+        try (InputStream in = p1.Main.getResourceAsStream("/" + NAME)) {
+            String s = new String(in.readAllBytes(), "UTF-8");
+            assertEquals(s, "m1");
+        }
+        try (InputStream in = p2.Main.getResourceAsStream("/" + NAME)) {
+            String s = new String(in.readAllBytes(), "UTF-8");
+            assertEquals(s, "m2");
+        }
+        InputStream in3 = p3.Main.getResourceAsStream("/" + NAME);
+        assertNull(in3);
+
+        // invoke Module getResources on modules m1-m3
+        InputStream in1 = p1.Main.class.getModule().getResourceAsStream("/" + NAME);
+        InputStream in2 = p2.Main.class.getModule().getResourceAsStream("/" + NAME);
+        in3 = p3.Main.class.getModule().getResourceAsStream("/" + NAME);
+        assertNotNull(in1);
+        assertNotNull(in2);
+        assertNull(in3);
+
+        // check the content of in1 and in2
+        String s1 = new String(in1.readAllBytes(), "UTF-8");
+        String s2 = new String(in2.readAllBytes(), "UTF-8");
+        assertEquals(s1, "m1");
+        assertEquals(s2, "m2");
+
+        // SecurityManager case
+        System.setSecurityManager(new SecurityManager());
+
+        assertNull(Main.class.getResource("/" + NAME));
+        assertNull(p1.Main.getResource("/" + NAME));
+        assertNull(p2.Main.getResource("/" + NAME));
+        assertNull(p3.Main.getResource("/" + NAME));
+
+        assertNull(Main.class.getResourceAsStream("/" + NAME));
+        assertNull(p1.Main.getResourceAsStream("/" + NAME));
+        assertNull(p2.Main.getResourceAsStream("/" + NAME));
+        assertNull(p3.Main.getResourceAsStream("/" + NAME));
+
+        System.out.println("Success!");
+    }
+
+    /**
+     * Returns the directory for the given module (by name).
+     */
+    static Path directoryFor(String name) {
+        Configuration cf = Layer.boot().configuration().get();
+        ModuleReference mref = cf.findModule(name).orElse(null);
+        if (mref == null)
+            throw new RuntimeException("not found: " + name);
+        Path dir = Paths.get(mref.location().get());
+        if (!Files.isDirectory(dir))
+            throw new RuntimeException("not a directory: " + dir);
+        return dir;
+    }
+
+    static byte[] readAll(URL url) throws IOException {
+        try (InputStream in = url.openStream()) {
+            return in.readAllBytes();
+        }
+    }
+
+    static void assertTrue(boolean condition) {
+        if (!condition) throw new RuntimeException();
+    }
+
+    static void assertNull(Object o) {
+        assertTrue(o == null);
+    }
+
+    static void assertNotNull(Object o) {
+        assertTrue(o != null);
+    }
+
+    static void assertEquals(Object actual, Object expected) {
+        if (expected == null) {
+            assertNull(actual);
+        } else {
+            assertTrue(expected.equals(actual));
+        }
+    }
+
+    static void assertNotEquals(Object actual, Object expected) {
+        if (expected == null) {
+            assertNotNull(actual);
+        } else {
+            assertTrue(!expected.equals(actual));
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Class/getResource/ResourcesTest.java	Sat Nov 07 17:41:27 2015 +0000
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2015, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import static jdk.testlibrary.ProcessTools.executeTestJava;
+
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+/**
+ * @test
+ * @library /jdk/jigsaw/lib /lib/testlibrary
+ * @modules jdk.compiler
+ * @build ResourcesTest CompilerUtils jdk.testlibrary.*
+ * @run testng ResourcesTest
+ * @summary Driver for basic test of Class getResource and getResourceAsStream
+ */
+
+@Test
+public class ResourcesTest {
+
+    private static final String TEST_SRC = System.getProperty("test.src");
+
+    private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
+    private static final Path CLASSES_DIR = Paths.get("classes");
+    private static final Path MODS_DIR = Paths.get("mods");
+
+
+    /**
+     * Compiles the modules used by the test and the test Main
+     */
+    @BeforeTest
+    public void compileAll() throws Exception {
+        boolean compiled;
+
+        // javac -modulesource mods -d mods src/**
+        compiled = CompilerUtils
+            .compile(SRC_DIR,
+                     MODS_DIR,
+                     "-modulesourcepath", SRC_DIR.toString());
+        assertTrue(compiled);
+
+        // javac -mp mods -d classes Main.java
+        compiled = CompilerUtils
+            .compile(Paths.get(TEST_SRC, "Main.java"),
+                     CLASSES_DIR,
+                     "-mp", MODS_DIR.toString());
+        assertTrue(compiled);
+
+    }
+
+    /**
+     * Run the test
+     */
+    public void runTest() throws Exception {
+
+        int exitValue
+            = executeTestJava("-mp", MODS_DIR.toString(),
+                              "-addmods", "m1,m2,m3",
+                               "-cp", CLASSES_DIR.toString(),
+                              "Main")
+                .outputTo(System.out)
+                .errorTo(System.out)
+                .getExitValue();
+
+        assertTrue(exitValue == 0);
+
+    }
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Class/getResource/src/m1/module-info.java	Sat Nov 07 17:41:27 2015 +0000
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2015, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module m1 {
+    exports p1;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Class/getResource/src/m1/p1/Main.java	Sat Nov 07 17:41:27 2015 +0000
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2015, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p1;
+
+import java.io.InputStream;
+import java.net.URL;
+
+public class Main {
+    private Main() { }
+
+    public static URL getResource(String name) {
+        return Main.class.getResource(name);
+    }
+
+    public static InputStream getResourceAsStream(String name) {
+        return Main.class.getResourceAsStream(name);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Class/getResource/src/m2/module-info.java	Sat Nov 07 17:41:27 2015 +0000
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2015, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module m2 {
+    exports p2;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Class/getResource/src/m2/p2/Main.java	Sat Nov 07 17:41:27 2015 +0000
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2015, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p2;
+
+import java.io.InputStream;
+import java.net.URL;
+
+public class Main {
+    private Main() { }
+
+    public static URL getResource(String name) {
+        return Main.class.getResource(name);
+    }
+
+    public static InputStream getResourceAsStream(String name) {
+        return Main.class.getResourceAsStream(name);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Class/getResource/src/m3/module-info.java	Sat Nov 07 17:41:27 2015 +0000
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2015, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module m3 {
+    exports p3;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Class/getResource/src/m3/p3/Main.java	Sat Nov 07 17:41:27 2015 +0000
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2015, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p3;
+
+import java.io.InputStream;
+import java.net.URL;
+
+public class Main {
+    private Main() { }
+
+    public static URL getResource(String name) {
+        return Main.class.getResource(name);
+    }
+
+    public static InputStream getResourceAsStream(String name) {
+        return Main.class.getResourceAsStream(name);
+    }
+}
--- a/test/jdk/jigsaw/etc/resources/Main.java	Sat Nov 07 16:48:06 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,167 +0,0 @@
-/*
- * Copyright (c) 2015, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.lang.module.Configuration;
-import java.lang.module.ModuleReference;
-import java.lang.reflect.Layer;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
-/**
- * Basic test of Class getResource and getResourceAsStream when invoked from
- * code in named modules.
- */
-
-public class Main {
-
-    static final String NAME = "myresource";
-
-    public static void main(String[] args) throws IOException {
-
-        // create m1/myresource containing "m1"
-        Path file = directoryFor("m1").resolve(NAME);
-        Files.write(file, "m1".getBytes("UTF-8"));
-
-        // create m2/myresource containing "m2"
-        file = directoryFor("m2").resolve(NAME);
-        Files.write(file, "m2".getBytes("UTF-8"));
-
-        // check that m3/myresource does not exist
-        assertTrue(Files.notExists(directoryFor("m3").resolve(NAME)));
-
-        // invoke Class getResource from the unnamed module
-        URL url0 = Main.class.getResource("/" + NAME);
-        assertNull(url0);
-
-        // invoke Class getResource from modules m1-m3
-        URL url1 = p1.Main.getResource("/" + NAME);
-        URL url2 = p2.Main.getResource("/" + NAME);
-        URL url3 = p3.Main.getResource("/" + NAME);
-        assertNotNull(url1);
-        assertNotNull(url2);
-        assertNull(url3);
-
-        // check contents of resurces at url1 and url2
-        assertEquals(new String(readAll(url1), "UTF-8"), "m1");
-        assertEquals(new String(readAll(url2), "UTF-8"), "m2");
-
-        // invoke Class getResourceAsStream from the unnamed module
-        InputStream in0 = Main.class.getResourceAsStream("/" + NAME);
-        assertNull(in0);
-
-        // invoke Class getResourceAsStream from modules m1-m3
-        try (InputStream in = p1.Main.getResourceAsStream("/" + NAME)) {
-            String s = new String(in.readAllBytes(), "UTF-8");
-            assertEquals(s, "m1");
-        }
-        try (InputStream in = p2.Main.getResourceAsStream("/" + NAME)) {
-            String s = new String(in.readAllBytes(), "UTF-8");
-            assertEquals(s, "m2");
-        }
-        InputStream in3 = p3.Main.getResourceAsStream("/" + NAME);
-        assertNull(in3);
-
-        // invoke Module getResources on modules m1-m3
-        InputStream in1 = p1.Main.class.getModule().getResourceAsStream("/" + NAME);
-        InputStream in2 = p2.Main.class.getModule().getResourceAsStream("/" + NAME);
-        in3 = p3.Main.class.getModule().getResourceAsStream("/" + NAME);
-        assertNotNull(in1);
-        assertNotNull(in2);
-        assertNull(in3);
-
-        // check the content of in1 and in2
-        String s1 = new String(in1.readAllBytes(), "UTF-8");
-        String s2 = new String(in2.readAllBytes(), "UTF-8");
-        assertEquals(s1, "m1");
-        assertEquals(s2, "m2");
-
-        // SecurityManager case
-        System.setSecurityManager(new SecurityManager());
-
-        assertNull(Main.class.getResource("/" + NAME));
-        assertNull(p1.Main.getResource("/" + NAME));
-        assertNull(p2.Main.getResource("/" + NAME));
-        assertNull(p3.Main.getResource("/" + NAME));
-
-        assertNull(Main.class.getResourceAsStream("/" + NAME));
-        assertNull(p1.Main.getResourceAsStream("/" + NAME));
-        assertNull(p2.Main.getResourceAsStream("/" + NAME));
-        assertNull(p3.Main.getResourceAsStream("/" + NAME));
-
-        System.out.println("Success!");
-    }
-
-    /**
-     * Returns the directory for the given module (by name).
-     */
-    static Path directoryFor(String name) {
-        Configuration cf = Layer.boot().configuration().get();
-        ModuleReference mref = cf.findModule(name).orElse(null);
-        if (mref == null)
-            throw new RuntimeException("not found: " + name);
-        Path dir = Paths.get(mref.location().get());
-        if (!Files.isDirectory(dir))
-            throw new RuntimeException("not a directory: " + dir);
-        return dir;
-    }
-
-    static byte[] readAll(URL url) throws IOException {
-        try (InputStream in = url.openStream()) {
-            return in.readAllBytes();
-        }
-    }
-
-    static void assertTrue(boolean condition) {
-        if (!condition) throw new RuntimeException();
-    }
-
-    static void assertNull(Object o) {
-        assertTrue(o == null);
-    }
-
-    static void assertNotNull(Object o) {
-        assertTrue(o != null);
-    }
-
-    static void assertEquals(Object actual, Object expected) {
-        if (expected == null) {
-            assertNull(actual);
-        } else {
-            assertTrue(expected.equals(actual));
-        }
-    }
-
-    static void assertNotEquals(Object actual, Object expected) {
-        if (expected == null) {
-            assertNotNull(actual);
-        } else {
-            assertTrue(!expected.equals(actual));
-        }
-    }
-}
-
--- a/test/jdk/jigsaw/etc/resources/ResourcesTest.java	Sat Nov 07 16:48:06 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 2015, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
-import static jdk.testlibrary.ProcessTools.executeTestJava;
-
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
-import static org.testng.Assert.*;
-
-/**
- * @test
- * @library ../../lib /lib/testlibrary
- * @modules jdk.compiler
- * @build ResourcesTest CompilerUtils jdk.testlibrary.*
- * @run testng ResourcesTest
- * @summary Driver for basic test of resource encapsulation
- */
-
-@Test
-public class ResourcesTest {
-
-    private static final String TEST_SRC = System.getProperty("test.src");
-
-    private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
-    private static final Path CLASSES_DIR = Paths.get("classes");
-    private static final Path MODS_DIR = Paths.get("mods");
-
-
-    /**
-     * Compiles the modules used by the test and the test Main
-     */
-    @BeforeTest
-    public void compileAll() throws Exception {
-        boolean compiled;
-
-        // javac -modulesource mods -d mods src/**
-        compiled = CompilerUtils
-            .compile(SRC_DIR,
-                     MODS_DIR,
-                     "-modulesourcepath", SRC_DIR.toString());
-        assertTrue(compiled);
-
-        // javac -mp mods -d classes Main.java
-        compiled = CompilerUtils
-            .compile(Paths.get(TEST_SRC, "Main.java"),
-                     CLASSES_DIR,
-                     "-mp", MODS_DIR.toString());
-        assertTrue(compiled);
-
-    }
-
-    /**
-     * Run the test
-     */
-    public void runTest() throws Exception {
-
-        int exitValue
-            = executeTestJava("-mp", MODS_DIR.toString(),
-                              "-addmods", "m1,m2,m3",
-                               "-cp", CLASSES_DIR.toString(),
-                              "Main")
-                .outputTo(System.out)
-                .errorTo(System.out)
-                .getExitValue();
-
-        assertTrue(exitValue == 0);
-
-    }
-
-}
-
--- a/test/jdk/jigsaw/etc/resources/src/m1/module-info.java	Sat Nov 07 16:48:06 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2015, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-module m1 {
-    exports p1;
-}
--- a/test/jdk/jigsaw/etc/resources/src/m1/p1/Main.java	Sat Nov 07 16:48:06 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2015, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package p1;
-
-import java.io.InputStream;
-import java.net.URL;
-
-public class Main {
-    private Main() { }
-
-    public static URL getResource(String name) {
-        return Main.class.getResource(name);
-    }
-
-    public static InputStream getResourceAsStream(String name) {
-        return Main.class.getResourceAsStream(name);
-    }
-}
--- a/test/jdk/jigsaw/etc/resources/src/m2/module-info.java	Sat Nov 07 16:48:06 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2015, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-module m2 {
-    exports p2;
-}
--- a/test/jdk/jigsaw/etc/resources/src/m2/p2/Main.java	Sat Nov 07 16:48:06 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2015, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package p2;
-
-import java.io.InputStream;
-import java.net.URL;
-
-public class Main {
-    private Main() { }
-
-    public static URL getResource(String name) {
-        return Main.class.getResource(name);
-    }
-
-    public static InputStream getResourceAsStream(String name) {
-        return Main.class.getResourceAsStream(name);
-    }
-}
--- a/test/jdk/jigsaw/etc/resources/src/m3/module-info.java	Sat Nov 07 16:48:06 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2015, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-module m3 {
-    exports p3;
-}
--- a/test/jdk/jigsaw/etc/resources/src/m3/p3/Main.java	Sat Nov 07 16:48:06 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2015, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package p3;
-
-import java.io.InputStream;
-import java.net.URL;
-
-public class Main {
-    private Main() { }
-
-    public static URL getResource(String name) {
-        return Main.class.getResource(name);
-    }
-
-    public static InputStream getResourceAsStream(String name) {
-        return Main.class.getResourceAsStream(name);
-    }
-}