< prev index next >

test/jdk/java/lang/ClassLoader/getResource/automaticmodules/Driver.java

Print this page
rev 51881 : [mq]: 8211171
rev 51882 : [mq]: 8211171-1


   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  * @library /lib/testlibrary /test/lib
  27  * @build Driver Main JarUtils

  28  * @run main Driver
  29  * @summary Test ClassLoader.getResourceXXX to locate resources in an automatic
  30  *          module
  31  */
  32 
  33 import java.lang.module.ModuleFinder;
  34 import java.lang.module.ModuleReference;
  35 import java.nio.file.Files;
  36 import java.nio.file.Path;
  37 import java.nio.file.Paths;
  38 import java.util.jar.Attributes;
  39 import java.util.jar.Manifest;
  40 
  41 import jdk.test.lib.process.ProcessTools;

  42 
  43 /**
  44  * The driver creates a JAR file containing p/Foo.class, p/foo.properties,
  45  * and p/resources/bar.properties. This ensures there are is a resource in
  46  * a module package and a resource that is not in the module package. The
  47  * test is then launched to locate every resource in the JAR file.
  48  */
  49 
  50 public class Driver {
  51 
  52     private static final String TEST_CLASSES = System.getProperty("test.classes");
  53 
  54     public static void main(String[] args) throws Exception {
  55         // create content for JAR file
  56         Path dir = Files.createTempDirectory("classes");
  57         Path p = Files.createDirectory(dir.resolve("p"));
  58         Files.createFile(p.resolve("Foo.class"));
  59         Files.createFile(p.resolve("foo.properties"));
  60         Path resources = Files.createDirectory(p.resolve("resources"));
  61         Files.createFile(resources.resolve("bar.properties"));




   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  * @library /test/lib
  27  * @build Driver Main
  28  *        jdk.test.lib.util.JarUtils
  29  * @run main Driver
  30  * @summary Test ClassLoader.getResourceXXX to locate resources in an automatic
  31  *          module
  32  */
  33 
  34 import java.lang.module.ModuleFinder;
  35 import java.lang.module.ModuleReference;
  36 import java.nio.file.Files;
  37 import java.nio.file.Path;
  38 import java.nio.file.Paths;
  39 import java.util.jar.Attributes;
  40 import java.util.jar.Manifest;
  41 
  42 import jdk.test.lib.process.ProcessTools;
  43 import jdk.test.lib.util.JarUtils;
  44 
  45 /**
  46  * The driver creates a JAR file containing p/Foo.class, p/foo.properties,
  47  * and p/resources/bar.properties. This ensures there are is a resource in
  48  * a module package and a resource that is not in the module package. The
  49  * test is then launched to locate every resource in the JAR file.
  50  */
  51 
  52 public class Driver {
  53 
  54     private static final String TEST_CLASSES = System.getProperty("test.classes");
  55 
  56     public static void main(String[] args) throws Exception {
  57         // create content for JAR file
  58         Path dir = Files.createTempDirectory("classes");
  59         Path p = Files.createDirectory(dir.resolve("p"));
  60         Files.createFile(p.resolve("Foo.class"));
  61         Files.createFile(p.resolve("foo.properties"));
  62         Path resources = Files.createDirectory(p.resolve("resources"));
  63         Files.createFile(resources.resolve("bar.properties"));


< prev index next >