use of org.ow2.proactive.scripting.InvalidScriptException in project scheduling by ow2-proactive.
the class ForkedTaskVariablesManagerTest method testAddBindingsToScriptHandlerContainsVariables.
@Test
public void testAddBindingsToScriptHandlerContainsVariables() throws InvalidScriptException, NodeException, NoSuchFieldException, IllegalAccessException {
ScriptHandler scriptHandler = new ScriptHandler();
Map<String, Serializable> variables = new HashMap<>();
variables.put(testVariable1Key, testVariable1Value);
VariablesMap variablesMap = new VariablesMap();
variablesMap.setInheritedMap(variables);
validateThatScriptHandlerBindingsContain(scriptHandler, createTaskContext(null), variablesMap, new HashMap<String, String>(), new HashMap<String, String>(), SchedulerConstants.VARIABLES_BINDING_NAME, variablesMap);
}
use of org.ow2.proactive.scripting.InvalidScriptException in project scheduling by ow2-proactive.
the class ForkedTaskVariablesManagerTest method testAddBindingsToScriptHandlerContainsCredentials.
@Test
public void testAddBindingsToScriptHandlerContainsCredentials() throws InvalidScriptException, NodeException, NoSuchFieldException, IllegalAccessException {
Map<String, String> thirdPartyCredentials = new HashMap<>();
thirdPartyCredentials.put(testCred1Key, testCred1Value);
// Expect taskResultArray to be inside the map
validateThatScriptHandlerBindingsContain(new ScriptHandler(), createTaskContext(null), new VariablesMap(), thirdPartyCredentials, new HashMap<String, String>(), SchedulerConstants.CREDENTIALS_VARIABLE, thirdPartyCredentials);
}
use of org.ow2.proactive.scripting.InvalidScriptException in project scheduling by ow2-proactive.
the class ForkedTaskVariablesManagerTest method testAddBindingsToScriptHandlerContainsPreviousTaskResults.
@Test
public void testAddBindingsToScriptHandlerContainsPreviousTaskResults() throws InvalidScriptException, NodeException, NoSuchFieldException, IllegalAccessException {
// Create task result array
TaskResultImpl taskResult = new TaskResultImpl(TaskIdImpl.createTaskId(new JobIdImpl(jobIdValue, jobNameValue), taskNameValue, taskIdValue), new Exception("Exception"));
TaskResult[] taskResultArray = { taskResult };
// Create TaskContext with task result array
TaskContext taskContext = createTaskContext(taskResultArray);
// Expect taskResultArray to be inside the map
validateThatScriptHandlerBindingsContain(new ScriptHandler(), taskContext, new VariablesMap(), new HashMap<String, String>(), new HashMap<String, String>(), SchedulerConstants.RESULTS_VARIABLE, taskResultArray);
}
use of org.ow2.proactive.scripting.InvalidScriptException in project scheduling by ow2-proactive.
the class ForkedTaskVariablesManagerTest method testAddBindingsToScriptHandlerContainsInputURI.
@Test
public void testAddBindingsToScriptHandlerContainsInputURI() throws InvalidScriptException, NodeException, NoSuchFieldException, IllegalAccessException {
ScriptExecutableContainer scriptContainer = createScriptContainer();
TaskLauncherInitializer taskLauncherInitializer = new TaskLauncherInitializer();
taskLauncherInitializer.setForkEnvironment(new ForkEnvironment());
TaskContext taskContext = new TaskContext(scriptContainer, taskLauncherInitializer, null, new NodeDataSpacesURIs(null, null, testSetString, null, null, null), null, null);
// Expect taskResultArray to be inside the map
validateThatScriptHandlerBindingsContain(new ScriptHandler(), taskContext, new VariablesMap(), new HashMap<String, String>(), new HashMap<String, String>(), SchedulerConstants.DS_INPUT_BINDING_NAME, testSetString);
}
use of org.ow2.proactive.scripting.InvalidScriptException in project scheduling by ow2-proactive.
the class ForkedTaskVariablesManagerTest method testAddBindingsToScriptHandlerContainsSchedulerNodeClientVariable.
@Test
public void testAddBindingsToScriptHandlerContainsSchedulerNodeClientVariable() throws InvalidScriptException, NodeException, NoSuchFieldException, IllegalAccessException, KeyException, NoSuchAlgorithmException {
ScriptExecutableContainer scriptContainer = createScriptContainer();
TaskLauncherInitializer taskLauncherInitializer = new TaskLauncherInitializer();
taskLauncherInitializer.setForkEnvironment(new ForkEnvironment());
taskLauncherInitializer.setSchedulerRestUrl("http://localhost:8080/rest");
Decrypter decrypter = createCredentials(testUser, testPass);
TaskContext taskContext = new TaskContext(scriptContainer, taskLauncherInitializer, null, new NodeDataSpacesURIs(null, null, null, null, null, null), null, null, decrypter);
// variable should belong to the expected class
validateThatScriptHandlerBindingsInstanceOf(new ScriptHandler(), taskContext, new VariablesMap(), new HashMap<String, String>(), new HashMap<String, String>(), SchedulerConstants.SCHEDULER_CLIENT_BINDING_NAME, SchedulerNodeClient.class);
}
Aggregations