169 if (!expectedMainClass.equals(mainClass)) { |
169 if (!expectedMainClass.equals(mainClass)) { |
170 throw new RuntimeException("Main class is wrong: " + mainClass); |
170 throw new RuntimeException("Main class is wrong: " + mainClass); |
171 } |
171 } |
172 } |
172 } |
173 |
173 |
174 private void testProcessHelper(List<String> args) throws Exception { |
174 private void testProcessHelper(List<String> args, String expectedValue) throws Exception { |
175 ProcessBuilder pb = new ProcessBuilder(args); |
175 ProcessBuilder pb = new ProcessBuilder(args); |
176 String cmd = pb.command().stream().collect(Collectors.joining(" ")); |
176 String cmd = pb.command().stream().collect(Collectors.joining(" ")); |
177 System.out.println("Starting the process:" + cmd); |
177 System.out.println("Starting the process:" + cmd); |
178 Process p = ProcessTools.startProcess("test", pb); |
178 Process p = ProcessTools.startProcess("test", pb); |
179 if (!p.isAlive()) { |
179 if (!p.isAlive()) { |
180 throw new RuntimeException("Cannot start the process: " + cmd); |
180 throw new RuntimeException("Cannot start the process: " + cmd); |
181 } |
181 } |
182 checkMainClass(p, TEST_PROCESS_MAIN_CLASS); |
182 checkMainClass(p, expectedValue); |
183 } |
183 } |
184 |
184 |
185 private File prepareJar() throws Exception { |
185 private File prepareJar() throws Exception { |
186 Path jarFile = USER_DIR.resolve("testprocess.jar"); |
186 Path jarFile = USER_DIR.resolve("testprocess.jar"); |
187 Manifest manifest = createManifest(); |
187 Manifest manifest = createManifest(); |