use of org.apache.karaf.event.command.EventTailCommand in project karaf by apache.
the class EventTailCommandTest method testTail.
@Test
public void testTail() throws Exception {
EventTailCommand tail = new EventTailCommand();
tail.session = mock(Session.class);
tail.collector = new EventCollector();
PrintStream out = System.out;
expect(tail.session.getConsole()).andReturn(out);
exception = null;
replay(tail.session);
ExecutorService executor = Executors.newSingleThreadExecutor();
executor.execute(() -> {
try {
tail.execute();
} catch (Exception e) {
exception = e;
}
});
tail.collector.handleEvent(event());
Thread.sleep(200);
// Will interrupt the tail
executor.shutdownNow();
executor.awaitTermination(10, TimeUnit.SECONDS);
if (exception != null) {
throw exception;
}
verify(tail.session);
}
Aggregations