use of com.axway.ats.log.autodb.events.DeleteTestCaseEvent in project ats-framework by Axway.
the class ActiveDbAppender method append.
/* (non-Javadoc)
* @see org.apache.log4j.AppenderSkeleton#append(org.apache.log4j.spi.LoggingEvent)
*/
@Override
protected void append(LoggingEvent event) {
// All events from all threads come into here
long eventTimestamp;
if (event instanceof AbstractLoggingEvent) {
eventTimestamp = ((AbstractLoggingEvent) event).getTimestamp();
} else {
eventTimestamp = System.currentTimeMillis();
}
LogEventRequest packedEvent = new // Remember which thread this event belongs to
LogEventRequest(// Remember which thread this event belongs to
Thread.currentThread().getName(), event, // Remember the event time
eventTimestamp);
if (event instanceof AbstractLoggingEvent) {
AbstractLoggingEvent dbLoggingEvent = (AbstractLoggingEvent) event;
switch(dbLoggingEvent.getEventType()) {
case START_TEST_CASE:
{
// on Test Executor side we block until the test case start is committed in the DB
waitForEventToBeExecuted(packedEvent, dbLoggingEvent, true);
// remember the test case id, which we will later pass to ATS agent
testCaseState.setTestcaseId(eventProcessor.getTestCaseId());
//this event has already been through the queue
return;
}
case END_TEST_CASE:
{
// clear test case id
testCaseState.clearTestcaseId();
// now pass the event to the queue
break;
}
case GET_CURRENT_TEST_CASE_STATE:
{
// get current test case id which will be passed to ATS agent
((GetCurrentTestCaseEvent) event).setTestCaseState(testCaseState);
//this event should not go through the queue
return;
}
case START_RUN:
/* We synchronize the run start:
* Here we make sure we are able to connect to the log DB.
* We also check the integrity of the DB schema.
* If we fail here, it does not make sense to run tests at all
*/
System.out.println(TimeUtils.getFormattedDateTillMilliseconds() + "*** ATS *** Waiting for " + event.getClass().getSimpleName() + " event completion");
waitForEventToBeExecuted(packedEvent, dbLoggingEvent, false);
//this event has already been through the queue
return;
case END_RUN:
{
/* We synchronize the run end.
* This way if there are remaining log events in the Test Executor's queue,
* the JVM will not be shutdown prior to committing all events in the DB, as
* the END_RUN event is the last one in the queue
*/
System.out.println(TimeUtils.getFormattedDateTillMilliseconds() + "*** ATS *** Waiting for " + event.getClass().getSimpleName() + " event completion");
waitForEventToBeExecuted(packedEvent, dbLoggingEvent, true);
//this event has already been through the queue
return;
}
case DELETE_TEST_CASE:
{
// tell the thread on the other side of the queue, that this test case is to be deleted
// on first chance
eventProcessor.requestTestcaseDeletion(((DeleteTestCaseEvent) dbLoggingEvent).getTestCaseId());
// this event is not going through the queue
return;
}
default:
// do nothing about this event
break;
}
}
passEventToLoggerQueue(packedEvent);
}
Aggregations