139
140 int count = TIMEOUT / 100;
141 while (!futures.isEmpty() && count-- > 0) {
142 Iterator<Future> it = futures.iterator();
143 while (it.hasNext()) {
144 Future future = it.next();
145 if (future.await(0, TimeUnit.MILLISECONDS)) {
146 it.remove();
147 }
148 }
149 if (!futures.isEmpty()) {
150 Util.sleep(100);
151 }
152 }
153
154 if (!futures.isEmpty()) {
155 throw new AssertionFailedError("Exceeded timeout limit of " + TIMEOUT + " msec");
156 }
157 }
158
159 private static String getJfxrtDir(final String classpath) {
160 final String jfxrt = "jfxrt.jar";
161 String cp = classpath;
162 int idx = cp.replace('\\', '/').indexOf("/" + jfxrt);
163 if (idx >= 0) {
164 cp = cp.substring(0, idx);
165 idx = cp.lastIndexOf(File.pathSeparator);
166 if (idx >= 0) {
167 cp = cp.substring(idx, cp.length());
168 }
169 return cp;
170 }
171 return null;
172 }
173
174 public static ArrayList<String> createApplicationLaunchCommand(
175 String testAppName,
176 String testPldrName,
177 String testPolicy) throws IOException {
178
179 final String classpath = System.getProperty("java.class.path");
180
181 /*
182 * note: the "worker" properties are tied into build.gradle and
183 * the related GradleJUnitWorker as a workaround until the build
184 * is fully converted to a modular build
185 */
186 final Boolean isJigsaw = Boolean.getBoolean("worker.isJigsaw");
187 final String workerJavaCmd = System.getProperty("worker.java.cmd");
188 final String workerPatchModuleFile = System.getProperty("worker.patchmodule.file");
189 final String workerPatchPolicy = System.getProperty("worker.patch.policy");
190 final String workerClassPath = System.getProperty("worker.classpath.file");
191 final Boolean workerDebug = Boolean.getBoolean("worker.debug");
192
193 final ArrayList<String> cmd = new ArrayList<>(30);
194
195 if (workerJavaCmd != null) {
196 cmd.add(workerJavaCmd);
197 } else {
198 cmd.add("java");
199 }
200
201 if (isJigsaw && workerPatchModuleFile != null) {
202 cmd.add("@" + workerPatchModuleFile);
203 } else {
204 String jfxdir = getJfxrtDir(classpath);
205 Assert.assertNotNull("failed to find jfxdir",jfxdir);
206 cmd.add("-Xbootclasspath/a:" + jfxdir + "/" + "jfxrt.jar");
207 }
208
209 // This is a "minimum" set, rather than the full @addExports
210 if (isJigsaw) {
211 cmd.add("--add-exports=javafx.graphics/com.sun.javafx.application=ALL-UNNAMED");
212 }
213
214 if (isJigsaw && workerClassPath != null) {
215 cmd.add("@" + workerClassPath);
216 } else {
217 cmd.add("-cp");
218 cmd.add(classpath);
219 }
220
221 if (testPldrName != null) {
222 cmd.add("-Djavafx.preloader=" + testPldrName);
223 }
224
225 if (testPolicy != null) {
226
227 cmd.add("-Djava.security.manager");
228
229 try {
230 if (workerPatchPolicy != null) {
231 // with Jigsaw, we need to create a merged java.policy
232 // file that contains the permissions for the patchmodule classes
233 // as well as the permissions needed for this test
234
235 File wpp = new File(workerPatchPolicy);
236 if (!wpp.exists()) {
237 throw new RuntimeException("Missing workerPatchPolicy");
238 }
|
139
140 int count = TIMEOUT / 100;
141 while (!futures.isEmpty() && count-- > 0) {
142 Iterator<Future> it = futures.iterator();
143 while (it.hasNext()) {
144 Future future = it.next();
145 if (future.await(0, TimeUnit.MILLISECONDS)) {
146 it.remove();
147 }
148 }
149 if (!futures.isEmpty()) {
150 Util.sleep(100);
151 }
152 }
153
154 if (!futures.isEmpty()) {
155 throw new AssertionFailedError("Exceeded timeout limit of " + TIMEOUT + " msec");
156 }
157 }
158
159 public static ArrayList<String> createApplicationLaunchCommand(
160 String testAppName,
161 String testPldrName,
162 String testPolicy) throws IOException {
163
164 final String classpath = System.getProperty("java.class.path");
165
166 /*
167 * note: the "worker" properties are tied into build.gradle
168 */
169 final String workerJavaCmd = System.getProperty("worker.java.cmd");
170 final String workerPatchModuleFile = System.getProperty("worker.patchmodule.file");
171 final String workerPatchPolicy = System.getProperty("worker.patch.policy");
172 final String workerClassPath = System.getProperty("worker.classpath.file");
173 final Boolean workerDebug = Boolean.getBoolean("worker.debug");
174
175 final ArrayList<String> cmd = new ArrayList<>(30);
176
177 if (workerJavaCmd != null) {
178 cmd.add(workerJavaCmd);
179 } else {
180 cmd.add("java");
181 }
182
183 if (workerPatchModuleFile != null) {
184 cmd.add("@" + workerPatchModuleFile);
185 } else {
186 System.out.println("Warning: no worker.patchmodule passed to unit test");
187 }
188
189 // This is a "minimum" set, rather than the full @addExports
190 cmd.add("--add-exports=javafx.graphics/com.sun.javafx.application=ALL-UNNAMED");
191
192 if (workerClassPath != null) {
193 cmd.add("@" + workerClassPath);
194 }
195
196 if (testPldrName != null) {
197 cmd.add("-Djavafx.preloader=" + testPldrName);
198 }
199
200 if (testPolicy != null) {
201
202 cmd.add("-Djava.security.manager");
203
204 try {
205 if (workerPatchPolicy != null) {
206 // with Jigsaw, we need to create a merged java.policy
207 // file that contains the permissions for the patchmodule classes
208 // as well as the permissions needed for this test
209
210 File wpp = new File(workerPatchPolicy);
211 if (!wpp.exists()) {
212 throw new RuntimeException("Missing workerPatchPolicy");
213 }
|