@Test
public void testStreamLogger() throws InterruptedException {

    final List<String> lines = Lists.newCopyOnWriteArrayList();
    final byte[] bytes = "line1\nline2\nline3".getBytes(Charsets.UTF_8);
    ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
    final StreamLogger logger = new StreamLogger(inputStream, LOG, MarkerFactory.getMarker("test")) {
        @Override
        protected void log(Logger logger, Marker marker, String line) {
            logger.info(marker, line);  /* just for visual inspection */
            lines.add(line);
        }
    };
    logger.start();
    logger.join();
    assertThat(lines).contains("line1", "line2", "line3");
}