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) {
}
}
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;
}
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"));
}
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"));
}
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"));
}
Aggregations