use of com.adaptris.core.StandaloneRequestor in project interlok by adaptris.
the class RetryFromJettyTest method testDelete.
@Test
public void testDelete() throws Exception {
RetryFromJetty retrier = create();
try {
start(retrier);
AdaptrisMessage baseMsg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
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_DELETE_PREFIX + baseMsg.getUniqueId());
StandardHttpProducer http = buildProducer(url);
http.setMethodProvider(new ConfiguredRequestMethodProvider(RequestMethod.DELETE));
http.setIgnoreServerResponseCode(true);
ExampleServiceCase.execute(new StandaloneRequestor(http), triggerMsg);
assertEquals(RetryFromJetty.HTTP_OK, triggerMsg.getMetadataValue(CoreConstants.HTTP_PRODUCER_RESPONSE_CODE));
} finally {
stop(retrier);
}
}
use of com.adaptris.core.StandaloneRequestor in project interlok by adaptris.
the class RetryFromJettyTest method testDelete_NotFound.
@Test
public void testDelete_NotFound() throws Exception {
RetryFromJetty retrier = create();
try {
start(retrier);
AdaptrisMessage baseMsg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
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_DELETE_PREFIX + triggerMsg.getUniqueId());
StandardHttpProducer http = buildProducer(url);
http.setMethodProvider(new ConfiguredRequestMethodProvider(RequestMethod.DELETE));
http.setIgnoreServerResponseCode(true);
ExampleServiceCase.execute(new StandaloneRequestor(http), triggerMsg);
assertEquals(RetryFromJetty.HTTP_NOT_FOUND, triggerMsg.getMetadataValue(CoreConstants.HTTP_PRODUCER_RESPONSE_CODE));
} finally {
stop(retrier);
}
}
use of com.adaptris.core.StandaloneRequestor in project interlok by adaptris.
the class RetryFromJettyTest method testRetry.
@Test
public void testRetry() 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()));
String url = jettyHelper.buildUrl(RetryFromJetty.DEFAULT_ENDPOINT_PREFIX + baseMsg.getUniqueId());
StandardHttpProducer http = buildProducer(url);
AdaptrisMessage triggerMsg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
ExampleServiceCase.execute(new StandaloneRequestor(http), triggerMsg);
assertEquals(RetryFromJetty.HTTP_ACCEPTED, triggerMsg.getMetadataValue(CoreConstants.HTTP_PRODUCER_RESPONSE_CODE));
// This should trigger the workflow, so we should wait for the message
await().atMost(Duration.ofSeconds(1)).with().pollInterval(Duration.ofMillis(100)).until(workflowProducer::messageCount, greaterThanOrEqualTo(1));
assertEquals(1, workflowProducer.messageCount());
} finally {
stop(retrier, workflow);
}
}
use of com.adaptris.core.StandaloneRequestor in project interlok by adaptris.
the class JmsProducerTest method testMultipleRequestorWithSession.
@Test
public void testMultipleRequestorWithSession() throws Exception {
String rfc6167 = "jms:queue:" + getName() + "";
ServiceList serviceList = new ServiceList(new Service[] { new StandaloneRequestor(activeMqBroker.getJmsConnection(), createProducer(rfc6167), new TimeInterval(1L, TimeUnit.SECONDS)), new StandaloneRequestor(activeMqBroker.getJmsConnection(), createProducer(rfc6167), new TimeInterval(1L, TimeUnit.SECONDS)) });
Loopback echo = createLoopback(activeMqBroker, getName());
try {
echo.start();
start(serviceList);
AdaptrisMessage msg1 = createMessage();
AdaptrisMessage msg2 = createMessage();
serviceList.doService(msg1);
serviceList.doService(msg2);
assertEquals(DEFAULT_PAYLOAD.toUpperCase(), msg1.getContent());
assertEquals(DEFAULT_PAYLOAD.toUpperCase(), msg2.getContent());
} finally {
stop(serviceList);
echo.stop();
}
}
use of com.adaptris.core.StandaloneRequestor in project interlok by adaptris.
the class JmsProducerTest method testRequest_DefinedReplyTo.
@Test
public void testRequest_DefinedReplyTo() throws Exception {
String rfc6167 = String.format("jms:queue:%1$s?replyToName=%1$s_reply", getName());
StandaloneRequestor serviceList = new StandaloneRequestor(activeMqBroker.getJmsConnection(), createProducer(rfc6167), new TimeInterval(1L, TimeUnit.SECONDS));
Loopback echo = createLoopback(activeMqBroker, getName());
try {
echo.start();
start(serviceList);
AdaptrisMessage msg = createMessage();
serviceList.doService(msg);
assertEquals(DEFAULT_PAYLOAD.toUpperCase(), msg.getContent());
} finally {
stop(serviceList);
echo.stop();
}
}
Aggregations