Created
September 12, 2011 17:04
-
-
Save coderunner/1211780 to your computer and use it in GitHub Desktop.
test stream logger
This file contains hidden or 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
| public class TestStreamLogger | |
| { | |
| private static final String LOGGER_NAME = "logger_name"; | |
| private static final Level LEVEL = Level.INFO; | |
| private static final String MESSAGE = "message"; | |
| private StreamLogger logger; | |
| private OutputStream stream; | |
| @Before | |
| public void setup() | |
| { | |
| stream = mock(OutputStream.class); | |
| logger = new StreamLogger(LOGGER_NAME, stream); | |
| } | |
| @Test | |
| public void shouldWriteFormattedMesssageToStream() throws Exception | |
| { | |
| logger.log(Level.INFO, MESSAGE); | |
| verify(stream).write((LOGGER_NAME +" - " + LEVEL + " : " + MESSAGE).getBytes()); | |
| } | |
| @Test | |
| public void shouldCloseStream() throws Exception | |
| { | |
| logger.close(); | |
| verify(stream).close(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment