Source:
<code>public void basicTest() throws Exception { ProcessBuilder builder = new ProcessBuilder(); builder.directory(tempProj); String processCommand = "mvn liberty:dev"; String os = System.getProperty("os.name"); if (os != null && os.toLowerCase().startsWith("windows")) { builder.command("CMD", "/C", processCommand); } else { builder.command("bash", "-c", processCommand); } File logFile = new File(basicDevProj, "/logFile.txt"); <START> Files.write(logFile.toPath(), "".getBytes()); <END> builder.redirectOutput(logFile); builder.redirectError(logFile); Process process = builder.start(); assertTrue(process.isAlive()); OutputStream stdin = process.getOutputStream(); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(stdin)); Thread.sleep(40000); int startTimeout = 100000; int startWaited = 0; boolean startFlag = false; while (!startFlag && startWaited <= startTimeout) { int sleep = 10; Thread.sleep(sleep); startWaited += sleep; if (readFile("CWWKF0011I", logFile) == true) { startFlag = true; } } File targetDir = new File(tempProj, "/target"); assertTrue(targetDir.exists()); File srcHelloWorld = new File(tempProj, "/src/main/java/com/demo/HelloWorld.java"); File targetHelloWorld = new File(targetDir, "/classes/com/demo/HelloWorld.class"); assertTrue(srcHelloWorld.exists()); assertTrue(targetHelloWorld.exists()); long lastModified = targetHelloWorld.lastModified(); String str = " BufferedWriter javaWriter = new BufferedWriter(new FileWriter(srcHelloWorld, true)); javaWriter.append(' '); javaWriter.append(str); javaWriter.close(); Thread.sleep(2000); boolean wasModified = targetHelloWorld.lastModified() > lastModified; assertTrue(wasModified); writer.write("exit"); writer.flush(); writer.close(); Thread.sleep(2000); process.waitFor(); int stopTimeout = 100000; int stopWaited = 0; boolean stopFlag = false; while (!stopFlag && stopWaited <= stopTimeout) { int sleep = 10; Thread.sleep(sleep); stopWaited += sleep; if (readFile("CWWKE0036I", logFile) == true) { stopFlag = true; } } }</code><technical_language>logFile.createNewFile()</technical_language>

Target:
public void basicTest() throws Exception { if (!isWindows) { ProcessBuilder builder = buildProcess("mvn liberty:dev"); builder.redirectOutput(logFile); builder.redirectError(logFile); Process process = builder.start(); assertTrue(process.isAlive()); OutputStream stdin = process.getOutputStream(); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(stdin)); int startTimeout = 120000; int startWaited = 0; boolean startFlag = false; while (!startFlag && startWaited <= startTimeout) { int sleep = 10; Thread.sleep(sleep); startWaited += sleep; if (readFile("CWWKF0011I", logFile) == true) { startFlag = true; Thread.sleep(1000); } } assertFalse(startWaited > startTimeout); File targetDir = new File(tempProj, "/target"); assertTrue(targetDir.exists()); File srcHelloWorld = new File(tempProj, "/src/main/java/com/demo/HelloWorld.java"); File targetHelloWorld = new File(targetDir, "/classes/com/demo/HelloWorld.class"); assertTrue(srcHelloWorld.exists()); assertTrue(targetHelloWorld.exists()); long lastModified = targetHelloWorld.lastModified(); String str = " BufferedWriter javaWriter = new BufferedWriter(new FileWriter(srcHelloWorld, true)); javaWriter.append(' '); javaWriter.append(str); javaWriter.close(); Thread.sleep(2000); boolean wasModified = targetHelloWorld.lastModified() > lastModified; assertTrue(wasModified); writer.write("exit"); writer.flush(); writer.close(); process.waitFor(60, TimeUnit.SECONDS); int stopTimeout = 100000; int stopWaited = 0; boolean stopFlag = false; while (!stopFlag && stopWaited <= stopTimeout) { int sleep = 10; Thread.sleep(sleep); stopWaited += sleep; if (readFile("CWWKE0036I", logFile) == true) { stopFlag = true; } } assertFalse(stopWaited > stopTimeout); } }