< prev index next >

jdk/test/tools/jlink/plugins/SystemModuleDescriptors/UserModuleTest.java

Print this page




  56     // the names of the modules in this test
  57     private static String[] modules = new String[] {"m1", "m2", "m3"};
  58 
  59     private static boolean hasJmods() {
  60         if (!Files.exists(JMODS)) {
  61             System.err.println("Test skipped. NO jmods directory");
  62             return false;
  63         }
  64         return true;
  65     }
  66 
  67     /*
  68      * Compiles all modules used by the test
  69      */
  70     @BeforeTest
  71     public void compileAll() throws Throwable {
  72         if (!hasJmods()) return;
  73 
  74         for (String mn : modules) {
  75             Path msrc = SRC_DIR.resolve(mn);
  76             assertTrue(CompilerUtils.compile(msrc, MODS_DIR, "-modulesourcepath", SRC_DIR.toString()));
  77         }
  78 
  79         if (Files.exists(IMAGE)) {
  80             FileUtils.deleteFileTreeUnchecked(IMAGE);
  81         }
  82 
  83         createImage(IMAGE, "java.base", "m1");
  84     }
  85 
  86     private void createImage(Path outputDir, String... modules) throws Throwable {
  87         Path jlink = Paths.get(JAVA_HOME, "bin", "jlink");
  88         String mp = JMODS.toString() + File.pathSeparator + MODS_DIR.toString();
  89         assertTrue(executeProcess(jlink.toString(), "--output", outputDir.toString(),
  90                         "--addmods", Arrays.stream(modules).collect(Collectors.joining(",")),
  91                         "--modulepath", mp)
  92                         .outputTo(System.out)
  93                         .errorTo(System.out)
  94                         .getExitValue() == 0);
  95     }
  96 
  97     /*
  98      * Test the image created when linking with a module with
  99      * no ConcealedPackages attribute
 100      */
 101     @Test
 102     public void test() throws Throwable {
 103         if (!hasJmods()) return;
 104 
 105         Path java = IMAGE.resolve("bin").resolve("java");
 106         assertTrue(executeProcess(java.toString(), "-m", "m1/p1.Main")
 107                         .outputTo(System.out)
 108                         .errorTo(System.out)
 109                         .getExitValue() == 0);
 110     }
 111 




  56     // the names of the modules in this test
  57     private static String[] modules = new String[] {"m1", "m2", "m3"};
  58 
  59     private static boolean hasJmods() {
  60         if (!Files.exists(JMODS)) {
  61             System.err.println("Test skipped. NO jmods directory");
  62             return false;
  63         }
  64         return true;
  65     }
  66 
  67     /*
  68      * Compiles all modules used by the test
  69      */
  70     @BeforeTest
  71     public void compileAll() throws Throwable {
  72         if (!hasJmods()) return;
  73 
  74         for (String mn : modules) {
  75             Path msrc = SRC_DIR.resolve(mn);
  76             assertTrue(CompilerUtils.compile(msrc, MODS_DIR, "--module-source-path", SRC_DIR.toString()));
  77         }
  78 
  79         if (Files.exists(IMAGE)) {
  80             FileUtils.deleteFileTreeUnchecked(IMAGE);
  81         }
  82 
  83         createImage(IMAGE, "java.base", "m1");
  84     }
  85 
  86     private void createImage(Path outputDir, String... modules) throws Throwable {
  87         Path jlink = Paths.get(JAVA_HOME, "bin", "jlink");
  88         String mp = JMODS.toString() + File.pathSeparator + MODS_DIR.toString();
  89         assertTrue(executeProcess(jlink.toString(), "--output", outputDir.toString(),
  90                         "--add-modules", Arrays.stream(modules).collect(Collectors.joining(",")),
  91                         "--module-path", mp)
  92                         .outputTo(System.out)
  93                         .errorTo(System.out)
  94                         .getExitValue() == 0);
  95     }
  96 
  97     /*
  98      * Test the image created when linking with a module with
  99      * no ConcealedPackages attribute
 100      */
 101     @Test
 102     public void test() throws Throwable {
 103         if (!hasJmods()) return;
 104 
 105         Path java = IMAGE.resolve("bin").resolve("java");
 106         assertTrue(executeProcess(java.toString(), "-m", "m1/p1.Main")
 107                         .outputTo(System.out)
 108                         .errorTo(System.out)
 109                         .getExitValue() == 0);
 110     }
 111 


< prev index next >