@Test(timeout = 1000) public void testTwoLines() { Log mockLog = EasyMock.createStrictMock(Log.class); mockLog.info("Two peas in a bucket."); mockLog.info("Big ham ham ham."); EasyMock.expectLastCall(); EasyMock.replay(mockLog); InputStream in = new ByteArrayInputStream("Two peas in a bucket.\nBig ham ham ham.\n".getBytes()); StreamLogger logger = new StreamLogger(in, mockLog); logger.run(); EasyMock.verify(mockLog); }
@Override public void run() { String line; try { while ((line = bufferedReader.readLine()) != null) { log.info(line); } } catch (IOException e) { throw new TaskException("Exception while intercepting stream.", e); } IOUtils.closeQuietly(bufferedReader); IOUtils.closeQuietly(inputStreamReader); }
StreamLogger implements Runnable { @Override public void run() { String line; try { while ((line = bufferedReader.readLine()) != null) { log.info(line); } } catch (IOException e) { throw new TaskException("Exception while intercepting stream.", e); } IOUtils.closeQuietly(bufferedReader); IOUtils.closeQuietly(inputStreamReader); } }
StreamLogger implements Runnable { @Override public void run() { String line; try { while ((line = bufferedReader.readLine()) != null) { log.info(line); } } catch (IOException e) { throw new TaskException("Exception while intercepting stream.", e); } IOUtils.closeQuietly(bufferedReader); IOUtils.closeQuietly(inputStreamReader); } StreamLogger(InputStream in, Log log); }
StreamLogger implements Runnable { @Override public void run() { String line; try { while ((line = bufferedReader.readLine()) != null) { log.info(line); } } catch (IOException e) { throw new TaskException("Exception while intercepting stream.", e); } IOUtils.closeQuietly(bufferedReader); IOUtils.closeQuietly(inputStreamReader); } StreamLogger(InputStream in, Log log); @Override void run(); }
StreamLogger implements Runnable { @Override public void run() { String line; try { while ((line = bufferedReader.readLine()) != null) { log.info(line); } } catch (IOException e) { throw new TaskException("Exception while intercepting stream.", e); } IOUtils.closeQuietly(bufferedReader); IOUtils.closeQuietly(inputStreamReader); } StreamLogger(InputStream in, Log log); @Override void run();  }