use of com.adaptris.core.http.client.ConfiguredRequestMethodProvider in project interlok by adaptris.
the class StandardHttpProducerTest method testRequest_EmptyReply.
@Test
public void testRequest_EmptyReply() throws Exception {
MockMessageProducer mock = new MockMessageProducer();
HttpConnection jc = HttpHelper.createConnection();
JettyMessageConsumer mc = createConsumer(HttpHelper.URL_TO_POST_TO);
Channel c = createChannel(jc, createWorkflow(mc, mock, new ServiceList()));
StandardWorkflow workflow = (StandardWorkflow) c.getWorkflowList().get(0);
StandardResponseProducer responder = new StandardResponseProducer(HttpStatus.OK_200);
responder.setSendPayload(false);
workflow.getServiceCollection().add(new StandaloneProducer(responder));
StandardHttpProducer stdHttp = new StandardHttpProducer().withURL(HttpHelper.createURL(c));
stdHttp.setMethodProvider(new ConfiguredRequestMethodProvider(RequestMethodProvider.RequestMethod.POST));
stdHttp.setConnectTimeout(new TimeInterval(60L, TimeUnit.SECONDS));
stdHttp.setReadTimeout(new TimeInterval(60L, TimeUnit.SECONDS));
StandaloneRequestor producer = new StandaloneRequestor(stdHttp);
producer.setReplyTimeout(new TimeInterval(60L, TimeUnit.SECONDS));
AdaptrisMessage msg = new DefaultMessageFactory().newMessage(TEXT);
try {
start(c);
start(producer);
producer.doService(msg);
waitForMessages(mock, 1);
} finally {
HttpHelper.stopChannelAndRelease(c);
stop(producer);
}
assertEquals(1, mock.messageCount());
AdaptrisMessage m2 = mock.getMessages().get(0);
assertEquals("POST", m2.getMetadataValue(CoreConstants.HTTP_METHOD));
assertEquals(0, msg.getSize());
}
use of com.adaptris.core.http.client.ConfiguredRequestMethodProvider in project interlok by adaptris.
the class RetryFromJettyTest method testReport_Broken.
@Test
public void testReport_Broken() throws Exception {
RetryFromJetty retrier = create();
try {
retrier.setRetryStore(new BrokenRetryStore());
start(retrier);
String url = jettyHelper.buildUrl(RetryFromJetty.DEFAULT_REPORTING_ENDPOINT);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
StandardHttpProducer http = buildProducer(url);
http.setIgnoreServerResponseCode(true);
http.setMethodProvider(new ConfiguredRequestMethodProvider(RequestMethodProvider.RequestMethod.GET));
ExampleServiceCase.execute(new StandaloneRequestor(http), msg);
assertEquals(RetryFromJetty.HTTP_ERROR, msg.getMetadataValue(CoreConstants.HTTP_PRODUCER_RESPONSE_CODE));
} finally {
stop(retrier);
}
}
use of com.adaptris.core.http.client.ConfiguredRequestMethodProvider in project interlok by adaptris.
the class RetryFromJettyTest method testDelete_BadRequest.
@Test
public void testDelete_BadRequest() throws Exception {
RetryFromJetty retrier = create();
try {
start(retrier);
AdaptrisMessage baseMsg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
retryStore.write(baseMsg);
assertNotNull(retryStore.getMetadata(baseMsg.getUniqueId()));
// we're going to use a POST but with the correct URL.
// so should be a BAD request.
AdaptrisMessage triggerMsg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
String url = jettyHelper.buildUrl(RetryFromJetty.DEFAULT_DELETE_PREFIX + baseMsg.getUniqueId());
StandardHttpProducer http = buildProducer(url);
http.setIgnoreServerResponseCode(true);
http.setMethodProvider(new ConfiguredRequestMethodProvider(RequestMethod.POST));
ExampleServiceCase.execute(new StandaloneRequestor(http), triggerMsg);
assertEquals(RetryFromJetty.HTTP_BAD, triggerMsg.getMetadataValue(CoreConstants.HTTP_PRODUCER_RESPONSE_CODE));
} finally {
stop(retrier);
}
}
Aggregations