@Test
public void testEventLogging() throws Exception {
EventHandlerService ehs = _testEventHandlerService();
// job event
WorkflowJobEvent event = new WorkflowJobEvent("jobid", "parentid", WorkflowJob.Status.RUNNING, getTestUser(),
"myapp", null, null);
TestLogAppender appender = null;
Logger logger = null;
try {
appender = getTestLogAppender();
logger = Logger.getLogger(EventHandlerService.class);
logger.addAppender(appender);
logger.setLevel(Level.DEBUG);
ehs.queueEvent(event);
List<LoggingEvent> log = appender.getLog();
LoggingEvent logEntry = log.get(0);
assertEquals(Level.DEBUG, logEntry.getLevel());
assertTrue(logEntry.getMessage().toString().contains("APP[myapp] JOB[jobid] ACTION[-] Queueing event : ID: jobid"));
assertEquals("org.apache.oozie.service.EventHandlerService", logEntry.getLoggerName());
ehs.new EventWorker().run();
log = appender.getLog();
logEntry = log.get(1);
assertEquals(Level.DEBUG, logEntry.getLevel());
assertTrue(logEntry.getMessage().toString().contains("APP[myapp] JOB[jobid] ACTION[-] Processing event : ID: jobid"));
// action event
CoordinatorActionEvent event2 = new CoordinatorActionEvent("jobid2@1", "parentid",
CoordinatorAction.Status.WAITING, getTestUser(), "myapp", null, null, null);
ehs.queueEvent(event2);
log = appender.getLog();
logEntry = log.get(2);
assertTrue(logEntry.getMessage().toString().contains("APP[myapp] JOB[jobid2] ACTION[jobid2@1] Queueing event : ID: jobid2@1"));
WorkflowJobEvent event3 = new WorkflowJobEvent("jobid-other", "parentid", WorkflowJob.Status.RUNNING, getTestUser(),
"myapp-other", null, null);
ehs.queueEvent(event3);
log = appender.getLog();
logEntry = log.get(3);