-
Notifications
You must be signed in to change notification settings - Fork 3
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
amckenzie
committed
Jun 12, 2018
1 parent
dbc321e
commit e0fb6c6
Showing
14 changed files
with
158 additions
and
71 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 was deleted.
Oops, something went wrong.
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
18 changes: 18 additions & 0 deletions
18
framework-tools-replay/src/main/java/uk/gov/justice/framework/tools/replay/LoggingMdc.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,18 @@ | ||
package uk.gov.justice.framework.tools.replay; | ||
|
||
import org.slf4j.MDC; | ||
|
||
public class LoggingMdc { | ||
|
||
public void put(final String key, final String value) { | ||
MDC.put(key, value); | ||
} | ||
|
||
public void remove(final String key) { | ||
MDC.remove(key); | ||
} | ||
|
||
public void clear() { | ||
MDC.clear(); | ||
} | ||
} |
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
14 changes: 0 additions & 14 deletions
14
framework-tools-replay/src/main/resources/log4j.properties
This file was deleted.
Oops, something went wrong.
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
32 changes: 7 additions & 25 deletions
32
...y/src/test/java/uk/gov/justice/framework/tools/replay/JsonEnvelopeJdbcRepositoryTest.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
65 changes: 65 additions & 0 deletions
65
...work-tools-replay/src/test/java/uk/gov/justice/framework/tools/replay/LoggingMdcTest.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,65 @@ | ||
package uk.gov.justice.framework.tools.replay; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.CoreMatchers.nullValue; | ||
import static org.junit.Assert.assertThat; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.runners.MockitoJUnitRunner; | ||
import org.slf4j.MDC; | ||
|
||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class LoggingMdcTest { | ||
|
||
|
||
@InjectMocks | ||
private LoggingMdc loggingMdc; | ||
|
||
@Test | ||
public void shouldWrapTheMdcStaticCall() throws Exception { | ||
|
||
final String key_1 = "key_1"; | ||
final String value_1 = "value_1"; | ||
final String key_2 = "key_2"; | ||
final String value_2 = "value_2"; | ||
|
||
loggingMdc.put(key_1, value_1); | ||
loggingMdc.put(key_2, value_2); | ||
|
||
assertThat(MDC.get(key_1), is(value_1)); | ||
assertThat(MDC.get(key_2), is(value_2)); | ||
|
||
loggingMdc.remove(key_1); | ||
|
||
assertThat(MDC.get(key_1), is(nullValue())); | ||
assertThat(MDC.get(key_2), is(value_2)); | ||
|
||
loggingMdc.remove(key_2); | ||
|
||
assertThat(MDC.get(key_1), is(nullValue())); | ||
assertThat(MDC.get(key_2), is(nullValue())); | ||
} | ||
|
||
@Test | ||
public void shouldClearTheMdc() throws Exception { | ||
|
||
final String key_1 = "key_1"; | ||
final String value_1 = "value_1"; | ||
final String key_2 = "key_2"; | ||
final String value_2 = "value_2"; | ||
|
||
loggingMdc.put(key_1, value_1); | ||
loggingMdc.put(key_2, value_2); | ||
|
||
assertThat(MDC.get(key_1), is(value_1)); | ||
assertThat(MDC.get(key_2), is(value_2)); | ||
|
||
loggingMdc.clear(); | ||
|
||
assertThat(MDC.get(key_1), is(nullValue())); | ||
assertThat(MDC.get(key_2), is(nullValue())); | ||
} | ||
} |
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
Oops, something went wrong.