예제 #1
0
 @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");
 }
예제 #2
0
 @Test
 public void testTerminateNull() throws Exception {
   ProBInstance proBInstance = mock(ProBInstance.class);
   BufferedReader reader = new BufferedReader(new StringReader(""));
   when(proBInstance.isShuttingDown()).thenReturn(true);
   Logger logger = mock(Logger.class);
   ConsoleListener listener = new ConsoleListener(proBInstance, reader, logger);
   String line = listener.readAndLog();
   assertNull(line);
   verifyNoMoreInteractions(logger);
 }
예제 #3
0
 @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);
 }