use of org.zeroturnaround.exec.StartedProcess in project ninja by ninjaframework.
the class RunClassInSeparateJvmMachineTest method multipleRestartsReallyQuickly.
@Test
public void multipleRestartsReallyQuickly() throws Exception {
RunClassInSeparateJvmMachine rcsjm = new RunClassInSeparateJvmMachine("FakeDaemon", FakeDaemonMain.class.getName(), getOurClassPath(), Collections.EMPTY_LIST, new File("."));
// override output so we can capture it
final ByteArrayOutputStream baos1 = new ByteArrayOutputStream();
rcsjm.setOutput(baos1);
rcsjm.restart();
StartedProcess startedProcess1 = rcsjm.getActiveProcess();
rcsjm.restart();
StartedProcess startedProcess2 = rcsjm.getActiveProcess();
rcsjm.restart();
StartedProcess startedProcess3 = rcsjm.getActiveProcess();
rcsjm.restart();
StartedProcess startedProcess4 = rcsjm.getActiveProcess();
assertTrue(isAlive(startedProcess4.getProcess()));
assertFalse(isAlive(startedProcess1.getProcess()));
assertFalse(isAlive(startedProcess2.getProcess()));
assertFalse(isAlive(startedProcess3.getProcess()));
assertFalse(startedProcess1.equals(startedProcess2));
}
use of org.zeroturnaround.exec.StartedProcess in project ninja by ninjaframework.
the class RunClassInSeparateJvmMachineTest method startProcess.
@Test
public void startProcess() throws Exception {
RunClassInSeparateJvmMachine rcsjm = new RunClassInSeparateJvmMachine("FakeDaemon", FakeDaemonMain.class.getName(), getOurClassPath(), Collections.EMPTY_LIST, new File("."));
// override output so we can capture it
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
rcsjm.setOutput(baos);
StartedProcess startedProcess = rcsjm.startProcess();
assertTrue(isAlive(startedProcess.getProcess()));
waitOrTimeout(fakeDaemonCondition(baos), Timeout.timeout(Duration.millis(10000)));
startedProcess.getProcess().destroy();
ProcessResult processResult = startedProcess.getFuture().get();
}
use of org.zeroturnaround.exec.StartedProcess in project ninja by ninjaframework.
the class RunClassInSeparateJvmMachineTest method restart.
@Test
public void restart() throws Exception {
RunClassInSeparateJvmMachine rcsjm = new RunClassInSeparateJvmMachine("FakeDaemon", FakeDaemonMain.class.getName(), getOurClassPath(), Collections.EMPTY_LIST, new File("."));
// override output so we can capture it
final ByteArrayOutputStream baos1 = new ByteArrayOutputStream();
rcsjm.setOutput(baos1);
rcsjm.restart();
StartedProcess startedProcess1 = rcsjm.getActiveProcess();
assertTrue(isAlive(startedProcess1.getProcess()));
waitOrTimeout(fakeDaemonCondition(baos1), Timeout.timeout(Duration.millis(10000)));
// override output so we can capture it
final ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
rcsjm.setOutput(baos2);
rcsjm.restart();
StartedProcess startedProcess2 = rcsjm.getActiveProcess();
assertTrue(isAlive(startedProcess2.getProcess()));
assertFalse(isAlive(startedProcess1.getProcess()));
assertFalse(startedProcess1.equals(startedProcess2));
waitOrTimeout(fakeDaemonCondition(baos2), Timeout.timeout(Duration.millis(10000)));
}
Aggregations