Search in sources :

Example 1 with SimpleIdGenerator

use of com.adaptris.util.SimpleIdGenerator in project interlok by adaptris.

the class RetryMessageErrorHandlerTest method testBug854.

@Test
@SuppressWarnings("deprecation")
public void testBug854() throws Exception {
    String name = renameThread("testBug854");
    try {
        MockMessageProducer failProducer = new MockMessageProducer();
        RetryMessageErrorHandler meh = createMessageErrorHandler(failProducer);
        meh.setRetryInterval(DEFAULT_RETRY_INTERVAL);
        meh.setRetryLimit(0);
        FailFirstMockMessageProducer workflowProducer = new FailFirstMockMessageProducer(1);
        StandardWorkflow workflow = createWorkflow(workflowProducer);
        workflow.setServiceCollection(new ServiceList());
        workflow.setProduceExceptionHandler(new RestartProduceExceptionHandler());
        Channel channel = new Channel();
        channel.getWorkflowList().add(workflow);
        channel.setProduceConnection(new MockConnection());
        channel.getProduceConnection().setConnectionErrorHandler(new ChannelRestartConnectionErrorHandler());
        Adapter adapter = new Adapter();
        adapter.setUniqueId(new SimpleIdGenerator().create(this));
        adapter.setMessageErrorHandler(meh);
        adapter.getChannelList().addChannel(channel);
        // adapter.prepare();
        adapter.requestStart();
        workflow.onAdaptrisMessage(AdaptrisMessageFactory.getDefaultInstance().newMessage("XXXX"));
        waitForMessages(workflowProducer, 1);
        adapter.requestClose();
        assertEquals("Ensure producer success", 1, workflowProducer.getMessages().size());
        assertEquals("Should not have produced to failProducer", 0, failProducer.getMessages().size());
    } finally {
        renameThread(name);
    }
}
Also used : FailFirstMockMessageProducer(com.adaptris.core.stubs.FailFirstMockMessageProducer) ChannelRestartConnectionErrorHandler(com.adaptris.core.stubs.ChannelRestartConnectionErrorHandler) FailFirstMockMessageProducer(com.adaptris.core.stubs.FailFirstMockMessageProducer) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) MockChannel(com.adaptris.core.stubs.MockChannel) SimpleIdGenerator(com.adaptris.util.SimpleIdGenerator) MockConnection(com.adaptris.core.stubs.MockConnection) Test(org.junit.Test)

Aggregations

ChannelRestartConnectionErrorHandler (com.adaptris.core.stubs.ChannelRestartConnectionErrorHandler)1 FailFirstMockMessageProducer (com.adaptris.core.stubs.FailFirstMockMessageProducer)1 MockChannel (com.adaptris.core.stubs.MockChannel)1 MockConnection (com.adaptris.core.stubs.MockConnection)1 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)1 SimpleIdGenerator (com.adaptris.util.SimpleIdGenerator)1 Test (org.junit.Test)1