I thought so too... I think the problem has to do with plugging in and out of SLF4J.
Gary On Wed, Dec 3, 2014 at 9:42 AM, Ralph Goers <[email protected]> wrote: > Yes, but if MarkerTest is calling MarkerManager.clear() in the @Before > method then all the Markers should be gone. > > Ralph > > On Dec 3, 2014, at 5:47 AM, Gary Gregory <[email protected]> wrote: > > On Tue, Dec 2, 2014 at 11:45 PM, Ralph Goers <[email protected]> > wrote: > >> So clearMarkers is called both before and after? Then I don’t understand >> why the failure occurred in MarkerTest. >> > > IIRC, the problem was that LoggerTest that ran before MarkerTest left the > system in a state that caused MarkerTest to fail because the markers > MarkerTest uses were already there. > > Gary > >> >> Ralph >> >> On Dec 1, 2014, at 1:38 PM, Gary Gregory <[email protected]> wrote: >> >> Note that MarkerTest already had: >> >> @Before >> @After >> public void clearMarkers() { >> MarkerManager.clear(); >> } >> >> >> Which was not enough. >> >> The next question is: Should >> org.apache.logging.log4j.junit.InitialLoggerContext have additional clean >> ups like MarkerManager.clear() and MDC clear()? >> >> Gary >> >> On Mon, Dec 1, 2014 at 1:07 AM, Ralph Goers <[email protected]> >> wrote: >> >>> I suppose that is one way to do it. Perhaps a better way would be to >>> call MarkerManager.clear() at the beginning and end of both LoggerTest and >>> MarkerTest. >>> >>> Ralph >>> >>> > On Nov 30, 2014, at 10:57 PM, [email protected] wrote: >>> > >>> > Repository: logging-log4j2 >>> > Updated Branches: >>> > refs/heads/master ebb1c8066 -> d033a71eb >>> > >>> > >>> > Test independence. >>> > >>> > Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo >>> > Commit: >>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/d033a71e >>> > Tree: >>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/d033a71e >>> > Diff: >>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/d033a71e >>> > >>> > Branch: refs/heads/master >>> > Commit: d033a71eb0047ca35ec1582f0eab73abe3e04919 >>> > Parents: ebb1c80 >>> > Author: Gary Gregory <[email protected]> >>> > Authored: Mon Dec 1 00:57:54 2014 -0500 >>> > Committer: Gary Gregory <[email protected]> >>> > Committed: Mon Dec 1 00:57:54 2014 -0500 >>> > >>> > ---------------------------------------------------------------------- >>> > .../org/apache/logging/slf4j/MarkerTest.java | 19 >>> +++++++++++-------- >>> > 1 file changed, 11 insertions(+), 8 deletions(-) >>> > ---------------------------------------------------------------------- >>> > >>> > >>> > >>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/d033a71e/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/MarkerTest.java >>> > ---------------------------------------------------------------------- >>> > diff --git >>> a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/MarkerTest.java >>> b/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/MarkerTest.java >>> > index 1460b87..fdd0848 100644 >>> > --- >>> a/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/MarkerTest.java >>> > +++ >>> b/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/MarkerTest.java >>> > @@ -29,6 +29,9 @@ import static org.junit.Assert.*; >>> > */ >>> > public class MarkerTest { >>> > >>> > + private static final String PARENT_MARKER_NAME = >>> MarkerTest.class.getSimpleName() + "-PARENT"; >>> > + private static final String CHILD_MAKER_NAME = >>> MarkerTest.class.getSimpleName() + "-TEST"; >>> > + >>> > @Before >>> > @After >>> > public void clearMarkers() { >>> > @@ -37,17 +40,17 @@ public class MarkerTest { >>> > >>> > @Test >>> > public void testMarker() { >>> > - final org.slf4j.Marker slf4jMarker = >>> org.slf4j.MarkerFactory.getMarker("TEST"); >>> > - final org.slf4j.Marker slf4jParent = >>> org.slf4j.MarkerFactory.getMarker("PARENT"); >>> > + final org.slf4j.Marker slf4jMarker = >>> org.slf4j.MarkerFactory.getMarker(CHILD_MAKER_NAME); >>> > + final org.slf4j.Marker slf4jParent = >>> org.slf4j.MarkerFactory.getMarker(PARENT_MARKER_NAME); >>> > slf4jMarker.add(slf4jParent); >>> > - final Marker log4jParent = MarkerManager.getMarker("PARENT"); >>> > - final Marker log4jMarker = MarkerManager.getMarker("TEST"); >>> > + final Marker log4jParent = >>> MarkerManager.getMarker(PARENT_MARKER_NAME); >>> > + final Marker log4jMarker = >>> MarkerManager.getMarker(CHILD_MAKER_NAME); >>> > >>> > assertTrue("Incorrect Marker class", slf4jMarker instanceof >>> Log4jMarker); >>> > - assertTrue(String.format("TEST (log4jMarker=%s) is not an >>> instance of PARENT (log4jParent=%s) in Log4j", >>> > - log4jMarker, log4jParent), >>> log4jMarker.isInstanceOf(log4jParent)); >>> > - assertTrue(String.format("TEST (slf4jMarker=%s) is not an >>> instance of PARENT (log4jParent=%s) in SLF4J", >>> > - slf4jMarker, slf4jParent), >>> slf4jMarker.contains(slf4jParent)); >>> > + assertTrue(String.format("%s (log4jMarker=%s) is not an >>> instance of %s (log4jParent=%s) in Log4j", >>> > + CHILD_MAKER_NAME, PARENT_MARKER_NAME, log4jMarker, >>> log4jParent), log4jMarker.isInstanceOf(log4jParent)); >>> > + assertTrue(String.format("%s (slf4jMarker=%s) is not an >>> instance of %s (log4jParent=%s) in SLF4J", >>> > + CHILD_MAKER_NAME, PARENT_MARKER_NAME, slf4jMarker, >>> slf4jParent), slf4jMarker.contains(slf4jParent)); >>> > } >>> > >>> > } >>> > >>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [email protected] >>> For additional commands, e-mail: [email protected] >>> >>> >> >> >> -- >> E-Mail: [email protected] | [email protected] >> <[email protected]> >> Java Persistence with Hibernate, Second Edition >> <http://www.manning.com/bauer3/> >> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/> >> Spring Batch in Action <http://www.manning.com/templier/> >> Blog: http://garygregory.wordpress.com >> Home: http://garygregory.com/ >> Tweet! http://twitter.com/GaryGregory >> >> >> > > > -- > E-Mail: [email protected] | [email protected] > <[email protected]> > Java Persistence with Hibernate, Second Edition > <http://www.manning.com/bauer3/> > JUnit in Action, Second Edition <http://www.manning.com/tahchiev/> > Spring Batch in Action <http://www.manning.com/templier/> > Blog: http://garygregory.wordpress.com > Home: http://garygregory.com/ > Tweet! http://twitter.com/GaryGregory > > > -- E-Mail: [email protected] | [email protected] Java Persistence with Hibernate, Second Edition <http://www.manning.com/bauer3/> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/> Spring Batch in Action <http://www.manning.com/templier/> Blog: http://garygregory.wordpress.com Home: http://garygregory.com/ Tweet! http://twitter.com/GaryGregory
