assertEquals(testThreads.length * TestLoggingThread.STOP_WATCH_COUNT, totalCount);
}
public void testOverflowHandling() throws Exception {
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
Logger logger = lc.getLogger("AppenderTest.overflowTest");
AsyncCoalescingStatisticsAppender appender = new AsyncCoalescingStatisticsAppender();
appender.setName("overflowTestAppender");
appender.setTimeSlice(1000);
appender.setQueueSize(2); //set low queue size so we overflow
logger.addAppender(appender);
logger.setAdditive(false);
logger.setLevel(Level.INFO);
appender.start();
for (int i = 0; i < 1000; i++) {
StopWatch stopWatch = new StopWatch("testOverflow");
Math.random(); //this should happen super fast, faster than the appender's Dispatcher thread can drain
logger.info(stopWatch.stop());
}
//again close the appender
appender.stop();
assertTrue("Expected some stop watch messages to get discarded", appender.getNumDiscardedMessages() > 0);