83 JarUtils.createJarFile(MODS_DIR.resolve("logging-1.0.jar"), 84 loggingClasses); 85 86 87 // compile + create mods/httpserver-9.0.0.jar 88 89 compiled = CompilerUtils.compile(httpServerSrc, 90 httpServerClasses, 91 "-cp", loggingClasses.toString()); 92 assertTrue(compiled); 93 94 JarUtils.createJarFile(MODS_DIR.resolve("httpserver-9.0.0.jar"), 95 httpServerClasses); 96 97 98 // compile basictest to mods/basictest 99 100 compiled = CompilerUtils 101 .compile(SRC_DIR.resolve(testModule), 102 MODS_DIR.resolve(testModule), 103 "-mp", MODS_DIR.toString()); 104 assertTrue(compiled); 105 106 107 // launch the test. Need -addmods because nothing explicitly depends on logging 108 109 int exitValue 110 = executeTestJava("-mp", MODS_DIR.toString(), 111 "-addmods", "logging", 112 "-m", testModule + "/" + mainClass) 113 .outputTo(System.out) 114 .errorTo(System.out) 115 .getExitValue(); 116 117 assertTrue(exitValue == 0); 118 } 119 120 121 122 /** 123 * Test using a JAR file with a service provider as an automatic module. 124 * 125 * The consists of 2 modules: 126 * 127 * sptest - the test itself 128 * bananascript - a JAR file (automatic module) with a dummy ScriptEngineFactory 129 * 130 * The test uses ServiceLoader to locate and load ScriptEngineFactory 131 * implementations. It checks that bananascript is located. 142 143 144 // create mods/bananascript-0.9.jar 145 146 compiled = CompilerUtils.compile(providerSrc, providerClasses); 147 assertTrue(compiled); 148 149 String config = "META-INF/services/javax.script.ScriptEngineFactory"; 150 Path services = providerClasses.resolve(config).getParent(); 151 Files.createDirectories(services); 152 Files.copy(providerSrc.resolve(config), providerClasses.resolve(config)); 153 154 JarUtils.createJarFile(MODS_DIR.resolve("bananascript-0.9.jar"), providerClasses); 155 156 157 // compile sptest to mods/sptest 158 159 compiled = CompilerUtils 160 .compile(SRC_DIR.resolve(testModule), 161 MODS_DIR.resolve(testModule), 162 "-mp", MODS_DIR.toString()); 163 164 assertTrue(compiled); 165 166 167 // launch the test 168 169 int exitValue 170 = executeTestJava("-mp", MODS_DIR.toString(), 171 "-m", testModule + "/" + mainClass) 172 .outputTo(System.out) 173 .errorTo(System.out) 174 .getExitValue(); 175 176 assertTrue(exitValue == 0); 177 178 } 179 180 } | 83 JarUtils.createJarFile(MODS_DIR.resolve("logging-1.0.jar"), 84 loggingClasses); 85 86 87 // compile + create mods/httpserver-9.0.0.jar 88 89 compiled = CompilerUtils.compile(httpServerSrc, 90 httpServerClasses, 91 "-cp", loggingClasses.toString()); 92 assertTrue(compiled); 93 94 JarUtils.createJarFile(MODS_DIR.resolve("httpserver-9.0.0.jar"), 95 httpServerClasses); 96 97 98 // compile basictest to mods/basictest 99 100 compiled = CompilerUtils 101 .compile(SRC_DIR.resolve(testModule), 102 MODS_DIR.resolve(testModule), 103 "--module-path", MODS_DIR.toString()); 104 assertTrue(compiled); 105 106 107 // launch the test. Need --add-mdoules because nothing explicitly depends on logging 108 109 int exitValue 110 = executeTestJava("--module-path", MODS_DIR.toString(), 111 "--add-modules", "logging", 112 "-m", testModule + "/" + mainClass) 113 .outputTo(System.out) 114 .errorTo(System.out) 115 .getExitValue(); 116 117 assertTrue(exitValue == 0); 118 } 119 120 121 122 /** 123 * Test using a JAR file with a service provider as an automatic module. 124 * 125 * The consists of 2 modules: 126 * 127 * sptest - the test itself 128 * bananascript - a JAR file (automatic module) with a dummy ScriptEngineFactory 129 * 130 * The test uses ServiceLoader to locate and load ScriptEngineFactory 131 * implementations. It checks that bananascript is located. 142 143 144 // create mods/bananascript-0.9.jar 145 146 compiled = CompilerUtils.compile(providerSrc, providerClasses); 147 assertTrue(compiled); 148 149 String config = "META-INF/services/javax.script.ScriptEngineFactory"; 150 Path services = providerClasses.resolve(config).getParent(); 151 Files.createDirectories(services); 152 Files.copy(providerSrc.resolve(config), providerClasses.resolve(config)); 153 154 JarUtils.createJarFile(MODS_DIR.resolve("bananascript-0.9.jar"), providerClasses); 155 156 157 // compile sptest to mods/sptest 158 159 compiled = CompilerUtils 160 .compile(SRC_DIR.resolve(testModule), 161 MODS_DIR.resolve(testModule), 162 "--module-path", MODS_DIR.toString()); 163 164 assertTrue(compiled); 165 166 167 // launch the test 168 169 int exitValue 170 = executeTestJava("--module-path", MODS_DIR.toString(), 171 "-m", testModule + "/" + mainClass) 172 .outputTo(System.out) 173 .errorTo(System.out) 174 .getExitValue(); 175 176 assertTrue(exitValue == 0); 177 178 } 179 180 } |