RequestReplyWorkflow extends StandardWorkflow { public AdaptrisMessageProducer getReplyProducer() { return replyProducer; } RequestReplyWorkflow(); @Override void doProduce(AdaptrisMessage msg); @Override void registerChannel(Channel c); void setReplyServiceCollection(ServiceCollection services); ServiceCollection getReplyServiceCollection(); void setReplyProducer(AdaptrisMessageProducer producer); AdaptrisMessageProducer getReplyProducer(); TimeInterval getReplyTimeout(); void setReplyTimeout(TimeInterval replyTimeout); void setRetainUniqueId(Boolean b); Boolean getRetainUniqueId();  }
@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); } }
@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); } }
@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); } }
@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); } }
@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); } }