@Test public void testTerminate() throws Exception { ProBInstance proBInstance = mock(ProBInstance.class); BufferedReader reader = new BufferedReader(new StringReader("foo")); when(proBInstance.isShuttingDown()).thenReturn(true); Logger logger = mock(Logger.class); ConsoleListener listener = new ConsoleListener(proBInstance, reader, logger); listener.logLines(); verify(logger, never()).debug("foo"); }
@Test public void testMultiLineReadAndTerminate() throws Exception { ProBInstance proBInstance = mock(ProBInstance.class); BufferedReader reader = new BufferedReader(new StringReader("foo\nbar\ngoo")); Logger logger = mock(Logger.class); ConsoleListener listener = new ConsoleListener(proBInstance, reader, logger); when(proBInstance.isShuttingDown()).thenReturn(false, false, true); listener.logLines(); verify(logger).debug("foo"); verify(logger).debug("bar"); verifyNoMoreInteractions(logger); }