use of com.adaptris.core.stubs.MockWorkflowInterceptor 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.MockWorkflowInterceptor in project interlok by adaptris.
the class MultiProducerWorkflowTest method testWorkflowWithInterceptor.
@Test
public void testWorkflowWithInterceptor() throws Exception {
MockMessageProducer mock1 = new MockMessageProducer();
MockMessageProducer mock2 = new MockMessageProducer();
MockWorkflowInterceptor interceptor = new MockWorkflowInterceptor();
MockChannel channel = createChannel(Arrays.asList(new AdaptrisMessageProducer[] { mock1, mock2 }), Arrays.asList(new Service[] { new PayloadFromTemplateService().withTemplate(MODIFIED_PAYLOAD) }));
try {
MultiProducerWorkflow workflow = (MultiProducerWorkflow) channel.getWorkflowList().get(0);
workflow.setUseProcessedMessage(false);
workflow.addInterceptor(interceptor);
channel.prepare();
channel.requestStart();
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(ORIGINAL_PAYLOAD);
workflow.onAdaptrisMessage(msg);
assertEquals(1, mock1.getMessages().size());
assertEquals(ORIGINAL_PAYLOAD, mock1.getMessages().get(0).getContent());
assertEquals(1, mock2.getMessages().size());
assertEquals(ORIGINAL_PAYLOAD, mock2.getMessages().get(0).getContent());
assertEquals(1, interceptor.messageCount());
} finally {
channel.requestClose();
}
}
use of com.adaptris.core.stubs.MockWorkflowInterceptor in project interlok by adaptris.
the class HttpConsumerTest method testPoolingWorkflow_WithoutInterceptor.
@Test
public void testPoolingWorkflow_WithoutInterceptor() throws Exception {
HttpConnection connection = createConnection(null);
MockMessageProducer mockProducer = new StaticMockMessageProducer();
mockProducer.getMessages().clear();
JettyMessageConsumer consumer = JettyHelper.createConsumer(URL_TO_POST_TO);
PoolingWorkflow workflow = new PoolingWorkflow();
workflow.addInterceptor(new MockWorkflowInterceptor());
workflow.setShutdownWaitTime(new TimeInterval(100L, TimeUnit.MILLISECONDS));
StandardResponseProducer responder = new StandardResponseProducer(HttpStatus.OK_200);
workflow.setConsumer(consumer);
workflow.getServiceCollection().add(new WaitService(new TimeInterval(1L, TimeUnit.SECONDS)));
workflow.getServiceCollection().add(new StandaloneProducer(mockProducer));
workflow.getServiceCollection().add(new StandaloneProducer(responder));
Channel channel = JettyHelper.createChannel(connection, workflow);
try {
channel.requestStart();
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML_PAYLOAD);
msg.addMetadata(CONTENT_TYPE_METADATA_KEY, "text/xml");
httpProducer.setUrl(createProduceDestinationUrl(connection.getPort()));
start(httpProducer);
AdaptrisMessage reply = httpProducer.request(msg);
// Because of redmineID #4715 it should just "return immediatel" which flushes the stream so there's no content.
assertEquals("Reply Payloads", "", reply.getContent());
} finally {
stop(httpProducer);
channel.requestClose();
}
}
Aggregations