use of com.adaptris.core.ServiceList in project interlok by adaptris.
the class ServiceFromCacheTest method createCache.
private CacheConnection createCache(String key) throws Exception {
ExpiringMapCache cacheInstance = new ExpiringMapCache();
CacheConnection conn = new CacheConnection();
conn.setCacheInstance(cacheInstance);
LifecycleHelper.initAndStart(conn);
conn.retrieveCache().put(key, DynamicServiceExecutorTest.createMessage(new ServiceList(new LogMessageService())).getContent());
return conn;
}
use of com.adaptris.core.ServiceList in project interlok by adaptris.
the class ExceptionHandlingServiceWrapperTest method retrieveObjectForSampleConfig.
@Override
protected Object retrieveObjectForSampleConfig() {
ExceptionHandlingServiceWrapper service = create();
service.setService(new ServiceList(new Service[] { new ThrowExceptionService(new ConfiguredException("Fail")), new AddMetadataService(Arrays.asList(new MetadataElement[] { new MetadataElement("servicesComplete", "true") })) }));
return service;
}
use of com.adaptris.core.ServiceList in project interlok by adaptris.
the class ExceptionHandlingServiceWrapperTest method testWithExceptionFromWrappedServices.
@Test
public void testWithExceptionFromWrappedServices() throws Exception {
ExceptionHandlingServiceWrapper service = create();
service.registerEventHandler(new DefaultEventHandler());
service.setService(new ServiceList(new Service[] { new ThrowExceptionService(new ConfiguredException("Fail")), new AddMetadataService(Arrays.asList(new MetadataElement[] { new MetadataElement("servicesComplete", "true") })) }));
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
assertNotNull(service.wrappedServices());
// ExceptionService defaults to NullService
assertEquals(2, service.wrappedServices().length);
execute(service, msg);
assertEquals("true", msg.getMetadataValue("exceptionServiceTriggered"));
assertNull(msg.getMetadataValue("servicesComplete"));
}
use of com.adaptris.core.ServiceList in project interlok by adaptris.
the class ExceptionReportServiceTest method testBug2356.
@Test
public void testBug2356() throws Exception {
ServiceImp failingService = new ThrowExceptionService(new ConfiguredException("Fail"));
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML_PAYLOAD);
ExceptionReportService service = new ExceptionReportService(new ExceptionAsXml().withExceptionGenerator(new SimpleExceptionReport()).withDocumentMerge(new InsertNode(XPATH_ROOT)));
MockMessageProducer mockProducer = new MockMessageProducer();
StandardProcessingExceptionHandler speh = new StandardProcessingExceptionHandler(new ServiceList(new Service[] { service, new StandaloneProducer(mockProducer) }));
MockChannel channel = new MockChannel();
MockMessageConsumer consumer = new MockMessageConsumer();
StandardWorkflow wf = new StandardWorkflow();
wf.getServiceCollection().add(failingService);
wf.setConsumer(consumer);
channel.setMessageErrorHandler(speh);
channel.getWorkflowList().add(wf);
try {
channel.prepare();
channel.requestStart();
consumer.submitMessage(msg);
assertEquals(1, mockProducer.getMessages().size());
AdaptrisMessage failedMessage = mockProducer.getMessages().get(0);
assertNotSame(XML_PAYLOAD, failedMessage.getContent());
XmlUtils xml = XmlHelper.createXmlUtils(failedMessage);
assertEquals(RAW_DATA, xml.getSingleTextItem(XPATH_ORIGINAL_NODE));
assertNotNull(xml.getSingleNode(XPATH_ROOT + "/Exception"));
String xmlElement = xml.getSingleTextItem(XPATH_ROOT + "/Exception");
assertTrue(xmlElement.contains("com.adaptris.core.services.exception.ThrowExceptionService.doService"));
} finally {
channel.requestClose();
}
}
use of com.adaptris.core.ServiceList in project interlok by adaptris.
the class AdvancedMessageSplitterServiceTest method createServiceImpl.
@Override
protected AdvancedMessageSplitterService createServiceImpl(MessageSplitter splitter, MockMessageProducer producer) {
AdvancedMessageSplitterService service = new AdvancedMessageSplitterService();
service.setSplitter(splitter);
service.setService(new ServiceList(new Service[] { new StandaloneProducer(producer) }));
return service;
}
Aggregations