use of org.apache.oozie.workflow.WorkflowApp in project oozie by apache.
the class TestWorkflowJobsGetForPurgeJPAExecutor method addRecordToWfJobTable.
@Override
protected WorkflowJobBean addRecordToWfJobTable(WorkflowJob.Status jobStatus, WorkflowInstance.Status instanceStatus) throws Exception {
WorkflowApp app = new LiteWorkflowApp("testApp", "<workflow-app/>", new StartNodeDef(LiteWorkflowStoreService.LiteControlNodeHandler.class, "end")).addNode(new EndNodeDef("end", LiteWorkflowStoreService.LiteControlNodeHandler.class));
Configuration conf = new Configuration();
Path appUri = new Path(getAppPath(), "workflow.xml");
conf.set(OozieClient.APP_PATH, appUri.toString());
conf.set(OozieClient.LOG_TOKEN, "testToken");
conf.set(OozieClient.USER_NAME, getTestUser());
WorkflowJobBean wfBean = createWorkflow(app, conf, jobStatus, instanceStatus);
Timestamp startTS = new Timestamp(System.currentTimeMillis() - (3 * DAY_IN_MS));
Timestamp endTS = new Timestamp(System.currentTimeMillis() - (2 * DAY_IN_MS));
wfBean.setStartTime(DateUtils.toDate(startTS));
wfBean.setEndTime(DateUtils.toDate(endTS));
try {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
WorkflowJobInsertJPAExecutor wfInsertCmd = new WorkflowJobInsertJPAExecutor(wfBean);
jpaService.execute(wfInsertCmd);
} catch (JPAExecutorException je) {
je.printStackTrace();
fail("Unable to insert the test wf job record to table");
throw je;
}
return wfBean;
}
use of org.apache.oozie.workflow.WorkflowApp in project oozie by apache.
the class TestLiteWorkflowAppService method testSchema.
public void testSchema() throws Exception {
Services services = new Services();
try {
services.init();
Reader reader = IOUtils.getResourceAsReader("wf-schema-valid.xml", -1);
Writer writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
IOUtils.copyCharStream(reader, writer);
WorkflowAppService wps = services.get(WorkflowAppService.class);
Configuration jobConf = new XConfiguration();
jobConf.set(OozieClient.APP_PATH, getTestCaseFileUri("workflow.xml"));
jobConf.set(OozieClient.USER_NAME, getTestUser());
WorkflowApp app = wps.parseDef(jobConf);
assertNotNull(app);
assertEquals("test-wf", app.getName());
reader = IOUtils.getResourceAsReader("wf-schema-invalid.xml", -1);
writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
IOUtils.copyCharStream(reader, writer);
try {
wps.parseDef(jobConf);
fail();
} catch (WorkflowException ex) {
// nop
}
} finally {
services.destroy();
}
}
Aggregations