CollectingLogOutputStream extends LogOutputStream { public String getAllLinesAsString() { Lock lock = new ReentrantLock(); lock.lock(); String allTheLines = StringUtils.join(this.lines, "\n"); lock.unlock(); return allTheLines; }  String getAllLinesAsString(); List<String> getLastNLines(int n);  }
@Test public void testGetAllLinesAsString() { CollectingLogOutputStream instance = new CollectingLogOutputStream(); instance.processLine("add a line of funky output", 1); instance.processLine("add another line of groovy output", 2); String output = instance.getAllLinesAsString(); assertTrue("output does not match", output.contains("funky") && output.contains("groovy")); }