use of com.adaptris.core.http.client.net.HttpRequestService in project interlok by adaptris.
the class JettyAsyncWorkflowInterceptorTest method testInterceptor_WithShortcut.
@Test
public void testInterceptor_WithShortcut() throws Exception {
HttpConnection connection = createConnection(Integer.parseInt(PROPERTIES.getProperty(JETTY_HTTP_PORT)));
JettyMessageConsumer consumer = JettyHelper.createConsumer(URL_TO_POST_TO, getName());
StandardWorkflow receivingWF = new StandardWorkflow();
MockMessageProducer producer = new MockMessageProducer();
receivingWF.addInterceptor(new JettyAsyncWorkflowInterceptor().withMode(JettyAsyncWorkflowInterceptor.Mode.REQUEST));
receivingWF.getServiceCollection().add(new PayloadFromTemplateService().withTemplate("hello world"));
receivingWF.getServiceCollection().add(new StandaloneProducer(producer));
receivingWF.getServiceCollection().add(new JettyResponseService(200, "text/plain"));
receivingWF.getServiceCollection().add(new ShortCutJettyResponse());
receivingWF.setConsumer(consumer);
Channel channel = JettyHelper.createChannel(connection, receivingWF);
HttpRequestService httpService = createRequestor(connection.getPort());
try {
start(channel);
LifecycleHelper.initAndStart(httpService);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML_PAYLOAD);
ExampleServiceCase.execute(httpService, msg);
assertEquals("hello world", msg.getContent());
// Should be removed from the static cache.
waitForMessages(producer, 1);
// Grab the message that the standardWorkflow handled; and check the msgId.
// Should be removed from the static cache.
assertFalse(JettyAsyncWorkflowInterceptor.cacheContains(producer.getMessages().get(0).getUniqueId()));
} finally {
stop(channel);
}
}
use of com.adaptris.core.http.client.net.HttpRequestService in project interlok by adaptris.
the class RetryFromJettyTest method testReport.
@Test
public void testReport() throws Exception {
RetryFromJetty retrier = create();
try {
start(retrier);
String url = jettyHelper.buildUrl(RetryFromJetty.DEFAULT_REPORTING_ENDPOINT);
HttpRequestService http = new HttpRequestService(url);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
ExampleServiceCase.execute(http, msg);
assertEquals(RetryFromJetty.HTTP_OK, msg.getMetadataValue(CoreConstants.HTTP_PRODUCER_RESPONSE_CODE));
// We know there should be at least 2 messages seeded...
try (InputStream in = msg.getInputStream()) {
List lines = IOUtils.readLines(in, StandardCharsets.UTF_8);
assertTrue(lines.size() >= 2);
}
} finally {
stop(retrier);
}
}
Aggregations