Ejemplo n.º 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");
 }
Ejemplo n.º 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");
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }