Search in sources :

Example 11 with MockRequestReplyProducer

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

the class StandaloneRequestorTest method testStandardDoService.

@Test
public void testStandardDoService() throws Exception {
    MockRequestReplyProducer m = new MockRequestReplyProducer();
    StandaloneRequestor service = new StandaloneRequestor(m);
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("XYZ");
    execute(service, msg);
    assertTrue(msg.containsKey(MockRequestReplyProducer.REPLY_METADATA_KEY));
    assertEquals(MockRequestReplyProducer.REPLY_METADATA_VALUE, msg.getMetadataValue(MockRequestReplyProducer.REPLY_METADATA_KEY));
    assertEquals(1, m.getProducedMessages().size());
}
Also used : MockRequestReplyProducer(com.adaptris.core.stubs.MockRequestReplyProducer) Test(org.junit.Test)

Example 12 with MockRequestReplyProducer

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

the class RequestReplyWorkflowTest method testWorkflow_HasObjectMetadata.

@Test
public void testWorkflow_HasObjectMetadata() throws Exception {
    Channel channel = createChannel();
    RequestReplyWorkflow workflow = (RequestReplyWorkflow) channel.getWorkflowList().get(0);
    MockMessageProducer replier = (MockMessageProducer) workflow.getReplyProducer();
    MockRequestReplyProducer requestor = (MockRequestReplyProducer) workflow.getProducer();
    try {
        start(channel);
        AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("xxx");
        msg.addMetadata(REQUEST_METADATA_KEY, REQUEST_METADATA_VALUE);
        msg.addObjectHeader(REQUEST_OBJ_METADATA_KEY, this);
        MockMessageConsumer m = (MockMessageConsumer) workflow.getConsumer();
        m.submitMessage(msg);
        doDefaultAssertions(requestor, replier);
        AdaptrisMessage replyMsg = replier.getMessages().get(0);
        assertTrue("Request Metadata", replyMsg.headersContainsKey(REQUEST_METADATA_KEY));
        assertTrue("Contains object metadata", replyMsg.getObjectHeaders().containsKey(REQUEST_OBJ_METADATA_KEY));
    } finally {
        stop(channel);
    }
}
Also used : MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) MockChannel(com.adaptris.core.stubs.MockChannel) MockMessageConsumer(com.adaptris.core.stubs.MockMessageConsumer) MockRequestReplyProducer(com.adaptris.core.stubs.MockRequestReplyProducer) Test(org.junit.Test)

Example 13 with MockRequestReplyProducer

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

the class RequestReplyWorkflowTest method testWorkflow_SkipProducer_HasNoEffect.

@Test
public void testWorkflow_SkipProducer_HasNoEffect() throws Exception {
    Channel channel = createChannel();
    RequestReplyWorkflow workflow = (RequestReplyWorkflow) channel.getWorkflowList().get(0);
    workflow.getServiceCollection().add(new MockSkipProducerService());
    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 : MockSkipProducerService(com.adaptris.core.stubs.MockSkipProducerService) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) MockChannel(com.adaptris.core.stubs.MockChannel) MockRequestReplyProducer(com.adaptris.core.stubs.MockRequestReplyProducer) Test(org.junit.Test)

Example 14 with MockRequestReplyProducer

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

the class RequestReplyWorkflowTest method testWorkflow_HasInterceptor.

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

Example 15 with MockRequestReplyProducer

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

the class RequestReplyProducerTest method testRequest_AdaptrisMessage_ProduceDestination_Long.

@Test
public void testRequest_AdaptrisMessage_ProduceDestination_Long() throws Exception {
    MockRequestReplyProducer mock = createAndStart();
    try {
        AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("dummy");
        AdaptrisMessage reply = mock.request(msg, 10L);
        assertSame(msg, reply);
        assertTrue(msg.headersContainsKey(MockRequestReplyProducer.REPLY_METADATA_KEY));
    } 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