Search in sources :

Example 1 with ForkedJvmTaskExecutionCommandCreator

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);
}
Also used : ScriptResult(org.ow2.proactive.scripting.ScriptResult) ForkEnvironmentScriptResult(org.ow2.proactive.scripting.ForkEnvironmentScriptResult) ForkedJvmTaskExecutionCommandCreator(org.ow2.proactive.scheduler.task.executors.forked.env.ForkedJvmTaskExecutionCommandCreator) PrintStream(java.io.PrintStream) TaskContextVariableExtractor(org.ow2.proactive.scheduler.task.context.TaskContextVariableExtractor) TaskContext(org.ow2.proactive.scheduler.task.context.TaskContext) ForkEnvironmentScriptResult(org.ow2.proactive.scripting.ForkEnvironmentScriptResult)

Example 2 with ForkedJvmTaskExecutionCommandCreator

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);
}
Also used : ScriptResult(org.ow2.proactive.scripting.ScriptResult) JavaPrefixCommandExtractor(org.ow2.proactive.scheduler.task.executors.forked.env.command.JavaPrefixCommandExtractor)

Example 3 with ForkedJvmTaskExecutionCommandCreator

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);
    }
}
Also used : TaskContext(org.ow2.proactive.scheduler.task.context.TaskContext)

Aggregations

TaskContext (org.ow2.proactive.scheduler.task.context.TaskContext)2 ScriptResult (org.ow2.proactive.scripting.ScriptResult)2 PrintStream (java.io.PrintStream)1 TaskContextVariableExtractor (org.ow2.proactive.scheduler.task.context.TaskContextVariableExtractor)1 ForkedJvmTaskExecutionCommandCreator (org.ow2.proactive.scheduler.task.executors.forked.env.ForkedJvmTaskExecutionCommandCreator)1 JavaPrefixCommandExtractor (org.ow2.proactive.scheduler.task.executors.forked.env.command.JavaPrefixCommandExtractor)1 ForkEnvironmentScriptResult (org.ow2.proactive.scripting.ForkEnvironmentScriptResult)1