use of org.apache.karaf.event.service.EventCollector 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);
}
use of org.apache.karaf.event.service.EventCollector in project karaf by apache.
the class EventDisplayCommandTest method testExecute.
@Test
public void testExecute() throws Exception {
IMocksControl c = createControl();
EventDisplayCommand display = new EventDisplayCommand();
display.session = c.createMock(Session.class);
expect(display.session.getConsole()).andReturn(System.out);
display.collector = new EventCollector();
display.collector.handleEvent(new Event("myTopic", new HashMap<>()));
c.replay();
display.execute();
c.verify();
}
Aggregations