use of com.axway.ats.log.autodb.events.GetCurrentTestCaseEvent in project ats-framework by Axway.
the class AtsDbLogger method getCurrentTestCaseState.
/**
* This event can not go through the regular way of sending log4j events in the case with Passive DB appenders.
* The reason is that we have to evaluate the result after the work of each passive appender and stop
* calling these appenders when the first one(the only one serving this caller) has processed the event.
*/
@SuppressWarnings("unchecked")
public TestCaseState getCurrentTestCaseState() {
GetCurrentTestCaseEvent event = new GetCurrentTestCaseEvent(ATS_DB_LOGGER_CLASS_NAME, logger);
Enumeration<Appender> appenders = Logger.getRootLogger().getAllAppenders();
while (appenders.hasMoreElements()) {
Appender appender = appenders.nextElement();
if (appender instanceof ActiveDbAppender) {
// Comes here on Test Executor side. There is just 1 Active appender
return ((ActiveDbAppender) appender).getCurrentTestCaseState(event).getTestCaseState();
} else if (appender instanceof PassiveDbAppender) {
// Comes here on Agent side. There will be 1 Passive appender per caller
// Pass the event to any existing appender.
// The correct one will return result, wrong appenders will return null.
GetCurrentTestCaseEvent resultEvent = ((PassiveDbAppender) appender).getCurrentTestCaseState(event);
if (resultEvent != null) {
// we found the right Passive appender
return resultEvent.getTestCaseState();
}
}
}
// no appropriate appender found
return null;
}
use of com.axway.ats.log.autodb.events.GetCurrentTestCaseEvent in project ats-framework by Axway.
the class AutoLogger method getCurrentTestCaseState.
/**
* This event can not go through the regular way of sending log4j events in the case with Passive DB appenders.
* The reason is that we have to evaluate the result after the work of each passive appender and stop
* calling these appenders when the first one(the only one serving this caller) has processed the event.
*/
@SuppressWarnings("unchecked")
public TestCaseState getCurrentTestCaseState() {
GetCurrentTestCaseEvent event = new GetCurrentTestCaseEvent(AUTO_LOGGER_CLASS_NAME, logger);
Enumeration<Appender> appenders = Logger.getRootLogger().getAllAppenders();
while (appenders.hasMoreElements()) {
Appender appender = appenders.nextElement();
if (appender instanceof ActiveDbAppender) {
// Comes here on Test Executor side. There is just 1 Active appender
return ((ActiveDbAppender) appender).getCurrentTestCaseState(event).getTestCaseState();
} else if (appender instanceof PassiveDbAppender) {
// Comes here on Agent side. There will be 1 Passive appender per caller
// Pass the event to any existing appender.
// The correct one will return result, wrong appenders will return null.
GetCurrentTestCaseEvent resultEvent = ((PassiveDbAppender) appender).getCurrentTestCaseState(event);
if (resultEvent != null) {
// we found the right Passive appender
return resultEvent.getTestCaseState();
}
}
}
// no appropriate appender found
return null;
}
Aggregations