}
}
@Test
public void testOnWorkflowJobFailureEvent() throws ParseException {
JMSJobEventListener wfEventListener = new JMSJobEventListener();
wfEventListener.init(conf);
Date startDate = DateUtils.parseDateUTC("2012-07-22T00:00Z");
Date endDate = new Date();
WorkflowJobEvent wfe = new WorkflowJobEvent("wfId1", "caId1", WorkflowJob.Status.FAILED, "user1",
"wf-app-name1", startDate, endDate);
wfe.setErrorCode("dummyErrorCode");
wfe.setErrorMessage("dummyErrorMessage");
ConnectionContext jmsContext = getConnectionContext();
try {
Session session = jmsContext.createSession(Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = jmsContext.createConsumer(session, wfEventListener.getTopic(wfe));
wfEventListener.onWorkflowJobEvent(wfe);
TextMessage message = (TextMessage) consumer.receive(5000);
WorkflowJobMessage wfFailMessage = JMSMessagingUtils.getEventMessage(message);
assertEquals(WorkflowJob.Status.FAILED, wfFailMessage.getStatus());
assertEquals(startDate, wfFailMessage.getStartTime());
assertEquals(endDate, wfFailMessage.getEndTime());
assertEquals("wfId1", wfFailMessage.getId());
assertEquals("caId1", wfFailMessage.getParentId());
assertEquals(MessageType.JOB, wfFailMessage.getMessageType());
assertEquals(AppType.WORKFLOW_JOB, wfFailMessage.getAppType());
assertEquals(EventStatus.FAILURE, wfFailMessage.getEventStatus());
assertEquals("user1", wfFailMessage.getUser());
assertEquals("wf-app-name1", wfFailMessage.getAppName());
assertEquals("dummyErrorCode", wfFailMessage.getErrorCode());
assertEquals("dummyErrorMessage", wfFailMessage.getErrorMessage());
wfEventListener.destroy();
}
catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}