Search in sources :

Example 1 with ContentLengthHandler

use of org.talend.esb.sam.common.handler.impl.ContentLengthHandler 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)

Example 2 with ContentLengthHandler

use of org.talend.esb.sam.common.handler.impl.ContentLengthHandler in project tesb-rt-se by Talend.

the class ContentLengthHandlerTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    contentLengthHandler = new ContentLengthHandler();
    contentLengthHandler.setLength(40);
    event = new Event();
}
Also used : Event(org.talend.esb.sam.common.event.Event) ContentLengthHandler(org.talend.esb.sam.common.handler.impl.ContentLengthHandler)

Aggregations

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