Search in sources :

Example 11 with AddMetadataService

use of com.adaptris.core.services.metadata.AddMetadataService in project interlok by adaptris.

the class DynamicServiceExecutorTest method testDoService_MimeServiceExtractor_NullSelector.

@Test
public void testDoService_MimeServiceExtractor_NullSelector() throws Exception {
    AddMetadataService metadataService = new AddMetadataService();
    metadataService.addMetadataElement(new MetadataElement(getName(), getName()));
    DynamicServiceExecutor dynamicService = createService();
    dynamicService.setServiceExtractor(new MimeServiceExtractor());
    AdaptrisMessage msg = createMimeMessage(new ServiceList(new Service[] { metadataService }), ENCODING_BASE64);
    try {
        execute(dynamicService, msg);
        fail();
    } catch (ServiceException expected) {
    }
}
Also used : ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ServiceList(com.adaptris.core.ServiceList) Service(com.adaptris.core.Service) LogMessageService(com.adaptris.core.services.LogMessageService) AddMetadataService(com.adaptris.core.services.metadata.AddMetadataService) MetadataElement(com.adaptris.core.MetadataElement) AddMetadataService(com.adaptris.core.services.metadata.AddMetadataService) Test(org.junit.Test)

Example 12 with AddMetadataService

use of com.adaptris.core.services.metadata.AddMetadataService 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 13 with AddMetadataService

use of com.adaptris.core.services.metadata.AddMetadataService in project interlok by adaptris.

the class ExceptionHandlingServiceWrapperTest method testNoExceptionFromWrappedServices.

@Test
public void testNoExceptionFromWrappedServices() throws Exception {
    AddMetadataService s1 = new AddMetadataService();
    s1.addMetadataElement("servicesComplete", "true");
    ExceptionHandlingServiceWrapper service = create();
    service.setService(s1);
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
    execute(service, msg);
    assertEquals("true", msg.getMetadataValue("servicesComplete"));
    assertNull(msg.getMetadataValue("exceptionServiceTriggered"));
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) AddMetadataService(com.adaptris.core.services.metadata.AddMetadataService) Test(org.junit.Test)

Example 14 with AddMetadataService

use of com.adaptris.core.services.metadata.AddMetadataService 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 15 with AddMetadataService

use of com.adaptris.core.services.metadata.AddMetadataService in project interlok by adaptris.

the class ExampleChannelCase method createServiceCollection.

private ServiceCollection createServiceCollection() throws CoreException {
    ServiceCollection services = new ServiceList();
    AddMetadataService service = new AddMetadataService();
    service.addMetadataElement("key1", "val1");
    services.addService(service);
    services.addService(new LogMessageService());
    return services;
}
Also used : ServiceCollection(com.adaptris.core.ServiceCollection) ServiceList(com.adaptris.core.ServiceList) LogMessageService(com.adaptris.core.services.LogMessageService) AddMetadataService(com.adaptris.core.services.metadata.AddMetadataService)

Aggregations

AddMetadataService (com.adaptris.core.services.metadata.AddMetadataService)46 Test (org.junit.Test)35 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)22 ThrowExceptionService (com.adaptris.core.services.exception.ThrowExceptionService)20 MetadataElement (com.adaptris.core.MetadataElement)18 PayloadFromTemplateService (com.adaptris.core.services.metadata.PayloadFromTemplateService)18 MockChannel (com.adaptris.core.stubs.MockChannel)18 ServiceList (com.adaptris.core.ServiceList)16 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)15 FailFirstMockMessageProducer (com.adaptris.core.stubs.FailFirstMockMessageProducer)15 MockSkipProducerService (com.adaptris.core.stubs.MockSkipProducerService)15 Service (com.adaptris.core.Service)10 Iterator (java.util.Iterator)10 EventHandlerAwareService (com.adaptris.core.stubs.EventHandlerAwareService)9 StandaloneProducer (com.adaptris.core.StandaloneProducer)8 LogMessageService (com.adaptris.core.services.LogMessageService)7 StaticMockMessageProducer (com.adaptris.core.stubs.StaticMockMessageProducer)6 Channel (com.adaptris.core.Channel)5 ArrayList (java.util.ArrayList)4 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)3