use of org.ow2.proactive.scheduler.common.exception.JobCreationException in project scheduling by ow2-proactive.
the class TestStaxJobFactory method testJobCreationAttributeOrderDefinitionGenericInformationXmlElement.
/**
* The next 3 tests are there to check that parsing a workflow XML description involving XML elements
* with more than 1 attribute (defined in any order) returns an object description with expected values
* in corresponding data structures.
*/
@Test
public void testJobCreationAttributeOrderDefinitionGenericInformationXmlElement() throws URISyntaxException, JobCreationException {
TaskFlowJob job = (TaskFlowJob) factory.createJob(getResource("job_attr_def_generic_information_xml_element.xml"));
Map<String, String> genericInformation = job.getTask("task").getGenericInformation();
assertExpectedKeyValueEntriesMatch(genericInformation);
}
use of org.ow2.proactive.scheduler.common.exception.JobCreationException in project scheduling by ow2-proactive.
the class TestStaxJobFactory method testTaskVariables.
@Test
public void testTaskVariables() throws URISyntaxException, JobCreationException {
TaskFlowJob job = (TaskFlowJob) factory.createJob(getResource("task_variables.xml"));
Map<String, TaskVariable> taskVariables = job.getTask("task").getVariables();
assertEquals(2, taskVariables.size());
TaskVariable taskVariable = taskVariables.get("name1");
assertNotNull(taskVariable);
assertEquals("name1", taskVariable.getName());
assertEquals("value1", taskVariable.getValue());
assertEquals("model1", taskVariable.getModel());
assertFalse(taskVariable.isJobInherited());
taskVariable = taskVariables.get("name2");
assertNotNull(taskVariable);
assertEquals("name2", taskVariable.getName());
assertEquals("value2", taskVariable.getValue());
assertEquals("model2", taskVariable.getModel());
assertTrue(taskVariable.isJobInherited());
}
use of org.ow2.proactive.scheduler.common.exception.JobCreationException in project scheduling by ow2-proactive.
the class TestStaxJobFactory method testHandleVariablesReplacements.
@Test
public void testHandleVariablesReplacements() throws JobCreationException {
// null replacement
Assert.assertEquals(ImmutableMap.<String, JobVariable>of("a1", new JobVariable("a1", "v1", "m1")), factory.replaceVariablesInJobVariablesMap(ImmutableMap.<String, JobVariable>of("a1", new JobVariable("a1", "v1", "m1")), null));
// replace existing variable, leave the model intact
Assert.assertEquals(ImmutableMap.<String, JobVariable>of("a1", new JobVariable("a1", "v2", "m1")), factory.replaceVariablesInJobVariablesMap(ImmutableMap.<String, JobVariable>of("a1", new JobVariable("a1", "v1", "m1")), ImmutableMap.<String, String>of("a1", "v2")));
// add new variable
Assert.assertEquals(ImmutableMap.<String, JobVariable>of("a1", new JobVariable("a1", "v1", "m1"), "a2", new JobVariable("a2", "v2")), factory.replaceVariablesInJobVariablesMap(ImmutableMap.<String, JobVariable>of("a1", new JobVariable("a1", "v1", "m1")), ImmutableMap.<String, String>of("a2", "v2")));
// reuse replacement variable in pattern and add new variable
Assert.assertEquals(ImmutableMap.<String, JobVariable>of("a1", new JobVariable("a1", "v1v2", "m1v2"), "a2", new JobVariable("a2", "v2")), factory.replaceVariablesInJobVariablesMap(ImmutableMap.<String, JobVariable>of("a1", new JobVariable("a1", "v1${a2}", "m1${a2}")), ImmutableMap.<String, String>of("a2", "v2")));
// existing variable uses another existing variable in a pattern, null replacements
Assert.assertEquals(ImmutableMap.<String, JobVariable>of("a1", new JobVariable("a1", "v1v2", "m1v2"), "a2", new JobVariable("a2", "v2")), factory.replaceVariablesInJobVariablesMap(ImmutableMap.<String, JobVariable>of("a1", new JobVariable("a1", "v1${a2}", "m1${a2}"), "a2", new JobVariable("a2", "v2")), null));
// existing variable uses another existing variable in a pattern, this other existing variable uses itself a replacement variable
Assert.assertEquals(ImmutableMap.<String, JobVariable>of("a1", new JobVariable("a1", "v1v3", "m1v3"), "a2", new JobVariable("a2", "v3", "m2v3"), "a3", new JobVariable("a3", "v3")), factory.replaceVariablesInJobVariablesMap(ImmutableMap.<String, JobVariable>of("a1", new JobVariable("a1", "v1${a2}", "m1${a2}"), "a2", new JobVariable("a2", "${a3}", "m2${a3}")), ImmutableMap.<String, String>of("a3", "v3")));
// existing variable uses a replacement variable in a pattern, this replacement variable uses itself a job variable from the workflow
Assert.assertEquals(ImmutableMap.<String, JobVariable>of("a1", new JobVariable("a1", "v1v3", "m1v3"), "a2", new JobVariable("a2", "v3"), "a3", new JobVariable("a3", "v3", "m3v3")), factory.replaceVariablesInJobVariablesMap(ImmutableMap.<String, JobVariable>of("a1", new JobVariable("a1", "v1${a2}", "m1${a2}"), "a3", new JobVariable("a3", "v3", "m3${a2}")), ImmutableMap.<String, String>of("a2", "${a3}")));
// existing variable uses a replacement variable in a pattern, but is overwritten by another replacement variable
Assert.assertEquals(ImmutableMap.<String, JobVariable>of("a1", new JobVariable("a1", "v1", "m1v2"), "a2", new JobVariable("a2", "v2")), factory.replaceVariablesInJobVariablesMap(ImmutableMap.<String, JobVariable>of("a1", new JobVariable("a1", "v1${a2}", "m1${a2}")), ImmutableMap.<String, String>of("a2", "v2", "a1", "v1")));
}
use of org.ow2.proactive.scheduler.common.exception.JobCreationException in project scheduling by ow2-proactive.
the class TestStaxJobFactory method testJobCreationAttributeOrderDefinitionParameterXmlElement.
@Test
public void testJobCreationAttributeOrderDefinitionParameterXmlElement() throws URISyntaxException, JobCreationException, IOException, ClassNotFoundException {
TaskFlowJob job = (TaskFlowJob) factory.createJob(getResource("job_attr_def_parameter_xml_element.xml"));
Map<String, Serializable> arguments = ((JavaTask) job.getTask("task")).getArguments();
assertExpectedKeyValueEntriesMatch(arguments);
}
use of org.ow2.proactive.scheduler.common.exception.JobCreationException in project scheduling by ow2-proactive.
the class InternalJobFactory method createJob.
/**
* Create a new internal job with the given job (user).
*
* @param job the user job that will be used to create the internal job.
* @return the created internal job.
* @throws JobCreationException an exception if the factory cannot create the given job.
*/
public static InternalJob createJob(Job job, Credentials cred) throws JobCreationException {
InternalJob iJob;
if (logger.isDebugEnabled()) {
logger.debug("Create job '" + job.getName() + "' - " + job.getClass().getName());
}
switch(job.getType()) {
case PARAMETER_SWEEPING:
logger.error("The type of the given job is not yet implemented !");
throw new JobCreationException("The type of the given job is not yet implemented !");
case TASKSFLOW:
iJob = createJob((TaskFlowJob) job);
break;
default:
logger.error("The type of the given job is unknown !");
throw new JobCreationException("The type of the given job is unknown !");
}
try {
// set the job common properties
iJob.setCredentials(cred);
setJobCommonProperties(job, iJob);
return iJob;
} catch (Exception e) {
logger.error("", e);
throw new InternalException("Error while creating the internalJob !", e);
}
}
Aggregations