add quick test variant to validate presence of mdc between threads

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1090318 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Tully 2011-04-08 16:16:27 +00:00
parent 15de238fd6
commit 2c27e5edf2
1 changed files with 7 additions and 0 deletions

View File

@ -34,6 +34,7 @@ import org.apache.log4j.spi.LoggingEvent;
public class AMQ2902Test extends TestCase {
final AtomicBoolean gotExceptionInLog = new AtomicBoolean(Boolean.FALSE);
final AtomicBoolean failedToFindMDC = new AtomicBoolean(Boolean.FALSE);
Appender appender = new Appender() {
public void addFilter(Filter newFilter) {
@ -54,6 +55,9 @@ public class AMQ2902Test extends TestCase {
&& event.getThrowableInformation().getThrowable() instanceof TransportDisposedIOException) {
gotExceptionInLog.set(Boolean.TRUE);
}
if (event.getMDC("activemq.broker") == null) {
failedToFindMDC.set(Boolean.TRUE);
}
return;
}
@ -101,12 +105,15 @@ public class AMQ2902Test extends TestCase {
public void setUp() throws Exception {
gotExceptionInLog.set(Boolean.FALSE);
failedToFindMDC.set(Boolean.FALSE);
Logger.getRootLogger().addAppender(appender);
Logger.getLogger(TransportConnection.class.getName() + ".Transport").setLevel(Level.DEBUG);
Logger.getLogger(TransportConnection.class.getName()).setLevel(Level.DEBUG);
}
public void tearDown() throws Exception {
Logger.getRootLogger().removeAppender(appender);
assertFalse("got unexpected ex in log on graceful close", gotExceptionInLog.get());
assertFalse("MDC is there", failedToFindMDC.get());
}
}