use of com.adaptris.core.http.client.net.StandardHttpProducer in project interlok by adaptris.
the class EmbeddedHttpConsumerTest method createProducer.
protected StandardHttpProducer createProducer() {
StandardHttpProducer p = new StandardHttpProducer();
p.setContentTypeProvider(new MetadataContentTypeProvider("content.type"));
p.setUrl("dummy_url");
p.setIgnoreServerResponseCode(true);
p.registerConnection(new NullConnection());
return p;
}
use of com.adaptris.core.http.client.net.StandardHttpProducer 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.net.StandardHttpProducer in project interlok by adaptris.
the class RetryFromJettyTest method testRetry_NotFound.
@Test
public void testRetry_NotFound() throws Exception {
RetryFromJetty retrier = create();
StandardWorkflow workflow = createWorkflow();
try {
MockMessageProducer workflowProducer = (MockMessageProducer) workflow.getProducer();
retrier.addWorkflow(workflow);
retrier.addWorkflow(createWorkflow());
start(workflow, retrier);
AdaptrisMessage baseMsg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
baseMsg.addMetadata(Workflow.WORKFLOW_ID_KEY, workflow.obtainWorkflowId());
retryStore.write(baseMsg);
assertNotNull(retryStore.getMetadata(baseMsg.getUniqueId()));
// This should result in a msgId that isn't found; so we get a 500...
AdaptrisMessage triggerMsg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
String url = jettyHelper.buildUrl(RetryFromJetty.DEFAULT_ENDPOINT_PREFIX + triggerMsg.getUniqueId());
StandardHttpProducer http = buildProducer(url);
http.setIgnoreServerResponseCode(true);
ExampleServiceCase.execute(new StandaloneRequestor(http), triggerMsg);
assertEquals(RetryFromJetty.HTTP_ERROR, triggerMsg.getMetadataValue(CoreConstants.HTTP_PRODUCER_RESPONSE_CODE));
} finally {
stop(retrier, workflow);
}
}
use of com.adaptris.core.http.client.net.StandardHttpProducer 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