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());
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations