Search in sources :

Example 1 with MockRequestReplyProducer

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

the class RequestReplyWorkflowTest method testWorkflow.

@Test
public void testWorkflow() throws Exception {
    Channel channel = createChannel();
    RequestReplyWorkflow workflow = (RequestReplyWorkflow) channel.getWorkflowList().get(0);
    workflow.setRetainUniqueId(true);
    MockMessageProducer replier = (MockMessageProducer) workflow.getReplyProducer();
    MockRequestReplyProducer requestor = (MockRequestReplyProducer) workflow.getProducer();
    try {
        start(channel);
        submitMessages(workflow, 1);
        doDefaultAssertions(requestor, replier);
        AdaptrisMessage replyMsg = replier.getMessages().get(0);
        assertTrue("Request Metadata", replyMsg.headersContainsKey(REQUEST_METADATA_KEY));
    } finally {
        stop(channel);
    }
}
Also used : MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) MockChannel(com.adaptris.core.stubs.MockChannel) MockRequestReplyProducer(com.adaptris.core.stubs.MockRequestReplyProducer) Test(org.junit.Test)

Example 2 with MockRequestReplyProducer

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

the class RequestReplyWorkflowTest method testWorkflow_UseReplyMetadata.

@Test
public void testWorkflow_UseReplyMetadata() throws Exception {
    Channel channel = createChannel();
    RequestReplyWorkflow workflow = (RequestReplyWorkflow) channel.getWorkflowList().get(0);
    MockMessageProducer replier = (MockMessageProducer) workflow.getReplyProducer();
    MockRequestReplyProducer requestor = (MockRequestReplyProducer) workflow.getProducer();
    try {
        requestor.setIgnoreReplyMetadata(false);
        start(channel);
        submitMessages(workflow, 1);
        doDefaultAssertions(requestor, replier);
        AdaptrisMessage reply = replier.getMessages().get(0);
        assertTrue("Contains Request Metadata key", reply.headersContainsKey(REQUEST_METADATA_KEY));
        assertTrue("Reply Metadata key", reply.headersContainsKey(MockRequestReplyProducer.REPLY_METADATA_KEY));
    } finally {
        stop(channel);
    }
}
Also used : MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) MockChannel(com.adaptris.core.stubs.MockChannel) MockRequestReplyProducer(com.adaptris.core.stubs.MockRequestReplyProducer) Test(org.junit.Test)

Example 3 with MockRequestReplyProducer

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

the class RequestReplyWorkflowTest method testWorkflow_IgnoreReplyMetadata.

@Test
public void testWorkflow_IgnoreReplyMetadata() throws Exception {
    Channel channel = createChannel();
    RequestReplyWorkflow workflow = (RequestReplyWorkflow) channel.getWorkflowList().get(0);
    MockMessageProducer replier = (MockMessageProducer) workflow.getReplyProducer();
    MockRequestReplyProducer requestor = (MockRequestReplyProducer) workflow.getProducer();
    try {
        requestor.setIgnoreReplyMetadata(true);
        start(channel);
        submitMessages(workflow, 1);
        doDefaultAssertions(requestor, replier);
        AdaptrisMessage reply = replier.getMessages().get(0);
        assertTrue("Contains Request Metadata key", reply.headersContainsKey(REQUEST_METADATA_KEY));
        assertFalse("Reply Metadata key", reply.headersContainsKey(MockRequestReplyProducer.REPLY_METADATA_KEY));
    } finally {
        stop(channel);
    }
}
Also used : MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) MockChannel(com.adaptris.core.stubs.MockChannel) MockRequestReplyProducer(com.adaptris.core.stubs.MockRequestReplyProducer) Test(org.junit.Test)

Example 4 with MockRequestReplyProducer

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

the class RequestReplyWorkflowTest method createChannel.

// private RequestReplyWorkflow workFlow;
// private MockMessageConsumer consumer;
// private MockRequestReplyProducer producer;
// private MockMessageProducer replyProducer;
private Channel createChannel() throws Exception {
    Channel channel = new MockChannel();
    MockMessageConsumer consumer = new MockMessageConsumer();
    MockRequestReplyProducer producer = new MockRequestReplyProducer();
    MockMessageProducer replyProducer = new MockMessageProducer();
    RequestReplyWorkflow workFlow = new RequestReplyWorkflow();
    workFlow.setConsumer(consumer);
    workFlow.setProducer(producer);
    workFlow.setReplyProducer(replyProducer);
    channel.getWorkflowList().addWorkflow(workFlow);
    channel.prepare();
    return channel;
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) MockChannel(com.adaptris.core.stubs.MockChannel) MockMessageConsumer(com.adaptris.core.stubs.MockMessageConsumer) MockRequestReplyProducer(com.adaptris.core.stubs.MockRequestReplyProducer)

Example 5 with MockRequestReplyProducer

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

the class RequestReplyProducerTest method testProduce_AdaptrisMessage_ProduceDestination.

@Test
public void testProduce_AdaptrisMessage_ProduceDestination() throws Exception {
    MockRequestReplyProducer mock = createAndStart();
    try {
        AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("dummy");
        mock.produce(msg);
        assertEquals(1, mock.getProducedMessages().size());
    } finally {
        LifecycleHelper.stopAndClose(mock);
    }
}
Also used : MockRequestReplyProducer(com.adaptris.core.stubs.MockRequestReplyProducer) Test(org.junit.Test)

Aggregations

MockRequestReplyProducer (com.adaptris.core.stubs.MockRequestReplyProducer)19 Test (org.junit.Test)18 MockChannel (com.adaptris.core.stubs.MockChannel)7 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)7 MockMessageConsumer (com.adaptris.core.stubs.MockMessageConsumer)2 MockSkipProducerService (com.adaptris.core.stubs.MockSkipProducerService)1 MockWorkflowInterceptor (com.adaptris.core.stubs.MockWorkflowInterceptor)1 TimeInterval (com.adaptris.util.TimeInterval)1