Search in sources :

Example 1 with StringContentFilter

use of org.talend.esb.sam.common.filter.impl.StringContentFilter 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());
}
Also used : StringContentFilter(org.talend.esb.sam.common.filter.impl.StringContentFilter) EventHandler(org.talend.esb.sam.common.spi.EventHandler) EventFilter(org.talend.esb.sam.common.spi.EventFilter) EventQueue(org.talend.esb.sam.agent.queue.EventQueue) ContentLengthHandler(org.talend.esb.sam.common.handler.impl.ContentLengthHandler) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 EventQueue (org.talend.esb.sam.agent.queue.EventQueue)1 StringContentFilter (org.talend.esb.sam.common.filter.impl.StringContentFilter)1 ContentLengthHandler (org.talend.esb.sam.common.handler.impl.ContentLengthHandler)1 EventFilter (org.talend.esb.sam.common.spi.EventFilter)1 EventHandler (org.talend.esb.sam.common.spi.EventHandler)1