Search in sources :

Example 26 with ServiceList

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;
}
Also used : ExpiringMapCache(com.adaptris.core.cache.ExpiringMapCache) ServiceList(com.adaptris.core.ServiceList) LogMessageService(com.adaptris.core.services.LogMessageService) CacheConnection(com.adaptris.core.services.cache.CacheConnection)

Example 27 with ServiceList

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;
}
Also used : ServiceList(com.adaptris.core.ServiceList) Service(com.adaptris.core.Service) AddMetadataService(com.adaptris.core.services.metadata.AddMetadataService) MetadataElement(com.adaptris.core.MetadataElement) AddMetadataService(com.adaptris.core.services.metadata.AddMetadataService)

Example 28 with ServiceList

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"));
}
Also used : DefaultEventHandler(com.adaptris.core.DefaultEventHandler) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ServiceList(com.adaptris.core.ServiceList) Service(com.adaptris.core.Service) AddMetadataService(com.adaptris.core.services.metadata.AddMetadataService) MetadataElement(com.adaptris.core.MetadataElement) AddMetadataService(com.adaptris.core.services.metadata.AddMetadataService) Test(org.junit.Test)

Example 29 with ServiceList

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();
    }
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) StandardWorkflow(com.adaptris.core.StandardWorkflow) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) XmlUtils(com.adaptris.util.XmlUtils) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ServiceList(com.adaptris.core.ServiceList) Service(com.adaptris.core.Service) ServiceImp(com.adaptris.core.ServiceImp) StandardProcessingExceptionHandler(com.adaptris.core.StandardProcessingExceptionHandler) MockMessageConsumer(com.adaptris.core.stubs.MockMessageConsumer) InsertNode(com.adaptris.util.text.xml.InsertNode) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 30 with ServiceList

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;
}
Also used : ServiceList(com.adaptris.core.ServiceList) Service(com.adaptris.core.Service) ThrowExceptionService(com.adaptris.core.services.exception.ThrowExceptionService) StandaloneProducer(com.adaptris.core.StandaloneProducer)

Aggregations

ServiceList (com.adaptris.core.ServiceList)64 Test (org.junit.Test)52 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)43 StandaloneProducer (com.adaptris.core.StandaloneProducer)39 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)33 Channel (com.adaptris.core.Channel)31 JettyHelper.createChannel (com.adaptris.core.http.jetty.JettyHelper.createChannel)29 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)23 HttpConnection (com.adaptris.core.http.jetty.HttpConnection)20 JettyMessageConsumer (com.adaptris.core.http.jetty.JettyMessageConsumer)20 StandardResponseProducer (com.adaptris.core.http.jetty.StandardResponseProducer)20 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)18 HttpConsumerTest (com.adaptris.core.http.jetty.HttpConsumerTest)18 PayloadFromTemplateService (com.adaptris.core.services.metadata.PayloadFromTemplateService)17 Service (com.adaptris.core.Service)16 AddMetadataService (com.adaptris.core.services.metadata.AddMetadataService)16 MetadataElement (com.adaptris.core.MetadataElement)14 ConfiguredRequestMethodProvider (com.adaptris.core.http.client.ConfiguredRequestMethodProvider)11 LogMessageService (com.adaptris.core.services.LogMessageService)11 StandardWorkflow (com.adaptris.core.StandardWorkflow)10