224 //Strip debug
225 {
226 Map<String, String> config1 = new HashMap<>();
227 config1.put(StripDebugPlugin.NAME, "");
228 Plugin strip = Jlink.newPlugin("strip-debug", config1, null);
229 lst.add(strip);
230 }
231 // compress
232 {
233 Map<String, String> config1 = new HashMap<>();
234 config1.put(DefaultCompressPlugin.NAME, "2");
235 Plugin compress
236 = Jlink.newPlugin("compress", config1, null);
237 lst.add(compress);
238 }
239 // Post processor
240 {
241 lst.add(new MyPostProcessor());
242 }
243 // Image builder
244 DefaultImageBuilder builder = new DefaultImageBuilder(true, output);
245 PluginsConfiguration plugins
246 = new Jlink.PluginsConfiguration(lst, builder, null);
247
248 jlink.build(config, plugins);
249
250 if (!Files.exists(output)) {
251 throw new AssertionError("Directory not created");
252 }
253 File jimage = new File(output.toString(), "lib" + File.separator + "modules");
254 if (!jimage.exists()) {
255 throw new AssertionError("jimage not generated");
256 }
257 File bom = new File(output.toString(), "bom");
258 if (!bom.exists()) {
259 throw new AssertionError("bom not generated");
260 }
261 File release = new File(output.toString(), "release");
262 if (!release.exists()) {
263 throw new AssertionError("release not generated");
264 }
265
266 if (!Files.exists(output.resolve("toto.txt"))) {
267 throw new AssertionError("Post processing not called");
268 }
269
270 }
271
272 private static void testOrder() throws Exception {
273 Jlink jlink = new Jlink();
274 Path output = Paths.get("integrationout2");
275 List<Path> modulePaths = new ArrayList<>();
276 File jmods
277 = JImageGenerator.getJModsDir(new File(System.getProperty("test.jdk")));
278 modulePaths.add(jmods.toPath());
279 Set<String> mods = new HashSet<>();
280 mods.add("java.management");
294 Set<String> after = new HashSet<>();
295 after.add(MyPlugin1.NAME+"2");
296 lst.add(new MyPlugin1(3, after, Collections.emptySet()));
297 }
298
299 // TRANSFORMER 2, must be after 1.
300 {
301 Set<String> after = new HashSet<>();
302 after.add(MyPlugin1.NAME+"1");
303 lst.add(new MyPlugin1(2, after, Collections.emptySet()));
304 }
305
306 // TRANSFORMER 1
307 {
308 Set<String> before = new HashSet<>();
309 before.add(MyPlugin1.NAME+"2");
310 lst.add(new MyPlugin1(1, Collections.emptySet(), before));
311 }
312
313 // Image builder
314 DefaultImageBuilder builder = new DefaultImageBuilder(false, output);
315 PluginsConfiguration plugins
316 = new Jlink.PluginsConfiguration(lst, builder, null);
317
318 jlink.build(config, plugins);
319
320 if (ordered.isEmpty()) {
321 throw new AssertionError("Plugins not called");
322 }
323 List<Integer> clone = new ArrayList<>();
324 clone.addAll(ordered);
325 Collections.sort(clone);
326 if (!clone.equals(ordered)) {
327 throw new AssertionError("Ordered is not properly sorted" + ordered);
328 }
329 }
330
331 private static void testCycleOrder() throws Exception {
332 Jlink jlink = new Jlink();
333 Path output = Paths.get("integrationout3");
334 List<Path> modulePaths = new ArrayList<>();
342 JlinkConfiguration config = new Jlink.JlinkConfiguration(output,
343 modulePaths, mods, limits, null);
344
345 List<Plugin> lst = new ArrayList<>();
346
347 // packager 1
348 {
349 Set<String> before = new HashSet<>();
350 before.add(MyPlugin1.NAME+"2");
351 lst.add(new MyPlugin1(1, Collections.emptySet(), before));
352 }
353
354 // packager 2
355 {
356 Set<String> before = new HashSet<>();
357 before.add(MyPlugin1.NAME+"1");
358 lst.add(new MyPlugin1(2, Collections.emptySet(), before));
359 }
360
361 // Image builder
362 DefaultImageBuilder builder = new DefaultImageBuilder(false, output);
363 PluginsConfiguration plugins
364 = new Jlink.PluginsConfiguration(lst, builder, null);
365 boolean failed = false;
366 try {
367 jlink.build(config, plugins);
368 failed = true;
369 } catch (Exception ex) {
370 // XXX OK
371 }
372 if (failed) {
373 throw new AssertionError("Should have failed");
374 }
375 }
376 }
|
224 //Strip debug
225 {
226 Map<String, String> config1 = new HashMap<>();
227 config1.put(StripDebugPlugin.NAME, "");
228 Plugin strip = Jlink.newPlugin("strip-debug", config1, null);
229 lst.add(strip);
230 }
231 // compress
232 {
233 Map<String, String> config1 = new HashMap<>();
234 config1.put(DefaultCompressPlugin.NAME, "2");
235 Plugin compress
236 = Jlink.newPlugin("compress", config1, null);
237 lst.add(compress);
238 }
239 // Post processor
240 {
241 lst.add(new MyPostProcessor());
242 }
243 // Image builder
244 DefaultImageBuilder builder = new DefaultImageBuilder(output);
245 PluginsConfiguration plugins
246 = new Jlink.PluginsConfiguration(lst, builder, null);
247
248 jlink.build(config, plugins);
249
250 if (!Files.exists(output)) {
251 throw new AssertionError("Directory not created");
252 }
253 File jimage = new File(output.toString(), "lib" + File.separator + "modules");
254 if (!jimage.exists()) {
255 throw new AssertionError("jimage not generated");
256 }
257 File release = new File(output.toString(), "release");
258 if (!release.exists()) {
259 throw new AssertionError("release not generated");
260 }
261
262 if (!Files.exists(output.resolve("toto.txt"))) {
263 throw new AssertionError("Post processing not called");
264 }
265
266 }
267
268 private static void testOrder() throws Exception {
269 Jlink jlink = new Jlink();
270 Path output = Paths.get("integrationout2");
271 List<Path> modulePaths = new ArrayList<>();
272 File jmods
273 = JImageGenerator.getJModsDir(new File(System.getProperty("test.jdk")));
274 modulePaths.add(jmods.toPath());
275 Set<String> mods = new HashSet<>();
276 mods.add("java.management");
290 Set<String> after = new HashSet<>();
291 after.add(MyPlugin1.NAME+"2");
292 lst.add(new MyPlugin1(3, after, Collections.emptySet()));
293 }
294
295 // TRANSFORMER 2, must be after 1.
296 {
297 Set<String> after = new HashSet<>();
298 after.add(MyPlugin1.NAME+"1");
299 lst.add(new MyPlugin1(2, after, Collections.emptySet()));
300 }
301
302 // TRANSFORMER 1
303 {
304 Set<String> before = new HashSet<>();
305 before.add(MyPlugin1.NAME+"2");
306 lst.add(new MyPlugin1(1, Collections.emptySet(), before));
307 }
308
309 // Image builder
310 DefaultImageBuilder builder = new DefaultImageBuilder(output);
311 PluginsConfiguration plugins
312 = new Jlink.PluginsConfiguration(lst, builder, null);
313
314 jlink.build(config, plugins);
315
316 if (ordered.isEmpty()) {
317 throw new AssertionError("Plugins not called");
318 }
319 List<Integer> clone = new ArrayList<>();
320 clone.addAll(ordered);
321 Collections.sort(clone);
322 if (!clone.equals(ordered)) {
323 throw new AssertionError("Ordered is not properly sorted" + ordered);
324 }
325 }
326
327 private static void testCycleOrder() throws Exception {
328 Jlink jlink = new Jlink();
329 Path output = Paths.get("integrationout3");
330 List<Path> modulePaths = new ArrayList<>();
338 JlinkConfiguration config = new Jlink.JlinkConfiguration(output,
339 modulePaths, mods, limits, null);
340
341 List<Plugin> lst = new ArrayList<>();
342
343 // packager 1
344 {
345 Set<String> before = new HashSet<>();
346 before.add(MyPlugin1.NAME+"2");
347 lst.add(new MyPlugin1(1, Collections.emptySet(), before));
348 }
349
350 // packager 2
351 {
352 Set<String> before = new HashSet<>();
353 before.add(MyPlugin1.NAME+"1");
354 lst.add(new MyPlugin1(2, Collections.emptySet(), before));
355 }
356
357 // Image builder
358 DefaultImageBuilder builder = new DefaultImageBuilder(output);
359 PluginsConfiguration plugins
360 = new Jlink.PluginsConfiguration(lst, builder, null);
361 boolean failed = false;
362 try {
363 jlink.build(config, plugins);
364 failed = true;
365 } catch (Exception ex) {
366 // XXX OK
367 }
368 if (failed) {
369 throw new AssertionError("Should have failed");
370 }
371 }
372 }
|