Search in sources :

Example 6 with InvalidScriptException

use of org.ow2.proactive.scripting.InvalidScriptException in project scheduling by ow2-proactive.

the class TestUnauthorizedScripts method createJobSelection.

public Job createJobSelection(String selectionScriptContent) throws InvalidScriptException, UserException {
    TaskFlowJob job = new TaskFlowJob();
    job.setName(this.getClass().getSimpleName() + "_selection");
    ScriptTask taskWithSelection = new ScriptTask();
    taskWithSelection.setScript(new TaskScript(new SimpleScript("println 'Hello'", "groovy")));
    taskWithSelection.addSelectionScript(new SelectionScript(new SimpleScript(selectionScriptContent, "groovy"), true));
    job.addTask(taskWithSelection);
    return job;
}
Also used : SelectionScript(org.ow2.proactive.scripting.SelectionScript) ScriptTask(org.ow2.proactive.scheduler.common.task.ScriptTask) TaskScript(org.ow2.proactive.scripting.TaskScript) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) SimpleScript(org.ow2.proactive.scripting.SimpleScript)

Example 7 with InvalidScriptException

use of org.ow2.proactive.scripting.InvalidScriptException in project scheduling by ow2-proactive.

the class CheckEligibleTaskDescriptorScriptTest method testOnlyInternalScriptContainsAPIBinding.

@Test
public void testOnlyInternalScriptContainsAPIBinding() throws InvalidScriptException {
    Script s = scriptWithApiBindingGlobal();
    Script s2 = scriptWithoutApiBinding();
    FlowScript fs = flowScriptWithoutApiBinding();
    Mockito.when(((EligibleTaskDescriptorImpl) etd).getInternal()).thenReturn(ist);
    Mockito.when(ist.getPreScript()).thenReturn(s2);
    Mockito.when(ist.getPostScript()).thenReturn(s2);
    Mockito.when(it.getCleaningScript()).thenReturn(s2);
    Mockito.when(sec.getScript()).thenReturn(s);
    Mockito.when(fe.getEnvScript()).thenReturn(s2);
    Mockito.when(it.getFlowScript()).thenReturn(fs);
    assertTrue(new CheckEligibleTaskDescriptorScript().isTaskContainsAPIBinding(etd));
}
Also used : SimpleScript(org.ow2.proactive.scripting.SimpleScript) FlowScript(org.ow2.proactive.scheduler.common.task.flow.FlowScript) Script(org.ow2.proactive.scripting.Script) EligibleTaskDescriptorImpl(org.ow2.proactive.scheduler.descriptor.EligibleTaskDescriptorImpl) FlowScript(org.ow2.proactive.scheduler.common.task.flow.FlowScript) Test(org.junit.Test)

Example 8 with InvalidScriptException

use of org.ow2.proactive.scripting.InvalidScriptException in project scheduling by ow2-proactive.

the class CheckEligibleTaskDescriptorScriptTest method testOnlyEnvScriptContainsAPIBinding.

@Test
public void testOnlyEnvScriptContainsAPIBinding() throws InvalidScriptException {
    Script s = scriptWithApiBindingUser();
    FlowScript fs = flowScriptWithoutApiBinding();
    Script s2 = scriptWithoutApiBinding();
    Mockito.when(it.getPreScript()).thenReturn(s2);
    Mockito.when(it.getPostScript()).thenReturn(s2);
    Mockito.when(it.getCleaningScript()).thenReturn(s2);
    Mockito.when(sec.getScript()).thenReturn(s2);
    Mockito.when(fe.getEnvScript()).thenReturn(s);
    Mockito.when(it.getFlowScript()).thenReturn(fs);
    assertTrue(new CheckEligibleTaskDescriptorScript().isTaskContainsAPIBinding(etd));
}
Also used : SimpleScript(org.ow2.proactive.scripting.SimpleScript) FlowScript(org.ow2.proactive.scheduler.common.task.flow.FlowScript) Script(org.ow2.proactive.scripting.Script) FlowScript(org.ow2.proactive.scheduler.common.task.flow.FlowScript) Test(org.junit.Test)

Example 9 with InvalidScriptException

use of org.ow2.proactive.scripting.InvalidScriptException in project scheduling by ow2-proactive.

the class CheckEligibleTaskDescriptorScriptTest method testAllScriptsNull.

@Test
public void testAllScriptsNull() throws InvalidScriptException {
    Script s = null;
    FlowScript fs = null;
    Mockito.when(it.getPreScript()).thenReturn(s);
    Mockito.when(it.getPostScript()).thenReturn(s);
    Mockito.when(it.getCleaningScript()).thenReturn(s);
    Mockito.when(fe.getEnvScript()).thenReturn(s);
    Mockito.when(sec.getScript()).thenReturn(s);
    Mockito.when(it.getFlowScript()).thenReturn(fs);
    assertFalse(new CheckEligibleTaskDescriptorScript().isTaskContainsAPIBinding(etd));
}
Also used : SimpleScript(org.ow2.proactive.scripting.SimpleScript) FlowScript(org.ow2.proactive.scheduler.common.task.flow.FlowScript) Script(org.ow2.proactive.scripting.Script) FlowScript(org.ow2.proactive.scheduler.common.task.flow.FlowScript) Test(org.junit.Test)

Example 10 with InvalidScriptException

use of org.ow2.proactive.scripting.InvalidScriptException in project scheduling by ow2-proactive.

the class CheckEligibleTaskDescriptorScriptTest method testOnlyPostScriptContainsAPIBinding.

@Test
public void testOnlyPostScriptContainsAPIBinding() throws InvalidScriptException {
    Script s = scriptWithApiBindingClient();
    Script s2 = scriptWithoutApiBinding();
    FlowScript fs = flowScriptWithoutApiBinding();
    Mockito.when(it.getPreScript()).thenReturn(s2);
    Mockito.when(it.getPostScript()).thenReturn(s);
    Mockito.when(it.getCleaningScript()).thenReturn(s2);
    Mockito.when(sec.getScript()).thenReturn(s2);
    Mockito.when(fe.getEnvScript()).thenReturn(s2);
    Mockito.when(it.getFlowScript()).thenReturn(fs);
    assertTrue(new CheckEligibleTaskDescriptorScript().isTaskContainsAPIBinding(etd));
}
Also used : SimpleScript(org.ow2.proactive.scripting.SimpleScript) FlowScript(org.ow2.proactive.scheduler.common.task.flow.FlowScript) Script(org.ow2.proactive.scripting.Script) FlowScript(org.ow2.proactive.scheduler.common.task.flow.FlowScript) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)27 SimpleScript (org.ow2.proactive.scripting.SimpleScript)27 VariablesMap (org.ow2.proactive.scheduler.task.utils.VariablesMap)15 ScriptHandler (org.ow2.proactive.scripting.ScriptHandler)15 ForkEnvironment (org.ow2.proactive.scheduler.common.task.ForkEnvironment)14 ScriptExecutableContainer (org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer)14 TaskContext (org.ow2.proactive.scheduler.task.context.TaskContext)14 TaskLauncherInitializer (org.ow2.proactive.scheduler.task.TaskLauncherInitializer)12 NodeDataSpacesURIs (org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs)12 TaskScript (org.ow2.proactive.scripting.TaskScript)12 FlowScript (org.ow2.proactive.scheduler.common.task.flow.FlowScript)11 Script (org.ow2.proactive.scripting.Script)11 HashMap (java.util.HashMap)6 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)6 InternalScriptTask (org.ow2.proactive.scheduler.task.internal.InternalScriptTask)6 InvalidScriptException (org.ow2.proactive.scripting.InvalidScriptException)6 ScriptTask (org.ow2.proactive.scheduler.common.task.ScriptTask)5 File (java.io.File)4 SelectionScript (org.ow2.proactive.scripting.SelectionScript)4 Serializable (java.io.Serializable)3