118 }
119
120 /**
121 * Test with --patch-module options patching the same module
122 */
123 public void testDuplicateModule() throws Exception {
124 int exitValue =
125 executeTestJava("--patch-module", "java.base=" + PATCHES1_DIR.resolve("java.base"),
126 "--patch-module", "java.base=" + PATCHES2_DIR.resolve("java.base"),
127 "--module-path", MODS_DIR.toString(),
128 "-m", "test/jdk.test.Main")
129 .outputTo(System.out)
130 .errorTo(System.out)
131 // error output by VM
132 .shouldContain("Cannot specify java.base more than once to --patch-module")
133 .getExitValue();
134
135 assertTrue(exitValue != 0);
136 }
137
138 @DataProvider(name = "emptyItem")
139 public Object[][] emptyItems() {
140 String patch1 = PATCHES1_DIR.resolve("java.base").toString();
141 String patch2 = PATCHES2_DIR.resolve("java.base").toString();
142 String pathSep = File.pathSeparator;
143 return new Object[][]{
144
145 { "java.base="+ pathSep + patch1 + pathSep + patch2, null },
146 { "java.base="+ patch1 + pathSep + pathSep + patch2, null },
147 { "java.base="+ patch1 + pathSep + patch2 + pathSep + pathSep, null },
148 };
149 }
150
151 /**
152 * Empty item in a non-empty path list
153 */
154 @Test(dataProvider = "emptyItem")
155 public void testEmptyItem(String value, String msg) throws Exception {
156 // the argument to the test is the list of classes overridden or added
157 String arg = Stream.of(CLASSES).collect(Collectors.joining(","));
|
118 }
119
120 /**
121 * Test with --patch-module options patching the same module
122 */
123 public void testDuplicateModule() throws Exception {
124 int exitValue =
125 executeTestJava("--patch-module", "java.base=" + PATCHES1_DIR.resolve("java.base"),
126 "--patch-module", "java.base=" + PATCHES2_DIR.resolve("java.base"),
127 "--module-path", MODS_DIR.toString(),
128 "-m", "test/jdk.test.Main")
129 .outputTo(System.out)
130 .errorTo(System.out)
131 // error output by VM
132 .shouldContain("Cannot specify java.base more than once to --patch-module")
133 .getExitValue();
134
135 assertTrue(exitValue != 0);
136 }
137
138 /**
139 * Test with --patch-module options patching the same module (not java.base).
140 *
141 */
142 public void testDuplicateModuleLogging() throws Exception {
143 int exitValue =
144 executeTestJava("--patch-module", "java.logging=" + PATCHES1_DIR.resolve("java.base"),
145 "--patch-module", "java.logging=" + PATCHES2_DIR.resolve("java.base"),
146 "--module-path", MODS_DIR.toString(),
147 "-m", "test/jdk.test.Main")
148 .outputTo(System.out)
149 .errorTo(System.out)
150 // error output by VM
151 .shouldContain("Cannot specify a module more than once to --patch-module: java.logging")
152 .getExitValue();
153
154 assertTrue(exitValue != 0);
155 }
156
157 @DataProvider(name = "emptyItem")
158 public Object[][] emptyItems() {
159 String patch1 = PATCHES1_DIR.resolve("java.base").toString();
160 String patch2 = PATCHES2_DIR.resolve("java.base").toString();
161 String pathSep = File.pathSeparator;
162 return new Object[][]{
163
164 { "java.base="+ pathSep + patch1 + pathSep + patch2, null },
165 { "java.base="+ patch1 + pathSep + pathSep + patch2, null },
166 { "java.base="+ patch1 + pathSep + patch2 + pathSep + pathSep, null },
167 };
168 }
169
170 /**
171 * Empty item in a non-empty path list
172 */
173 @Test(dataProvider = "emptyItem")
174 public void testEmptyItem(String value, String msg) throws Exception {
175 // the argument to the test is the list of classes overridden or added
176 String arg = Stream.of(CLASSES).collect(Collectors.joining(","));
|