use of org.ow2.proactive.scheduler.common.job.factories.JobComparator in project scheduling by ow2-proactive.
the class TestXMLTransformer method transformAndCompare.
/**
* The following operations are performed:
*
* 1. xmlFile to java => job1
*
* 2. job1 = > xmlFle2
*
* 3. xmlFile2 to java => job2
*
* 4. Compare job1 and job2
*/
private void transformAndCompare(File xmlFile) throws Exception {
// xml to java => job1
TaskFlowJob job1 = (TaskFlowJob) (JobFactory.getFactory().createJob(xmlFile.getAbsolutePath()));
// job1 to xmlFile2
File xmlFile2 = folder.newFile(xmlFile.getName());
Job2XMLTransformer transformer = new Job2XMLTransformer();
transformer.job2xmlFile(job1, xmlFile2);
// xmlFile2 to job2
TaskFlowJob job2;
try {
job2 = (TaskFlowJob) (JobFactory.getFactory().createJob(xmlFile2.getAbsolutePath()));
} catch (Exception e) {
e.printStackTrace();
String message = "Could not create Job object from generated xml. \n";
message += "Generated xml content was : \n ****** " + xmlFile2.getAbsolutePath() + " ***********\n ";
message += FileUtils.readFileToString(xmlFile2);
message += "\n *************************** ";
throw new Exception(message, e);
}
// compare job1 and job2
JobComparator comparator = new JobComparator();
if (!comparator.isEqualJob(job1, job2)) {
String message = "Jobs are not equal for file " + xmlFile + "\n";
message += "Reason: " + comparator.getDifferenceMessage() + "\n";
message += "Generated xml content was : \n ****** " + xmlFile2.getAbsolutePath() + " *********** \n ";
message += FileUtils.readFileToString(xmlFile2);
message += "\n *************************** ";
Assert.fail(message);
}
}
Aggregations