use of org.apache.commons.exec.Executor in project project-build-plugin by axonivy.
the class EngineControl method start.
public Executor start() throws Exception {
CommandLine startCmd = toEngineCommand(Command.start);
context.log.info("Start Axon Ivy Engine in folder: " + context.engineDirectory);
Executor executor = createEngineExecutor();
executor.setStreamHandler(createEngineLogStreamForwarder(logLine -> findStartEngineUrl(logLine)));
executor.setWatchdog(new ExecuteWatchdog(ExecuteWatchdog.INFINITE_TIMEOUT));
executor.setProcessDestroyer(new ShutdownHookProcessDestroyer());
executor.execute(startCmd, asynchExecutionHandler());
waitForEngineStart(executor);
return executor;
}
use of org.apache.commons.exec.Executor in project project-build-plugin by axonivy.
the class TestDeployToRunningEngine method deployIarRemoteAndAssert.
private void deployIarRemoteAndAssert() throws Exception, MojoExecutionException, MojoFailureException {
deployMojo.deployToEngineApplication = "test";
deployMojo.deployMethod = DeployMethod.HTTP;
Executor startedProcess = null;
try {
System.setOut(originalOut);
startedProcess = mojo.startEngine();
deployMojo.deployEngineUrl = (String) rule.project.getProperties().get(EngineControl.Property.TEST_ENGINE_URL);
System.setOut(new PrintStream(outContent));
deployMojo.execute();
assertThat(outContent.toString()).contains("Start deploying project(s) of file").contains("Application: test").contains("Deploying users ...").doesNotContain("deployDirectory is set but will not be used for HTTP Deployment.");
} finally {
kill(startedProcess);
}
}
use of org.apache.commons.exec.Executor in project project-build-plugin by axonivy.
the class TestDeployToRunningEngine method canDeployIar.
@Test
public void canDeployIar() throws Exception {
deployMojo.deployToEngineApplication = "Portal";
File deployedIar = getTarget(deployMojo.deployFile, deployMojo);
File deployedIarFlagFile = new File(deployedIar.getParent(), deployedIar.getName() + ".deployed");
File deployedIarLogFile = new File(deployedIar.getParent(), deployedIar.getName() + ".deploymentLog");
Executor startedProcess = null;
try {
startedProcess = mojo.startEngine();
deployMojo.execute();
assertThat(deployedIar).doesNotExist();
assertThat(deployedIarFlagFile).exists();
assertThat(deployedIarLogFile).exists();
assertThat(linesOf(deployedIarLogFile)).haveAtLeast(1, new Condition<>(s -> s.contains("Deploying users ..."), ""));
} finally {
kill(startedProcess);
}
}
use of org.apache.commons.exec.Executor in project project-build-plugin by axonivy.
the class TestStartEngine method startEngine_targetDirectoryNotClean.
@Test
public void startEngine_targetDirectoryNotClean() throws Exception {
LogCollector log = new LogCollector();
StartTestEngineMojo mojo = rule.getMojo();
mojo.setLog(log);
Executor startedProcess = null;
try {
File engineDirTarget = mojo.getEngineDir(mojo.project);
assertThat(engineDirTarget.toString()).contains("/target/ivyEngine");
assertThat(engineDirTarget).doesNotExist();
assertThat(log.getWarnings().toString()).doesNotContain("Skipping copy");
startedProcess = mojo.startEngine();
assertThat(engineDirTarget).exists();
assertThat(log.getWarnings().toString()).doesNotContain("Skipping copy");
kill(startedProcess);
startedProcess = mojo.startEngine();
assertThat(engineDirTarget).exists();
assertThat(log.getWarnings().toString()).contains("Skipping copy");
} finally {
kill(startedProcess);
}
}
use of org.apache.commons.exec.Executor in project oxCore by GluuFederation.
the class ProcessHelper method executeProgram.
/**
* @param printJobTimeout
* the printJobTimeout (ms) before the watchdog terminates the print
* process
* @param printInBackground
* printing done in the background or blocking
* @param streamHandler
* @return a print result handler (implementing a future)
* @throws IOException
* the test failed
*/
public static PrintResultHandler executeProgram(CommandLine commandLine, String workingDirectory, long printJobTimeout, boolean printInBackground, int successExitValue, ExecuteStreamHandler streamHandler) throws IOException {
ExecuteWatchdog watchdog = null;
PrintResultHandler resultHandler;
// Create the executor and consider the successExitValue as success
Executor executor = new DefaultExecutor();
executor.setExitValue(successExitValue);
if (StringHelper.isNotEmpty(workingDirectory)) {
executor.setWorkingDirectory(new File(workingDirectory));
}
// Redirect streams if needed
if (streamHandler != null) {
executor.setStreamHandler(streamHandler);
}
// Create a watchdog if requested
if (printJobTimeout > 0) {
watchdog = new ExecuteWatchdog(printJobTimeout);
executor.setWatchdog(watchdog);
}
// Pass a "ExecuteResultHandler" when doing background printing
if (printInBackground) {
LOG.debug(String.format("Executing non-blocking process %s", commandLine.toString()));
resultHandler = new PrintResultHandler(watchdog);
executor.execute(commandLine, resultHandler);
} else {
LOG.debug(String.format("Executing blocking process %s", commandLine.toString()));
successExitValue = executor.execute(commandLine);
resultHandler = new PrintResultHandler(successExitValue);
}
return resultHandler;
}
Aggregations