1 /* |
1 /* |
2 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
52 private static final Path MODS_DIR = Paths.get("mods"); |
52 private static final Path MODS_DIR = Paths.get("mods"); |
53 private static final Path LIBS_DIR = Paths.get("libs"); |
53 private static final Path LIBS_DIR = Paths.get("libs"); |
54 private static final Path DEST_DIR = Paths.get("moduleinfosrc"); |
54 private static final Path DEST_DIR = Paths.get("moduleinfosrc"); |
55 private static final Path NEW_MODS_DIR = Paths.get("new_mods"); |
55 private static final Path NEW_MODS_DIR = Paths.get("new_mods"); |
56 |
56 |
57 /** |
|
58 * Compiles all modules used by the test |
|
59 */ |
|
60 @BeforeTest |
57 @BeforeTest |
61 public void compileAll() throws Exception { |
58 public void setup() throws Exception { |
62 |
59 compileAndCreateJars(); |
63 compileModules(MODS_DIR); |
|
64 |
|
65 createJARFiles(MODS_DIR, LIBS_DIR); |
|
66 } |
60 } |
67 |
61 |
68 @Test |
62 @Test |
69 public void test() throws IOException { |
63 public void test() throws IOException { |
|
64 Path dest = DEST_DIR.resolve("open"); |
|
65 Path classes = NEW_MODS_DIR.resolve("open"); |
|
66 Files.createDirectories(dest); |
|
67 Files.createDirectories(classes); |
|
68 |
70 Stream<String> files = MODULES.stream() |
69 Stream<String> files = MODULES.stream() |
71 .map(mn -> LIBS_DIR.resolve(mn + ".jar")) |
70 .map(mn -> LIBS_DIR.resolve(mn + ".jar")) |
72 .map(Path::toString); |
71 .map(Path::toString); |
73 |
72 |
74 Stream<String> options = Stream.concat( |
73 Stream<String> options = Stream.concat( |
75 Stream.of("--generate-open-module", DEST_DIR.toString()), files); |
74 Stream.of("--generate-open-module", dest.toString()), files); |
76 JdepsRunner.run(options.toArray(String[]::new)); |
75 JdepsRunner.run(options.toArray(String[]::new)); |
77 |
76 |
78 // check file exists |
77 // check file exists |
79 MODULES.stream() |
78 MODULES.stream() |
80 .map(mn -> DEST_DIR.resolve(mn).resolve("module-info.java")) |
79 .map(mn -> dest.resolve(mn).resolve("module-info.java")) |
81 .forEach(f -> assertTrue(Files.exists(f))); |
80 .forEach(f -> assertTrue(Files.exists(f))); |
82 |
81 |
83 // copy classes to a temporary directory |
82 // copy classes to a temporary directory |
84 // and then compile new module-info.java |
83 // and then compile new module-info.java |
85 copyClasses(MODS_DIR, NEW_MODS_DIR); |
84 copyClasses(MODS_DIR, classes); |
86 compileNewGenModuleInfo(DEST_DIR, NEW_MODS_DIR); |
85 compileNewGenModuleInfo(dest, classes); |
87 |
86 |
88 for (String mn : MODULES) { |
87 for (String mn : MODULES) { |
89 Path p1 = NEW_MODS_DIR.resolve(mn).resolve(MODULE_INFO); |
88 Path p1 = classes.resolve(mn).resolve(MODULE_INFO); |
90 Path p2 = MODS_DIR.resolve(mn).resolve(MODULE_INFO); |
89 Path p2 = MODS_DIR.resolve(mn).resolve(MODULE_INFO); |
91 |
|
92 try (InputStream in1 = Files.newInputStream(p1); |
90 try (InputStream in1 = Files.newInputStream(p1); |
93 InputStream in2 = Files.newInputStream(p2)) { |
91 InputStream in2 = Files.newInputStream(p2)) { |
94 verify(ModuleDescriptor.read(in1), |
92 verify(ModuleDescriptor.read(in1), |
95 ModuleDescriptor.read(in2)); |
93 ModuleDescriptor.read(in2)); |
96 } |
94 } |