Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
73 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
slf4j-simple/src/main/java/org/slf4j/simple/DoubleInitializationPitfallTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.slf4j.simple; | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
import static org.junit.Assert.fail; | ||
|
||
import org.junit.Test; | ||
import org.slf4j.ILoggerFactory; | ||
import org.slf4j.LoggerFactory; | ||
import org.slf4j.MDC; | ||
import org.slf4j.MarkerFactory; | ||
|
||
public class DoubleInitializationPitfallTest { | ||
|
||
|
||
@Test | ||
public void verifyImpactOfMarkerFactory() { | ||
ILoggerFactory firstFactory = LoggerFactory.getILoggerFactory(); | ||
MarkerFactory.getMarker("DOUBLE_INIT"); | ||
ILoggerFactory secondFactory = LoggerFactory.getILoggerFactory(); | ||
|
||
if(firstFactory != secondFactory) { | ||
fail("MarkerFactory.getMarker causes multiple provider initialization"); | ||
} | ||
} | ||
|
||
@Test | ||
public void verifyImpactOfMDC() { | ||
ILoggerFactory firstFactory = LoggerFactory.getILoggerFactory(); | ||
MDC.put("DoubleInitializationPitfallTest", "a"); | ||
ILoggerFactory secondFactory = LoggerFactory.getILoggerFactory(); | ||
|
||
if(firstFactory != secondFactory) { | ||
fail("MarkerFactory.getMarker causes multiple provider initialization"); | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shouldn't this file be in src/test instead of src/main?