only define one @Test method per test class with Async Loggers to prevent spurious failures
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/fa8b1624 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/fa8b1624 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/fa8b1624 Branch: refs/heads/LOG4J-1181 Commit: fa8b16240f10bdb0923d8662fff48f7f6a882712 Parents: 65adfab Author: rpopma <[email protected]> Authored: Wed Nov 11 23:21:26 2015 +0900 Committer: rpopma <[email protected]> Committed: Wed Nov 11 23:21:26 2015 +0900 ---------------------------------------------------------------------- .../logging/log4j/core/async/AsyncLoggerTest.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/fa8b1624/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTest.java index 319d37e..991c580 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTest.java @@ -52,7 +52,10 @@ public class AsyncLoggerTest { final File file = new File("target", "AsyncLoggerTest.log"); // System.out.println(f.getAbsolutePath()); file.delete(); + final AsyncLogger log = (AsyncLogger) LogManager.getLogger("com.foo.Bar"); + assertTrue(log.getNanoClock() instanceof DummyNanoClock); + final String msg = "Async logger msg"; log.info(msg, new InternalError("this is not a real error")); CoreLoggerContexts.stopLoggerContext(false, file); // stop async thread @@ -67,11 +70,12 @@ public class AsyncLoggerTest { final String location = "testAsyncLogWritesToLog"; assertTrue("no location", !line1.contains(location)); } - - @Test - public void testNanoClockInitiallyDummy() { - final AsyncLogger log = (AsyncLogger) LogManager.getLogger("com.foo.Bar"); - assertTrue(log.getNanoClock() instanceof DummyNanoClock); - } + + // NOTE: only define one @Test method per test class with Async Loggers to prevent spurious failures + // @Test + // public void testNanoClockInitiallyDummy() { + // final AsyncLogger log = (AsyncLogger) LogManager.getLogger("com.foo.Bar"); + // assertTrue(log.getNanoClock() instanceof DummyNanoClock); + // } }
