Skip to content

Commit

Permalink
SLF4J-389 - added a test
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Polevoy committed Jan 11, 2017
1 parent b8b881b commit 7df8afc
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion slf4j-simple/src/test/java/org/slf4j/impl/SimpleLoggerTest.java
Expand Up @@ -27,6 +27,11 @@
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

import static org.junit.Assert.*;

Expand Down Expand Up @@ -57,7 +62,7 @@ public void offLevel() {
assertEquals("off", simpleLogger.recursivelyComputeLevelString());
assertFalse(simpleLogger.isErrorEnabled());
}

@Test
public void loggerNameWithNoDots_WithLevel() {
SimpleLogger simpleLogger = new SimpleLogger("a");
Expand All @@ -82,4 +87,16 @@ public void loggerNameWithOneDot_NoSetLevel() {
assertNull(simpleLogger.recursivelyComputeLevelString());
}

@Test
public void shouldReplaceSystemStreams() {
PrintStream original = System.err;
ByteArrayOutputStream bout = new ByteArrayOutputStream();
PrintStream replacement = new PrintStream(bout);
System.setErr(replacement);
Logger l = LoggerFactory.getLogger(this.getClass());
l.info("hello");
System.setErr(original);
replacement.flush();
assertTrue(bout.toString().contains("INFO org.slf4j.impl.SimpleLoggerTest - hello"));
}
}

0 comments on commit 7df8afc

Please sign in to comment.