use of org.ow2.proactive.scheduler.task.executors.forked.env.ForkedJvmTaskExecutionCommandCreator in project scheduling by ow2-proactive.
the class ForkedProcessBuilderCreatorTest method setMocks.
private void setMocks(ForkedProcessBuilderCreator forkedProcessBuilderCreator) throws Exception {
ForkedJvmTaskExecutionCommandCreator forkedJvmTaskExecutionCommandCreator = mock(ForkedJvmTaskExecutionCommandCreator.class);
TaskContextVariableExtractor taskContextVariableExtractor = mock(TaskContextVariableExtractor.class);
ForkEnvironmentScriptExecutor forkEnvironmentScriptExecutor = mock(ForkEnvironmentScriptExecutor.class);
given(forkedJvmTaskExecutionCommandCreator.createForkedJvmTaskExecutionCommand(any(TaskContext.class), any(ScriptResult.class), any(String.class))).willReturn(Arrays.asList(forkEnJavaCommandString));
given(taskContextVariableExtractor.extractVariablesThirdPartyCredentialsAndSystemEnvironmentVariables(any(TaskContext.class))).willReturn(taskContextExtractedVariables);
given(forkEnvironmentScriptExecutor.executeForkEnvironmentScript(any(TaskContext.class), any(PrintStream.class), any(PrintStream.class))).willReturn(new ScriptResult<ForkEnvironmentScriptResult>(new ForkEnvironmentScriptResult()));
setPrivateField(ForkedProcessBuilderCreator.class.getDeclaredField("forkedJvmTaskExecutionCommandCreator"), forkedProcessBuilderCreator, forkedJvmTaskExecutionCommandCreator);
setPrivateField(ForkedProcessBuilderCreator.class.getDeclaredField("taskContextVariableExtractor"), forkedProcessBuilderCreator, taskContextVariableExtractor);
setPrivateField(ForkedProcessBuilderCreator.class.getDeclaredField("forkEnvironmentScriptExecutor"), forkedProcessBuilderCreator, forkEnvironmentScriptExecutor);
}
use of org.ow2.proactive.scheduler.task.executors.forked.env.ForkedJvmTaskExecutionCommandCreator in project scheduling by ow2-proactive.
the class ForkedJvmTaskExecutionCommandCreatorTest method replaceJavaPrefixCommandCreatorWithMock.
/**
* Replaces the java prefix command creator service with a mock
*
* @param forkedJvmTaskExecutionCommandCreator Instance which will have the service replaced.
* @throws IllegalAccessException
* @throws NoSuchFieldException
*/
private void replaceJavaPrefixCommandCreatorWithMock(ForkedJvmTaskExecutionCommandCreator forkedJvmTaskExecutionCommandCreator) throws IllegalAccessException, NoSuchFieldException {
JavaPrefixCommandExtractor javaPrefixCommandExtractor = mock(JavaPrefixCommandExtractor.class);
given(javaPrefixCommandExtractor.extractJavaPrefixCommandToCommandListFromScriptResult(any(ScriptResult.class))).willReturn(Arrays.asList(testPreJaveCommandString));
setPrivateField(ForkedJvmTaskExecutionCommandCreator.class.getDeclaredField("javaPrefixCommandExtractor"), forkedJvmTaskExecutionCommandCreator, javaPrefixCommandExtractor);
}
use of org.ow2.proactive.scheduler.task.executors.forked.env.ForkedJvmTaskExecutionCommandCreator in project scheduling by ow2-proactive.
the class ForkedJvmTaskExecutionCommandCreatorTest method javaCommandContains.
private void javaCommandContains(List<String> stringsContained, ForkEnvironment forkEnvironment) throws Exception {
ForkedJvmTaskExecutionCommandCreator forkedJvmTaskExecutionCommandCreator = new ForkedJvmTaskExecutionCommandCreator();
replaceJavaPrefixCommandCreatorWithMock(forkedJvmTaskExecutionCommandCreator);
TaskContext taskContext = createTaskContext();
taskContext.getInitializer().setForkEnvironment(forkEnvironment);
List<String> containsJavaHome = forkedJvmTaskExecutionCommandCreator.createForkedJvmTaskExecutionCommand(taskContext, null, serializedContextAbsolutePath);
for (String insideJavaCommand : stringsContained) {
assertThatListHasAtLeastOneStringWhichContains(containsJavaHome, insideJavaCommand);
}
}
Aggregations