Use a ThreadContextRule to clean up tests. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/0277dd90 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/0277dd90 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/0277dd90
Branch: refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure Commit: 0277dd902577becd5daf2ba6685f8c818ae9eec7 Parents: aad314e Author: Gary Gregory <ggreg...@apache.org> Authored: Mon Aug 15 13:15:53 2016 -0700 Committer: Gary Gregory <ggreg...@apache.org> Committed: Mon Aug 15 13:15:53 2016 -0700 ---------------------------------------------------------------------- .../ContextStackJsonAttributeConverterTest.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0277dd90/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextStackJsonAttributeConverterTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextStackJsonAttributeConverterTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextStackJsonAttributeConverterTest.java index 98eca8b..af55666 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextStackJsonAttributeConverterTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextStackJsonAttributeConverterTest.java @@ -16,32 +16,32 @@ */ package org.apache.logging.log4j.core.appender.db.jpa.converter; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + import java.util.Arrays; import org.apache.logging.log4j.ThreadContext; +import org.apache.logging.log4j.junit.ThreadContextStackRule; import org.apache.logging.log4j.spi.MutableThreadContextStack; -import org.junit.After; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; -import static org.junit.Assert.*; - public class ContextStackJsonAttributeConverterTest { private ContextStackJsonAttributeConverter converter; + @Rule + public final ThreadContextStackRule threadContextRule = new ThreadContextStackRule(); + @Before public void setUp() { this.converter = new ContextStackJsonAttributeConverter(); } - @After - public void tearDown() { - - } - @Test public void testConvert01() { - ThreadContext.clearStack(); final ThreadContext.ContextStack stack = new MutableThreadContextStack( Arrays.asList("value1", "another2")); @@ -59,7 +59,6 @@ public class ContextStackJsonAttributeConverterTest { @Test public void testConvert02() { - ThreadContext.clearStack(); final ThreadContext.ContextStack stack = new MutableThreadContextStack( Arrays.asList("key1", "value2", "my3"));