Пример #1
0
 @Test
 public void testSingleLineRead() throws Exception {
   ProBInstance proBInstance = mock(ProBInstance.class);
   BufferedReader reader = new BufferedReader(new StringReader("foo"));
   Logger logger = mock(Logger.class);
   ConsoleListener listener = new ConsoleListener(proBInstance, reader, logger);
   String line = listener.readAndLog();
   assertEquals("foo", line);
   verify(logger).debug("foo");
 }
Пример #2
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");
 }
Пример #3
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);
 }
Пример #4
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);
 }