Search in sources :

Example 16 with MockMessageConsumer

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

the class AdaptrisConnectionTest method testCloseWithWorkerLifecycle.

@Test
public void testCloseWithWorkerLifecycle() throws Exception {
    MockConnection mc = new MockConnection();
    List<MockMessageConsumer> consumers = createConsumers();
    List<MockMessageProducer> producers = createProducers();
    for (MockMessageConsumer c : consumers) {
        mc.addMessageConsumer(c);
    }
    for (MockMessageProducer c : producers) {
        mc.addMessageProducer(c);
    }
    mc.setWorkersFirstOnShutdown(true);
    invoke(mc, INIT);
    invoke(producers, INIT);
    invoke(consumers, INIT);
    invoke(mc, START);
    invoke(producers, START);
    invoke(consumers, START);
    invoke(mc, STOP);
    assertState(producers, StoppedState.getInstance());
    assertState(consumers, StoppedState.getInstance());
    invoke(mc, CLOSE);
    assertState(producers, ClosedState.getInstance());
    assertState(consumers, ClosedState.getInstance());
}
Also used : MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) MockMessageConsumer(com.adaptris.core.stubs.MockMessageConsumer) MockConnection(com.adaptris.core.stubs.MockConnection) Test(org.junit.Test)

Example 17 with MockMessageConsumer

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

the class DefaultFailedMessageRetrierTest method testRoundTrip_AdapterRetry.

@Test
public void testRoundTrip_AdapterRetry() throws Exception {
    AdaptrisMarshaller marshaller = DefaultMarshaller.getDefaultMarshaller();
    Adapter adapter = (Adapter) marshaller.unmarshal(marshaller.marshal(createAdapterForRetry(create(), new StandardProcessingExceptionHandler(new StandaloneProducer(new MockMessageProducer())))));
    DefaultFailedMessageRetrier retrier = (DefaultFailedMessageRetrier) adapter.getFailedMessageRetrier();
    MockMessageProducer errProd = getErrorHandler(adapter);
    try {
        FailFirstMockMessageProducer workflowProducer = (FailFirstMockMessageProducer) adapter.getChannelList().get(0).getWorkflowList().get(0).getProducer();
        MockMessageConsumer consumer = (MockMessageConsumer) adapter.getChannelList().get(0).getWorkflowList().get(0).getConsumer();
        AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("ABCDEF");
        start(adapter);
        consumer.submitMessage(msg);
        // SHould have failed
        assertEquals(1, errProd.messageCount());
        retrier.onAdaptrisMessage(errProd.getMessages().get(0));
        assertTrue(msg.containsKey(CoreConstants.RETRY_COUNT_KEY));
        assertEquals("1", msg.getMetadataValue(CoreConstants.RETRY_COUNT_KEY));
        assertEquals(1, workflowProducer.getMessages().size());
    } finally {
        stop(adapter);
    }
}
Also used : FailFirstMockMessageProducer(com.adaptris.core.stubs.FailFirstMockMessageProducer) FailFirstMockMessageProducer(com.adaptris.core.stubs.FailFirstMockMessageProducer) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) MockMessageConsumer(com.adaptris.core.stubs.MockMessageConsumer) Test(org.junit.Test)

Example 18 with MockMessageConsumer

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

the class DefaultFailedMessageRetrierTest method createAdapterForRetry.

private Adapter createAdapterForRetry(FailedMessageRetrier retrier, ProcessingExceptionHandler errorHandler) throws Exception {
    Adapter adapter = AdapterTest.createAdapter(getName());
    adapter.setFailedMessageRetrier(retrier);
    adapter.setMessageErrorHandler(errorHandler);
    adapter.getChannelList().clear();
    Channel c = new Channel();
    c.setUniqueId(getName());
    StandardWorkflow wf = new StandardWorkflow();
    wf.setUniqueId(getName());
    wf.setConsumer(new MockMessageConsumer());
    wf.setProducer(new FailFirstMockMessageProducer());
    c.getWorkflowList().add(wf);
    adapter.getChannelList().add(c);
    return adapter;
}
Also used : FailFirstMockMessageProducer(com.adaptris.core.stubs.FailFirstMockMessageProducer) MockMessageConsumer(com.adaptris.core.stubs.MockMessageConsumer)

Example 19 with MockMessageConsumer

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

the class WorkflowLifecycleStrategyCase method configure.

protected Workflow configure(WorkflowImp wf, String uid) {
    wf.setUniqueId(uid);
    wf.setConsumer(new MockMessageConsumer());
    return wf;
}
Also used : MockMessageConsumer(com.adaptris.core.stubs.MockMessageConsumer)

Example 20 with MockMessageConsumer

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

the class WorkflowListTest method createWorkflow.

private StandardWorkflow createWorkflow(String uid) {
    StandardWorkflow result = new StandardWorkflow();
    result.setUniqueId(uid);
    result.setConsumer(new MockMessageConsumer());
    return result;
}
Also used : MockMessageConsumer(com.adaptris.core.stubs.MockMessageConsumer)

Aggregations

MockMessageConsumer (com.adaptris.core.stubs.MockMessageConsumer)31 Test (org.junit.Test)20 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)18 MockChannel (com.adaptris.core.stubs.MockChannel)10 FailFirstMockMessageProducer (com.adaptris.core.stubs.FailFirstMockMessageProducer)5 ConfiguredException (com.adaptris.core.services.exception.ConfiguredException)4 ThrowExceptionService (com.adaptris.core.services.exception.ThrowExceptionService)4 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)4 MockStandaloneConsumer (com.adaptris.core.stubs.MockStandaloneConsumer)4 MockConnection (com.adaptris.core.stubs.MockConnection)3 StaticMockMessageProducer (com.adaptris.core.stubs.StaticMockMessageProducer)3 StandardWorkflow (com.adaptris.core.StandardWorkflow)2 MockRequestReplyProducer (com.adaptris.core.stubs.MockRequestReplyProducer)2 StateManagedStandaloneConsumer (com.adaptris.core.stubs.StateManagedStandaloneConsumer)2 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)1 AdaptrisMessageConsumer (com.adaptris.core.AdaptrisMessageConsumer)1 AdaptrisMessageProducer (com.adaptris.core.AdaptrisMessageProducer)1 Channel (com.adaptris.core.Channel)1 Service (com.adaptris.core.Service)1 ServiceImp (com.adaptris.core.ServiceImp)1