use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class StandardMessageErrorDigestTest method testMBean_GetMessageDigestMultipleWorkflow.
@Test
public void testMBean_GetMessageDigestMultipleWorkflow() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
adapter.setMessageErrorDigester(new StandardMessageErrorDigester(getName()));
Channel channel1 = createChannel("channel1");
StandardWorkflow workflow1 = createWorkflow("workflow1");
StandardWorkflow workflow2 = createWorkflow("workflow2");
workflow1.getServiceCollection().add(new ThrowExceptionService(new ConfiguredException("fail1")));
workflow2.getServiceCollection().add(new ThrowExceptionService(new ConfiguredException("fail2")));
channel1.getWorkflowList().add(workflow1);
channel1.getWorkflowList().add(workflow2);
adapter.getChannelList().add(channel1);
List<BaseComponentMBean> mBeans = createJmxManagers(adapter);
try {
start(adapter);
register(mBeans);
ObjectName adapterObj = createAdapterObjectName(adapterName);
ObjectName digesterObj = createMessageErrorDigestObjectName(adapterName, getName());
StandardMessageErrorDigesterJmxMBean errDigester = JMX.newMBeanProxy(mBeanServer, digesterObj, StandardMessageErrorDigesterJmxMBean.class);
workflow1.onAdaptrisMessage(new DefaultMessageFactory().newMessage("Hello Workflow1"));
workflow2.onAdaptrisMessage(new DefaultMessageFactory().newMessage("Hello Workflow2"));
// They should have failed.
assertNotNull(errDigester.getDigest());
assertEquals(2, errDigester.getDigest().size());
assertEquals(2, errDigester.getTotalErrorCount());
MessageDigestErrorEntry entry1 = errDigester.getDigest().get(0);
MessageDigestErrorEntry entry2 = errDigester.getDigest().get(1);
assertEquals("workflow1@channel1", entry1.getWorkflowId());
assertEquals("workflow2@channel1", entry2.getWorkflowId());
} finally {
stop(adapter);
}
}
use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class StopProcessingServiceTest method testService.
@Test
public void testService() throws Exception {
AdaptrisMessage msg = new DefaultMessageFactory().newMessage();
execute(new StopProcessingService(), msg);
assertEquals("Stop processing", CoreConstants.STOP_PROCESSING_VALUE, msg.getMetadataValue(CoreConstants.STOP_PROCESSING_KEY));
assertEquals("Skip producer", CoreConstants.STOP_PROCESSING_VALUE, msg.getMetadataValue(CoreConstants.KEY_WORKFLOW_SKIP_PRODUCER));
}
use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class ReadMetadataFromFilesystemTest method testService_NoFile.
@Test
public void testService_NoFile() throws Exception {
String subDir = new GuidGenerator().getUUID().replaceAll(":", "").replaceAll("-", "");
AdaptrisMessage msg = new DefaultMessageFactory().newMessage();
ReadMetadataFromFilesystem service = createService(subDir);
execute(service, msg);
assertFalse(msg.headersContainsKey("key5"));
}
use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class ReadMetadataFromFilesystemTest method testService_DoNotOverwriteExistingMetadata.
@Test
public void testService_DoNotOverwriteExistingMetadata() throws Exception {
String subDir = new GuidGenerator().getUUID().replaceAll(":", "").replaceAll("-", "");
AdaptrisMessage msg = new DefaultMessageFactory().newMessage();
msg.addMetadata("key5", "MyValue");
ReadMetadataFromFilesystem service = createService(subDir);
service.setOverwriteExistingMetadata(false);
File parentDir = FsHelper.createFileReference(FsHelper.createUrlFromString(PROPERTIES.getProperty(BASE_DIR), true));
String propsFilename = parentDir.getCanonicalPath() + "/" + subDir + "/" + msg.getUniqueId();
Properties p = createProperties();
writeProperties(p, new File(propsFilename), false);
execute(service, msg);
assertTrue(msg.headersContainsKey("key5"));
assertEquals("MyValue", msg.getMetadataValue("key5"));
}
use of com.adaptris.core.DefaultMessageFactory in project interlok by adaptris.
the class ReadMetadataFromFilesystemTest method testService_OverwriteExistingMetadata.
@Test
public void testService_OverwriteExistingMetadata() throws Exception {
String subDir = new GuidGenerator().getUUID().replaceAll(":", "").replaceAll("-", "");
AdaptrisMessage msg = new DefaultMessageFactory().newMessage();
msg.addMetadata("key5", "MyValue");
ReadMetadataFromFilesystem service = createService(subDir);
service.setOverwriteExistingMetadata(true);
File parentDir = FsHelper.createFileReference(FsHelper.createUrlFromString(PROPERTIES.getProperty(BASE_DIR), true));
String propsFilename = parentDir.getCanonicalPath() + "/" + subDir + "/" + msg.getUniqueId();
Properties p = createProperties();
writeProperties(p, new File(propsFilename), false);
execute(service, msg);
assertTrue(msg.headersContainsKey("key5"));
assertEquals("v5", msg.getMetadataValue("key5"));
}
Aggregations