Search in sources :

Example 11 with DefaultEventHandler

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

the class BaseCase method createandStartDummyEventHandler.

public static EventHandler createandStartDummyEventHandler() throws CoreException {
    DefaultEventHandler eh = new DefaultEventHandler();
    LifecycleHelper.init(eh);
    LifecycleHelper.start(eh);
    return eh;
}
Also used : DefaultEventHandler(com.adaptris.core.DefaultEventHandler)

Example 12 with DefaultEventHandler

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

the class ExampleWorkflowCase method testRegisterObjects.

@Test
public void testRegisterObjects() throws Exception {
    WorkflowImp wf = createWorkflowForGenericTests();
    wf.registerChannel(new Channel());
    try {
        wf.registerChannel(null);
        fail();
    } catch (IllegalArgumentException e) {
        ;
    }
    wf.registerActiveMsgErrorHandler(new NullProcessingExceptionHandler());
    try {
        wf.registerActiveMsgErrorHandler(null);
        fail();
    } catch (IllegalArgumentException e) {
        ;
    }
    wf.registerActiveMsgErrorHandler(new NullProcessingExceptionHandler());
    try {
        wf.registerActiveMsgErrorHandler(null);
        fail();
    } catch (IllegalArgumentException e) {
        ;
    }
    wf.registerEventHandler(new DefaultEventHandler());
    try {
        wf.registerEventHandler(null);
        fail();
    } catch (IllegalArgumentException e) {
        ;
    }
}
Also used : DefaultEventHandler(com.adaptris.core.DefaultEventHandler) MockChannel(com.adaptris.core.stubs.MockChannel) Channel(com.adaptris.core.Channel) WorkflowImp(com.adaptris.core.WorkflowImp) NullProcessingExceptionHandler(com.adaptris.core.NullProcessingExceptionHandler) Test(org.junit.Test)

Example 13 with DefaultEventHandler

use of com.adaptris.core.DefaultEventHandler 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 14 with DefaultEventHandler

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

the class MockChannel method prepare.

@Override
public void prepare() throws CoreException {
    if (eh == null) {
        eh = new DefaultEventHandler();
    }
    eh.requestStart();
    registerEventHandler(eh);
    super.prepare();
    registerActiveMsgErrorHandler(getMessageErrorHandler());
    for (Workflow workflow : getWorkflowList()) {
        if (workflow.getMessageErrorHandler() != null) {
            workflow.registerActiveMsgErrorHandler(workflow.getMessageErrorHandler());
        } else {
            workflow.registerActiveMsgErrorHandler(getMessageErrorHandler());
        }
    }
}
Also used : DefaultEventHandler(com.adaptris.core.DefaultEventHandler) Workflow(com.adaptris.core.Workflow)

Example 15 with DefaultEventHandler

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

the class PooledSplitJoinServiceTest method testService_WithException.

@Test(expected = ServiceException.class)
public void testService_WithException() throws Exception {
    PooledSplitJoinService service = new PooledSplitJoinService();
    service.setAggregator(new AppendingMessageAggregator());
    service.setSplitter(new LineCountSplitter(1));
    service.setPoolsize(10);
    service.setTimeout(new TimeInterval(5L, TimeUnit.SECONDS));
    service.setService(new ThrowExceptionService(new ConfiguredException("always-fail")));
    service.registerEventHandler(LifecycleHelper.initAndStart(new DefaultEventHandler()));
    AdaptrisMessage msg = createLineCountMessageInput(50);
    try {
        ExampleServiceCase.execute(service, msg);
    } catch (ServiceException e) {
        assertEquals("always-fail", e.getMessage());
        throw e;
    }
}
Also used : TimeInterval(com.adaptris.util.TimeInterval) ServiceException(com.adaptris.core.ServiceException) DefaultEventHandler(com.adaptris.core.DefaultEventHandler) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ThrowExceptionService(com.adaptris.core.services.exception.ThrowExceptionService) AppendingMessageAggregator(com.adaptris.core.services.aggregator.AppendingMessageAggregator) ConfiguredException(com.adaptris.core.services.exception.ConfiguredException) Test(org.junit.Test)

Aggregations

DefaultEventHandler (com.adaptris.core.DefaultEventHandler)21 Test (org.junit.Test)18 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)12 AppendingMessageAggregator (com.adaptris.core.services.aggregator.AppendingMessageAggregator)6 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)6 TimeInterval (com.adaptris.util.TimeInterval)6 ServiceException (com.adaptris.core.ServiceException)3 ConfiguredException (com.adaptris.core.services.exception.ConfiguredException)3 ThrowExceptionService (com.adaptris.core.services.exception.ThrowExceptionService)3 Adapter (com.adaptris.core.Adapter)2 Channel (com.adaptris.core.Channel)2 NullService (com.adaptris.core.NullService)2 StandaloneProducer (com.adaptris.core.StandaloneProducer)2 AdapterShutdownEvent (com.adaptris.core.event.AdapterShutdownEvent)2 BootstrapProperties (com.adaptris.core.management.BootstrapProperties)2 WaitService (com.adaptris.core.services.WaitService)2 JunitBootstrapProperties (com.adaptris.core.stubs.JunitBootstrapProperties)2 StaticMockEventProducer (com.adaptris.core.stubs.StaticMockEventProducer)2 URLString (com.adaptris.util.URLString)2 Properties (java.util.Properties)2