Search in sources :

Example 36 with MetadataElement

use of com.adaptris.core.MetadataElement 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 37 with MetadataElement

use of com.adaptris.core.MetadataElement 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 38 with MetadataElement

use of com.adaptris.core.MetadataElement 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 39 with MetadataElement

use of com.adaptris.core.MetadataElement in project interlok by adaptris.

the class AddMetadataServiceTest method testFilesizeMetadata.

@Test
public void testFilesizeMetadata() throws CoreException {
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("The Quick Brown Fox Jumps Over The Lazy Dog");
    MetadataElement m3 = new MetadataElement("key3", "$MSG_SIZE$");
    service.addMetadataElement(m3);
    execute(service, msg);
    assertTrue(msg.getMetadataValue("key1").equals("val1"));
    assertTrue(msg.getMetadataValue("key2").equals("val2"));
    assertEquals(String.valueOf(msg.getSize()), msg.getMetadataValue("key3"));
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) MetadataElement(com.adaptris.core.MetadataElement) Test(org.junit.Test)

Example 40 with MetadataElement

use of com.adaptris.core.MetadataElement in project interlok by adaptris.

the class AddMetadataServiceTest method testDoServiceWithReferencedKey.

@Test
public void testDoServiceWithReferencedKey() throws CoreException {
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
    msg.addMessageHeader("key999", "key666");
    m1 = new MetadataElement("$$key999", "value666");
    service = new AddMetadataService();
    service.addMetadataElement(m1);
    execute(service, msg);
    assertEquals("value666", msg.getMetadataValue("key666"));
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) MetadataElement(com.adaptris.core.MetadataElement) Test(org.junit.Test)

Aggregations

MetadataElement (com.adaptris.core.MetadataElement)151 Test (org.junit.Test)101 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)94 XPath (com.adaptris.util.text.xml.XPath)23 Document (org.w3c.dom.Document)19 MetadataCollection (com.adaptris.core.MetadataCollection)18 AddMetadataService (com.adaptris.core.services.metadata.AddMetadataService)18 ServiceException (com.adaptris.core.ServiceException)17 ServiceList (com.adaptris.core.ServiceList)14 Cache (com.adaptris.core.cache.Cache)14 MetadataCacheValueTranslator (com.adaptris.core.services.cache.translators.MetadataCacheValueTranslator)12 ArrayList (java.util.ArrayList)11 CoreException (com.adaptris.core.CoreException)10 Service (com.adaptris.core.Service)10 HashSet (java.util.HashSet)9 ExpiringMapCache (com.adaptris.core.cache.ExpiringMapCache)8 StandaloneProducer (com.adaptris.core.StandaloneProducer)7 StaticCacheValueTranslator (com.adaptris.core.services.cache.translators.StaticCacheValueTranslator)7 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)6 Session (javax.jms.Session)6