Disable logging temporarily when running testRegistrationAfterShutdown2
This commit is contained in:
parent
d53f7595d3
commit
0d70ba4938
@ -15,12 +15,19 @@
|
|||||||
*/
|
*/
|
||||||
package io.netty.channel;
|
package io.netty.channel;
|
||||||
|
|
||||||
|
import ch.qos.logback.classic.Logger;
|
||||||
|
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||||
|
import ch.qos.logback.core.Appender;
|
||||||
import io.netty.channel.local.LocalChannel;
|
import io.netty.channel.local.LocalChannel;
|
||||||
import io.netty.util.concurrent.EventExecutor;
|
import io.netty.util.concurrent.EventExecutor;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
@ -343,6 +350,16 @@ public class SingleThreadEventLoopTest {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Disable logging temporarily.
|
||||||
|
Logger root = (Logger) LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
|
||||||
|
List<Appender<ILoggingEvent>> appenders = new ArrayList<Appender<ILoggingEvent>>();
|
||||||
|
for (Iterator<Appender<ILoggingEvent>> i = root.iteratorForAppenders(); i.hasNext();) {
|
||||||
|
Appender<ILoggingEvent> a = i.next();
|
||||||
|
appenders.add(a);
|
||||||
|
root.detachAppender(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
ch.unsafe().register(promise);
|
ch.unsafe().register(promise);
|
||||||
promise.awaitUninterruptibly();
|
promise.awaitUninterruptibly();
|
||||||
assertFalse(promise.isSuccess());
|
assertFalse(promise.isSuccess());
|
||||||
@ -350,6 +367,12 @@ public class SingleThreadEventLoopTest {
|
|||||||
|
|
||||||
// Ensure the listener was notified.
|
// Ensure the listener was notified.
|
||||||
assertFalse(latch.await(1, TimeUnit.SECONDS));
|
assertFalse(latch.await(1, TimeUnit.SECONDS));
|
||||||
|
assertFalse(ch.isOpen());
|
||||||
|
} finally {
|
||||||
|
for (Appender<ILoggingEvent> a: appenders) {
|
||||||
|
root.addAppender(a);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 5000)
|
@Test(timeout = 5000)
|
||||||
|
Loading…
Reference in New Issue
Block a user