Example usage for org.apache.commons.exec Executor getProcessDestroyer

List of usage examples for org.apache.commons.exec Executor getProcessDestroyer

Introduction

In this page you can find the example usage for org.apache.commons.exec Executor getProcessDestroyer.

Prototype

ProcessDestroyer getProcessDestroyer();

Source Link

Document

Set the handler for cleanup of started processes if the main process is going to terminate.

Usage

From source file:ch.ivyteam.ivy.maven.TestStartEngine.java

@Test
public void testKillEngineOnVmExit() throws Exception {
    StartTestEngineMojo mojo = rule.getMojo();
    Executor startedProcess = null;
    try {/*from  w  w w  . java 2 s  .com*/
        startedProcess = mojo.startEngine();
        assertThat(startedProcess.getProcessDestroyer()).isInstanceOf(ShutdownHookProcessDestroyer.class);
        ShutdownHookProcessDestroyer jvmShutdownHoock = (ShutdownHookProcessDestroyer) startedProcess
                .getProcessDestroyer();
        assertThat(jvmShutdownHoock.size()).as("One started engine process must be killed on VM end.")
                .isEqualTo(1);
    } finally {
        kill(startedProcess);
    }
}