use of com.adaptris.core.StandardWorkflow in project interlok by adaptris.
the class WorkflowManagerTest method testAddChildRuntimeComponent.
@Test
public void testAddChildRuntimeComponent() 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.setDisableDefaultMessageCount(true);
WorkflowManager workflowManager = new WorkflowManager(workflow, channelManager);
WorkflowChild child = new WorkflowChild(workflowManager);
new WorkflowChild(workflowManager);
assertTrue(workflowManager.addChildJmxComponent(child));
assertFalse(workflowManager.addChildJmxComponent(child));
try {
workflowManager.addChildJmxComponent(null);
fail();
} catch (IllegalArgumentException expected) {
}
assertEquals(1, workflowManager.getChildRuntimeInfoComponents().size());
}
use of com.adaptris.core.StandardWorkflow in project interlok by adaptris.
the class WorkflowManagerTest method testInjectMessage.
@Test
public void testInjectMessage() 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();
SerializableAdaptrisMessage msg = createSAM(msgUniqueId);
try {
register(mBeans);
WorkflowManagerMBean workflowManagerProxy = JMX.newMBeanProxy(mBeanServer, workflowObj, WorkflowManagerMBean.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 WorkflowManagerTest method testProcess.
@Test
public void testProcess() 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();
SerializableMessage msg = createSM(msgUniqueId);
try {
register(mBeans);
MessageProcessor workflowManagerProxy = JMX.newMBeanProxy(mBeanServer, workflowObj, MessageProcessor.class);
adapterManager.requestStart();
SerializableMessage reply = workflowManagerProxy.process(msg);
assertEquals(msgUniqueId, reply.getUniqueId());
assertEquals(PAYLOAD, reply.getContent());
assertEquals(PAYLOAD_ENCODING, reply.getContentEncoding());
Map<String, String> headers = reply.getMessageHeaders();
assertTrue(headers.containsKey(METADATA_KEY));
assertEquals(METADATA_VALUE, headers.get(METADATA_KEY));
assertTrue(headers.containsKey(getName()));
assertEquals(getName(), headers.get(getName()));
assertEquals("", reply.getNextServiceId());
} finally {
adapter.requestClose();
}
}
use of com.adaptris.core.StandardWorkflow in project interlok by adaptris.
the class WorkflowManagerTest method testWorkflowManager_HasRetryMonitor.
@Test
public void testWorkflowManager_HasRetryMonitor() 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.setMessageErrorHandler(new RetryMessageErrorHandler(getName()));
WorkflowManager realWorkflowManager = new WorkflowManager(workflow, channelManager);
adapterManager.createObjectName();
ObjectName workflowObj = realWorkflowManager.createObjectName();
try {
adapterManager.registerMBean();
adapterManager.requestStart();
ObjectName handlerObjectName = ObjectName.getInstance(JMX_RETRY_MONITOR_TYPE + realWorkflowManager.createObjectHierarchyString() + ID_PREFIX + getName());
WorkflowManagerMBean workflowManagerProxy = JMX.newMBeanProxy(mBeanServer, workflowObj, WorkflowManagerMBean.class);
assertTrue(workflowManagerProxy.getChildRuntimeInfoComponents().contains(handlerObjectName));
RetryMessageErrorHandlerMonitorMBean monitor = JMX.newMBeanProxy(mBeanServer, handlerObjectName, RetryMessageErrorHandlerMonitorMBean.class);
} finally {
adapterManager.requestClose();
adapterManager.unregisterMBean();
}
}
use of com.adaptris.core.StandardWorkflow in project interlok by adaptris.
the class WorkflowManagerTest method testRemoveChildRuntimeComponent.
@Test
public void testRemoveChildRuntimeComponent() 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.setDisableDefaultMessageCount(true);
WorkflowManager workflowManager = new WorkflowManager(workflow, channelManager);
WorkflowChild child = new WorkflowChild(workflowManager);
WorkflowChild child2 = new WorkflowChild(workflowManager);
assertTrue(workflowManager.addChildJmxComponent(child));
try {
workflowManager.removeChildJmxComponent(null);
fail();
} catch (IllegalArgumentException expected) {
}
assertTrue(workflowManager.removeChildJmxComponent(child));
assertFalse(workflowManager.removeChildJmxComponent(child2));
assertEquals(0, workflowManager.getChildRuntimeInfoComponents().size());
}
Aggregations