use of com.adaptris.core.ServiceList 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.ServiceList in project interlok by adaptris.
the class ActiveMqJmsTransactedWorkflowTest method testServiceExceptionNonStrictWithErrorHandler.
// In Non-Strict Mode, if you have configured an error handler, then
// the transaction is successful.
@Test
public void testServiceExceptionNonStrictWithErrorHandler() throws Exception {
int msgCount = 10;
String destination = createSafeUniqueId(new Object());
MockMessageProducer meh = new MockMessageProducer();
Channel channel = createStartableChannel(activeMqBroker, true, "testServiceExceptionNonStrictWithErrorHandler", destination);
JmsTransactedWorkflow workflow = (JmsTransactedWorkflow) channel.getWorkflowList().get(0);
workflow.setStrict(Boolean.FALSE);
workflow.getServiceCollection().addService(new ThrowExceptionService(new ConfiguredException("Fail")));
channel.setMessageErrorHandler(new StandardProcessingExceptionHandler(new ServiceList(new ArrayList<Service>(Arrays.asList(new Service[] { new StandaloneProducer(meh) })))));
channel.prepare();
try {
channel.requestStart();
StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new PtpProducer().withQueue((destination)));
send(sender, msgCount);
waitForMessages(meh, msgCount);
assertEquals(0, ((MockMessageProducer) workflow.getProducer()).getMessages().size());
} finally {
channel.requestClose();
}
assertEquals(0, activeMqBroker.messagesOnQueue(destination));
}
use of com.adaptris.core.ServiceList in project interlok by adaptris.
the class LargeMessageWorkflowTest method testServiceException.
@Override
@Test
public void testServiceException() throws Exception {
MockMessageProducer producer = new MockMessageProducer();
MockMessageProducer meh = new MockMessageProducer();
MockChannel channel = createChannel(producer, Arrays.asList(new Service[] { new AddMetadataService(Arrays.asList(new MetadataElement[] { new MetadataElement(METADATA_KEY, METADATA_VALUE) })), new PayloadFromTemplateService().withTemplate(PAYLOAD_2), new ThrowExceptionService(new ConfiguredException("Fail")) }));
try {
LargeMessageWorkflow workflow = (LargeMessageWorkflow) channel.getWorkflowList().get(0);
channel.setMessageErrorHandler(new StandardProcessingExceptionHandler(new ServiceList(new ArrayList<Service>(Arrays.asList(new Service[] { new StandaloneProducer(meh) })))));
channel.prepare();
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(PAYLOAD_1);
start(channel);
workflow.onAdaptrisMessage(msg);
assertEquals("Make none produced", 0, producer.getMessages().size());
assertEquals(1, meh.getMessages().size());
for (AdaptrisMessage m : meh.getMessages()) {
assertEquals(PAYLOAD_2, m.getContent());
assertTrue("Contains correct metadata key", m.containsKey(METADATA_KEY));
assertEquals(METADATA_VALUE, m.getMetadataValue(METADATA_KEY));
assertNotNull(m.getObjectHeaders().get(CoreConstants.OBJ_METADATA_EXCEPTION));
assertNotNull(m.getObjectHeaders().get(CoreConstants.OBJ_METADATA_EXCEPTION_CAUSE));
assertEquals(ThrowExceptionService.class.getSimpleName(), m.getObjectHeaders().get(CoreConstants.OBJ_METADATA_EXCEPTION_CAUSE));
}
} finally {
stop(channel);
}
}
use of com.adaptris.core.ServiceList in project interlok by adaptris.
the class LargeMessageWorkflowTest method testProduceException.
@Override
@Test
public void testProduceException() throws Exception {
MockMessageProducer producer = new MockMessageProducer() {
@Override
protected void doProduce(AdaptrisMessage msg, String endpoint) throws ProduceException {
throw new ProduceException();
}
};
;
MockMessageProducer meh = new MockMessageProducer();
MockChannel channel = createChannel(producer, Arrays.asList(new Service[] { new AddMetadataService(Arrays.asList(new MetadataElement[] { new MetadataElement(METADATA_KEY, METADATA_VALUE) })), new PayloadFromTemplateService().withTemplate(PAYLOAD_2) }));
try {
LargeMessageWorkflow workflow = (LargeMessageWorkflow) channel.getWorkflowList().get(0);
channel.setMessageErrorHandler(new StandardProcessingExceptionHandler(new ServiceList(new ArrayList<Service>(Arrays.asList(new Service[] { new StandaloneProducer(meh) })))));
channel.prepare();
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(PAYLOAD_1);
start(channel);
workflow.onAdaptrisMessage(msg);
assertEquals("Make none produced", 0, producer.getMessages().size());
assertEquals(1, meh.getMessages().size());
for (AdaptrisMessage m : meh.getMessages()) {
assertEquals(PAYLOAD_2, m.getContent());
assertTrue("Contains correct metadata key", m.containsKey(METADATA_KEY));
assertEquals(METADATA_VALUE, m.getMetadataValue(METADATA_KEY));
}
} finally {
stop(channel);
}
}
use of com.adaptris.core.ServiceList in project interlok by adaptris.
the class SharedServiceConfigurationCheckerTest method testServiceInServiceCollectionExist.
@Test
public void testServiceInServiceCollectionExist() throws Exception {
BootstrapProperties mockBootProperties = new MockBootProperties(createAdapterConfig(new NullService("SharedNullService"), new ServiceList(new SharedService("SharedNullService"))));
ConfigurationCheckReport report = checker.performConfigCheck(mockBootProperties);
assertTrue(report.isCheckPassed());
assertNotNull(report.toString());
}
Aggregations