use of org.talend.esb.sam.common.spi.EventHandler in project tesb-rt-se by Talend.
the class EventCollectorTest method testEventCollector.
@Test
public void testEventCollector() throws InterruptedException {
EventQueue queue = new EventQueue();
EventCollector eventCollector = new EventCollector();
eventCollector.setDefaultInterval(500);
eventCollector.setFilters(new ArrayList<EventFilter>());
eventCollector.getFilters().add(new StringContentFilter());
eventCollector.setHandlers(new ArrayList<EventHandler>());
eventCollector.getHandlers().add(new ContentLengthHandler());
eventCollector.setEventsPerMessageCall(2);
eventCollector.setQueue(queue);
MockService monitoringService = new MockService();
eventCollector.setMonitoringServiceClient(monitoringService);
eventCollector.init();
// Add events
queue.add(createEvent("1"));
queue.add(createEvent("2"));
queue.add(createEvent("3"));
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
// Send from Queue
// eventCollector.sendEventsFromQueue();
// eventCollector.sendEventsFromQueue();
Assert.assertEquals(2, monitoringService.receivedEvents.size());
// List<Event> events0 = monitoringService.receivedEvents.get(0);
// Assert.assertEquals(2, events0.size());
// List<Event> events1 = monitoringService.receivedEvents.get(1);
// Assert.assertEquals(1, events1.size());
}
Aggregations