From: Alexandre Montplaisir Date: Fri, 3 Jun 2016 19:49:37 +0000 (-0400) Subject: Clear loggers at the beginning of tests, not at the end X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=1e67919e5a809aafc1ad068ad690f3f48e9d10da;p=lttng-ust-java-tests.git Clear loggers at the beginning of tests, not at the end That way the very first test will also get a clean state. Signed-off-by: Alexandre Montplaisir --- diff --git a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulLoggerHierarchyListIT.java b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulLoggerHierarchyListIT.java index 4254aaf..e53e4a7 100644 --- a/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulLoggerHierarchyListIT.java +++ b/lttng-ust-java-tests-jul/src/test/java/org/lttng/ust/agent/integration/events/JulLoggerHierarchyListIT.java @@ -25,6 +25,7 @@ import java.util.logging.Logger; import org.junit.After; import org.junit.AfterClass; +import org.junit.Before; import org.junit.BeforeClass; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -90,7 +91,23 @@ public class JulLoggerHierarchyListIT extends LoggerHierachyListITBase { } /** - * + * Test setup + */ + @SuppressWarnings("static-method") + @Before + public void setup() { + /* + * Kind of hackish, but it's the only way to ensure that loggers are + * really removed in-between tests, since LogManager does not provide a + * way to forcibly remove a logger, and it doesn't seem like it will any + * time soon, see http://bugs.java.com/view_bug.do?bug_id=4811930 + */ + LogManager.getLogManager().reset(); + System.gc(); + } + + /** + * Test cleanup */ @After public void cleanup() { @@ -111,15 +128,6 @@ public class JulLoggerHierarchyListIT extends LoggerHierachyListITBase { } childLogger = null; } - - /* - * Kind of hackish, but it's the only way to ensure that loggers are - * really removed in-between tests, since LogManager does not provide a - * way to forcibly remove a logger, and it doesn't seem like it will any - * time soon, see http://bugs.java.com/view_bug.do?bug_id=4811930 - */ - LogManager.getLogManager().reset(); - System.gc(); } // ------------------------------------------------------------------------