use of com.adaptris.core.StandardWorkflow in project interlok by adaptris.
the class WorkflowManagerTest method testInjectWithReply.
@Test
public void testInjectWithReply() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
Channel channel = createChannel("c1");
ChannelManager channelManager = new ChannelManager(channel, adapterManager);
StandardWorkflow workflow = createWorkflow("w1");
workflow.getServiceCollection().add(new AddMetadataService(Arrays.asList(new MetadataElement(getName(), getName()))));
WorkflowManager realWorkflowManager = new WorkflowManager(workflow, channelManager);
adapterManager.createObjectName();
ObjectName workflowObj = realWorkflowManager.createObjectName();
channelManager.createObjectName();
List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
mBeans.add(adapterManager);
mBeans.addAll(adapterManager.getAllDescendants());
String msgUniqueId = new GuidGenerator().getUUID();
SerializableAdaptrisMessage msg = createSAM(msgUniqueId);
try {
register(mBeans);
WorkflowManagerMBean workflowManagerProxy = JMX.newMBeanProxy(mBeanServer, workflowObj, WorkflowManagerMBean.class);
adapterManager.requestStart();
SerializableAdaptrisMessage reply = (SerializableAdaptrisMessage) workflowManagerProxy.process(msg);
assertEquals(msgUniqueId, reply.getUniqueId());
assertEquals(PAYLOAD, reply.getContent());
assertEquals(PAYLOAD_ENCODING, reply.getContentEncoding());
assertTrue(reply.containsKey(METADATA_KEY));
assertEquals(METADATA_VALUE, reply.getMetadataValue(METADATA_KEY));
assertTrue(reply.containsKey(getName()));
assertEquals(getName(), reply.getMetadataValue(getName()));
} finally {
adapter.requestClose();
}
}
use of com.adaptris.core.StandardWorkflow 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.StandardWorkflow in project interlok by adaptris.
the class WorkflowManagerTest method testProcessAsync.
@Test
public void testProcessAsync() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
Channel channel = createChannel("c1");
ChannelManager channelManager = new ChannelManager(channel, adapterManager);
StandardWorkflow workflow = createWorkflow("w1");
MockMessageProducer mockProducer = new MockMessageProducer();
workflow.setProducer(mockProducer);
WorkflowManager realWorkflowManager = new WorkflowManager(workflow, channelManager);
adapterManager.createObjectName();
ObjectName workflowObj = realWorkflowManager.createObjectName();
channelManager.createObjectName();
List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
mBeans.add(adapterManager);
mBeans.addAll(adapterManager.getAllDescendants());
String msgUniqueId = new GuidGenerator().getUUID();
SerializableMessage msg = createSM(msgUniqueId);
try {
register(mBeans);
MessageProcessor workflowManagerProxy = JMX.newMBeanProxy(mBeanServer, workflowObj, MessageProcessor.class);
adapterManager.requestStart();
workflowManagerProxy.processAsync(msg);
assertEquals(1, mockProducer.getMessages().size());
AdaptrisMessage procMsg = mockProducer.getMessages().get(0);
assertEquals(msgUniqueId, procMsg.getUniqueId());
assertEquals(PAYLOAD, procMsg.getContent());
assertEquals(PAYLOAD_ENCODING, procMsg.getContentEncoding());
assertTrue(procMsg.headersContainsKey(METADATA_KEY));
assertEquals(METADATA_VALUE, procMsg.getMetadataValue(METADATA_KEY));
} finally {
adapter.requestClose();
}
}
use of com.adaptris.core.StandardWorkflow 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();
}
}
use of com.adaptris.core.StandardWorkflow in project interlok by adaptris.
the class ExampleErrorHandlerCase method createChannel.
protected Channel createChannel(MockMessageConsumer consumer, ProcessingExceptionHandler ceh, ProcessingExceptionHandler weh, Service... services) {
StandardWorkflow workflow = createWorkflow(consumer, weh, services);
Channel c = new Channel();
c.setMessageErrorHandler(ceh);
c.getWorkflowList().add(workflow);
return c;
}
Aggregations