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/2f10db34 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2f10db34 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2f10db34 Branch: refs/heads/LOG4J2-89 Commit: 2f10db348fe0e63f3d2b3789e944cf10689a5d65 Parents: 91f8d46 Author: rpopma <[email protected]> Authored: Wed Nov 11 23:21:26 2015 +0900 Committer: Ralph Goers <[email protected]> Committed: Fri Nov 20 17:39:22 2015 -0700 ---------------------------------------------------------------------- .../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/2f10db34/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); + // } }
