57 */ |
57 */ |
58 @BeforeTest |
58 @BeforeTest |
59 public void compileAll() throws Exception { |
59 public void compileAll() throws Exception { |
60 CompilerUtils.cleanDir(CLASSES_DIR); |
60 CompilerUtils.cleanDir(CLASSES_DIR); |
61 |
61 |
62 assertTrue(CompilerUtils.compile(Paths.get(TEST_SRC, "p"), |
62 Path tmp = Paths.get("tmp"); |
|
63 assertTrue(CompilerUtils.compile(Paths.get(TEST_SRC, "src", "apple"), tmp)); |
|
64 assertTrue(CompilerUtils.compile(Paths.get(TEST_SRC, "src", "q"), |
63 CLASSES_DIR, |
65 CLASSES_DIR, |
|
66 "-cp", tmp.toString(), |
64 "-XaddExports:java.base/sun.security.util=ALL-UNNAMED")); |
67 "-XaddExports:java.base/sun.security.util=ALL-UNNAMED")); |
65 } |
68 } |
66 |
69 |
67 @Test |
70 @Test |
68 public void withReplacement() { |
71 public void withReplacement() { |
69 Path file = Paths.get("p", "WithRepl.class"); |
72 Path file = Paths.get("q", "WithRepl.class"); |
70 String[] output = JdepsUtil.jdeps("-jdkinternals", CLASSES_DIR.resolve(file).toString()); |
73 String[] output = JdepsUtil.jdeps("-jdkinternals", CLASSES_DIR.resolve(file).toString()); |
71 int i = 0; |
74 int i = 0; |
72 while (!output[i].contains("Suggested Replacement")) { |
75 while (!output[i].contains("Suggested Replacement")) { |
73 i++; |
76 i++; |
74 } |
77 } |
88 String repl = line.substring(pos, line.length()).trim(); |
91 String repl = line.substring(pos, line.length()).trim(); |
89 assertEquals(REPLACEMENTS.get(name), repl); |
92 assertEquals(REPLACEMENTS.get(name), repl); |
90 } |
93 } |
91 } |
94 } |
92 |
95 |
|
96 /* |
|
97 * A JDK internal class has been removed while its package still exists. |
|
98 */ |
93 @Test |
99 @Test |
94 public void noReplacement() { |
100 public void noReplacement() { |
95 Path file = Paths.get("p", "NoRepl.class"); |
101 Path file = Paths.get("q", "NoRepl.class"); |
|
102 String[] output = JdepsUtil.jdeps("-jdkinternals", CLASSES_DIR.resolve(file).toString()); |
|
103 int i = 0; |
|
104 // expect no replacement |
|
105 while (i < output.length && !output[i].contains("Suggested Replacement")) { |
|
106 i++; |
|
107 } |
|
108 |
|
109 // no replacement |
|
110 assertEquals(output.length-i, 0); |
|
111 } |
|
112 |
|
113 /* |
|
114 * A JDK internal package has been removed. |
|
115 */ |
|
116 @Test |
|
117 public void removedPackage() { |
|
118 Path file = Paths.get("q", "RemovedPackage.class"); |
96 String[] output = JdepsUtil.jdeps("-jdkinternals", CLASSES_DIR.resolve(file).toString()); |
119 String[] output = JdepsUtil.jdeps("-jdkinternals", CLASSES_DIR.resolve(file).toString()); |
97 int i = 0; |
120 int i = 0; |
98 // expect no replacement |
121 // expect no replacement |
99 while (i < output.length && !output[i].contains("Suggested Replacement")) { |
122 while (i < output.length && !output[i].contains("Suggested Replacement")) { |
100 i++; |
123 i++; |