Search in sources :

Example 1 with EventHandlerAwareService

use of com.adaptris.core.stubs.EventHandlerAwareService in project interlok by adaptris.

the class ServiceCollectionCase method testInitWithEventHandlerAware.

@Test
public void testInitWithEventHandlerAware() throws Exception {
    EventHandlerAwareService s = new EventHandlerAwareService(UUID.randomUUID().toString());
    ServiceCollectionImp sc = createServiceCollection();
    DefaultEventHandler eh = new DefaultEventHandler();
    sc.registerEventHandler(eh);
    sc.addService(new NullService(UUID.randomUUID().toString()));
    sc.addService(s);
    LifecycleHelper.init(sc);
    assertNotNull(s.retrieveEventHandler());
    assertEquals(eh, s.retrieveEventHandler());
}
Also used : DefaultEventHandler(com.adaptris.core.DefaultEventHandler) ServiceCollectionImp(com.adaptris.core.ServiceCollectionImp) NullService(com.adaptris.core.NullService) EventHandlerAwareService(com.adaptris.core.stubs.EventHandlerAwareService) Test(org.junit.Test)

Example 2 with EventHandlerAwareService

use of com.adaptris.core.stubs.EventHandlerAwareService in project interlok by adaptris.

the class RetryMessageErrorHandlerTest method testChannel_HasEventHandler.

@Test
public void testChannel_HasEventHandler() throws Exception {
    EventHandlerAwareService srv = new EventHandlerAwareService();
    RetryMessageErrorHandler meh = new RetryMessageErrorHandler(srv);
    DefaultEventHandler eventHandler = new DefaultEventHandler();
    Adapter adapter = AdapterTest.createAdapter(getName(), eventHandler);
    Channel c = new Channel();
    c.setMessageErrorHandler(meh);
    adapter.getChannelList().add(c);
    try {
        LifecycleHelper.init(adapter);
        assertEquals(eventHandler, srv.retrieveEventHandler());
    } finally {
        LifecycleHelper.close(adapter);
    }
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) EventHandlerAwareService(com.adaptris.core.stubs.EventHandlerAwareService) Test(org.junit.Test)

Example 3 with EventHandlerAwareService

use of com.adaptris.core.stubs.EventHandlerAwareService in project interlok by adaptris.

the class BranchingServiceCollectionTest method testInitWithEventHandlerAware.

@Override
public void testInitWithEventHandlerAware() throws Exception {
    EventHandlerAwareService s = new EventHandlerAwareService(UUID.randomUUID().toString());
    BranchingServiceCollection sc = createServiceCollection();
    sc.setFirstServiceId(FIRST_SERVICE_ID);
    DefaultEventHandler eh = new DefaultEventHandler();
    sc.registerEventHandler(eh);
    sc.addService(new NullService(UUID.randomUUID().toString()));
    sc.addService(s);
    LifecycleHelper.init(sc);
    assertNotNull(s.retrieveEventHandler());
    assertEquals(eh, s.retrieveEventHandler());
}
Also used : EventHandlerAwareService(com.adaptris.core.stubs.EventHandlerAwareService)

Example 4 with EventHandlerAwareService

use of com.adaptris.core.stubs.EventHandlerAwareService in project interlok by adaptris.

the class StandardProcessingExceptionHandlerTest method testChannel_HasEventHandler.

@Test
public void testChannel_HasEventHandler() throws Exception {
    EventHandlerAwareService srv = new EventHandlerAwareService();
    StandardProcessingExceptionHandler meh = new StandardProcessingExceptionHandler(srv);
    DefaultEventHandler eventHandler = new DefaultEventHandler();
    Adapter adapter = AdapterTest.createAdapter(getName(), eventHandler);
    Channel c = new Channel();
    c.setMessageErrorHandler(meh);
    adapter.getChannelList().add(c);
    try {
        LifecycleHelper.init(adapter);
        assertEquals(eventHandler, srv.retrieveEventHandler());
    } finally {
        LifecycleHelper.close(adapter);
    }
}
Also used : EventHandlerAwareService(com.adaptris.core.stubs.EventHandlerAwareService) Test(org.junit.Test)

Example 5 with EventHandlerAwareService

use of com.adaptris.core.stubs.EventHandlerAwareService in project interlok by adaptris.

the class StandardWorkflowTest method testInitialiseWithEventAware.

@Test
public void testInitialiseWithEventAware() throws Exception {
    EventHandlerAwareProducer prod = new EventHandlerAwareProducer();
    EventHandlerAwareConsumer cons = new EventHandlerAwareConsumer();
    EventHandlerAwareService service = new EventHandlerAwareService();
    MockChannel channel = createChannel(prod, Arrays.asList(new Service[] { service }));
    ((WorkflowImp) channel.getWorkflowList().get(0)).setConsumer(cons);
    log.error("------------{}---------------", getName());
    channel.requestInit();
    EventHandler eh = channel.obtainEventHandler();
    log.error("Obtained [{}]", eh);
    log.error("------------{}---------------", getName());
    assertEquals(eh, prod.retrieveEventHandler());
    assertEquals(eh, cons.retrieveEventHandler());
    assertEquals(eh, service.retrieveEventHandler());
}
Also used : EventHandlerAwareConsumer(com.adaptris.core.stubs.EventHandlerAwareConsumer) MockChannel(com.adaptris.core.stubs.MockChannel) EventHandlerAwareProducer(com.adaptris.core.stubs.EventHandlerAwareProducer) PayloadFromTemplateService(com.adaptris.core.services.metadata.PayloadFromTemplateService) EventHandlerAwareService(com.adaptris.core.stubs.EventHandlerAwareService) MockSkipProducerService(com.adaptris.core.stubs.MockSkipProducerService) ThrowExceptionService(com.adaptris.core.services.exception.ThrowExceptionService) AddMetadataService(com.adaptris.core.services.metadata.AddMetadataService) EventHandlerAwareService(com.adaptris.core.stubs.EventHandlerAwareService) Test(org.junit.Test)

Aggregations

EventHandlerAwareService (com.adaptris.core.stubs.EventHandlerAwareService)9 Test (org.junit.Test)8 MockChannel (com.adaptris.core.stubs.MockChannel)3 DefaultEventHandler (com.adaptris.core.DefaultEventHandler)1 NullService (com.adaptris.core.NullService)1 ServiceCollectionImp (com.adaptris.core.ServiceCollectionImp)1 ThrowExceptionService (com.adaptris.core.services.exception.ThrowExceptionService)1 AddMetadataService (com.adaptris.core.services.metadata.AddMetadataService)1 PayloadFromTemplateService (com.adaptris.core.services.metadata.PayloadFromTemplateService)1 EventHandlerAwareConsumer (com.adaptris.core.stubs.EventHandlerAwareConsumer)1 EventHandlerAwareProducer (com.adaptris.core.stubs.EventHandlerAwareProducer)1 MockSkipProducerService (com.adaptris.core.stubs.MockSkipProducerService)1