use of com.adaptris.core.AdaptrisMessage in project interlok by adaptris.
the class ReportBuilderTest method testBuild.
@Test
public void testBuild() throws Exception {
AdaptrisMessage msg = new DefaultMessageFactory().newMessage();
ReportBuilder builder = new ReportBuilder();
try {
LifecycleHelper.initAndStart(builder);
builder.build(listFiles(10), msg);
try (InputStream in = msg.getInputStream()) {
List lines = IOUtils.readLines(in, StandardCharsets.UTF_8);
assertEquals(10, lines.size());
}
} finally {
LifecycleHelper.stopAndClose(builder);
}
}
use of com.adaptris.core.AdaptrisMessage in project interlok by adaptris.
the class RetryFromJettyTest method testRetry_WrongMethod.
@Test
public void testRetry_WrongMethod() 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 route condition that doesn't match POST + the msgId so 400 is
// expected
String url = jettyHelper.buildUrl(RetryFromJetty.DEFAULT_ENDPOINT_PREFIX + baseMsg.getUniqueId());
StandardHttpProducer http = buildProducer(url);
http.setIgnoreServerResponseCode(true);
http.setMethodProvider(new ConfiguredRequestMethodProvider(RequestMethodProvider.RequestMethod.GET));
AdaptrisMessage triggerMsg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
ExampleServiceCase.execute(new StandaloneRequestor(http), triggerMsg);
assertEquals(RetryFromJetty.HTTP_BAD, triggerMsg.getMetadataValue(CoreConstants.HTTP_PRODUCER_RESPONSE_CODE));
} finally {
stop(retrier, workflow);
}
}
use of com.adaptris.core.AdaptrisMessage 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.AdaptrisMessage 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.AdaptrisMessage 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);
}
}
Aggregations