Search in sources :

Example 1 with Event

use of com.adaptris.core.Event in project interlok by adaptris.

the class ExampleEventHandlerCase method testSendMultipleEvent.

@Test
public void testSendMultipleEvent() throws Exception {
    int count = 10;
    Event e = EventFactory.create(AdapterCloseEvent.class);
    T eh = applyConfiguration(newEventHandler(getName()));
    try {
        eh.requestStart();
        for (int i = 0; i < count; i++) {
            eh.send(e);
        }
        doAssertions(eh, count, e.getClass());
    } finally {
        eh.requestClose();
    }
}
Also used : AdapterCloseEvent(com.adaptris.core.event.AdapterCloseEvent) Event(com.adaptris.core.Event) Test(org.junit.Test)

Example 2 with Event

use of com.adaptris.core.Event in project interlok by adaptris.

the class ExampleEventHandlerCase method testSendEvent_WithProperties.

@Test
public void testSendEvent_WithProperties() throws Exception {
    Event e = EventFactory.create(AdapterCloseEvent.class);
    T eh = applyConfiguration(newEventHandler(getName()));
    Map<String, String> properties = MetadataCollection.asMap(new MetadataCollection(new MetadataElement("hello", "world")));
    try {
        eh.requestStart();
        eh.send(e, properties);
        doAssertions(eh, 1, e.getClass());
        MockMessageProducer p = getProducer(eh);
        AdaptrisMessage msg = p.getMessages().get(0);
        assertTrue(msg.headersContainsKey("hello"));
        assertEquals("world", msg.getMetadataValue("hello"));
    } finally {
        eh.requestClose();
    }
}
Also used : MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) AdapterCloseEvent(com.adaptris.core.event.AdapterCloseEvent) Event(com.adaptris.core.Event) MetadataCollection(com.adaptris.core.MetadataCollection) MetadataElement(com.adaptris.core.MetadataElement) Test(org.junit.Test)

Example 3 with Event

use of com.adaptris.core.Event in project interlok by adaptris.

the class ExampleEventHandlerCase method testSendEvent.

@Test
public void testSendEvent() throws Exception {
    Event e = EventFactory.create(AdapterCloseEvent.class);
    T eh = applyConfiguration(newEventHandler(getName()));
    try {
        eh.requestStart();
        eh.send(e);
        doAssertions(eh, 1, e.getClass());
    } finally {
        eh.requestClose();
    }
}
Also used : AdapterCloseEvent(com.adaptris.core.event.AdapterCloseEvent) Event(com.adaptris.core.Event) Test(org.junit.Test)

Aggregations

Event (com.adaptris.core.Event)3 AdapterCloseEvent (com.adaptris.core.event.AdapterCloseEvent)3 Test (org.junit.Test)3 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)1 MetadataCollection (com.adaptris.core.MetadataCollection)1 MetadataElement (com.adaptris.core.MetadataElement)1 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)1