Skip to content

Instantly share code, notes, and snippets.

@coderunner
Created September 12, 2011 17:04
Show Gist options
  • Select an option

  • Save coderunner/1211780 to your computer and use it in GitHub Desktop.

Select an option

Save coderunner/1211780 to your computer and use it in GitHub Desktop.

Revisions

  1. coderunner revised this gist Sep 13, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.java
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ public class TestStreamLogger
    public void setup()
    {
    stream = mock(OutputStream.class);
    logger = new StreamLogger("logger_name", stream);
    logger = new StreamLogger(LOGGER_NAME, stream);
    }

    @Test
  2. coderunner created this gist Sep 12, 2011.
    29 changes: 29 additions & 0 deletions gistfile1.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    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();
    }
    }