Skip to content

Commit 87c5310

Browse files
JavaLogFactory Side Effect Management
System err is changed to a null impl in the test. Updating to restore the original value.
1 parent 020410c commit 87c5310

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/test/java/org/owasp/esapi/logging/java/JavaLogFactoryTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void write(int b) throws IOException {
6767
};
6868

6969
ArgumentCaptor<Object> stdErrOut = ArgumentCaptor.forClass(Object.class);
70-
70+
PrintStream orig = System.err;
7171
try (PrintStream errPrinter = new PrintStream(nullOutputStream)) {
7272
PrintStream spyPrinter = PowerMockito.spy(errPrinter);
7373
Mockito.doCallRealMethod().when(spyPrinter).print(stdErrOut.capture());
@@ -80,7 +80,10 @@ public void write(int b) throws IOException {
8080
IOException actual = (IOException) writeData;
8181
assertEquals(originException, actual.getCause());
8282
assertEquals("Failed to load esapi-java-logging.properties.", actual.getMessage());
83+
} finally {
84+
System.setErr(orig);
8385
}
86+
8487
}
8588

8689
@Test

0 commit comments

Comments
 (0)