use of com.adaptris.core.Workflow in project interlok by adaptris.
the class ChannelManagerTest method testRemoveChild.
@Test
public void testRemoveChild() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
Channel channel = createChannel(getName());
Workflow workflow1 = createWorkflow(getName() + "_1");
Workflow workflow2 = createWorkflow(getName() + "_2");
ChannelManager channelManager = new ChannelManager(channel, adapterManager);
WorkflowManager child1 = new WorkflowManager(workflow1, channelManager);
WorkflowManager child2 = new WorkflowManager(workflow2, channelManager);
assertEquals(2, channelManager.getChildren().size());
assertTrue(channelManager.removeChild(child1));
assertFalse(channelManager.getChildren().contains(child1.createObjectName()));
assertEquals(1, channelManager.getChildren().size());
try {
channelManager.removeChild(null);
fail();
} catch (IllegalArgumentException expected) {
}
assertEquals(1, channelManager.getChildren().size());
}
use of com.adaptris.core.Workflow in project interlok by adaptris.
the class ChannelManagerTest method testAddChild.
@Test
public void testAddChild() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
Channel channel = createChannel(getName());
Workflow workflow1 = createWorkflow(getName() + "_1");
Workflow workflow2 = createWorkflow(getName() + "_2");
ChannelManager channelManager = new ChannelManager(channel, adapterManager);
WorkflowManager child1 = new WorkflowManager(workflow1, channelManager);
WorkflowManager child2 = new WorkflowManager(workflow2, channelManager);
assertEquals(2, channel.getWorkflowList().size());
assertEquals(2, channelManager.getChildren().size());
try {
channelManager.addChild(child1);
fail();
} catch (IllegalArgumentException expected) {
assertTrue(expected.getMessage().startsWith("duplicate Workflow ID"));
}
assertEquals(2, channelManager.getChildren().size());
try {
channelManager.addChild(null);
fail();
} catch (IllegalArgumentException expected) {
}
assertEquals(2, channelManager.getChildren().size());
}
use of com.adaptris.core.Workflow in project interlok by adaptris.
the class WorkflowManagerTest method testRestart.
@Test
public void testRestart() 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);
Workflow workflow = createWorkflow("w1");
WorkflowManager realWorkflowManager = new WorkflowManager(workflow, channelManager);
List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
adapterManager.createObjectName();
ObjectName workflowObj = realWorkflowManager.createObjectName();
mBeans.add(adapterManager);
mBeans.addAll(adapterManager.getAllDescendants());
try {
register(mBeans);
WorkflowManagerMBean workflowManagerProxy = JMX.newMBeanProxy(mBeanServer, workflowObj, WorkflowManagerMBean.class);
adapterManager.requestStart();
assertEquals(StartedState.getInstance(), workflowManagerProxy.getComponentState());
workflowManagerProxy.requestStop(TIMEOUT_MILLIS);
assertEquals(StoppedState.getInstance(), workflowManagerProxy.getComponentState());
workflowManagerProxy.requestRestart(TIMEOUT_MILLIS);
assertEquals(StartedState.getInstance(), workflowManagerProxy.getComponentState());
} finally {
adapter.requestClose();
}
}
use of com.adaptris.core.Workflow in project interlok by adaptris.
the class WorkflowManagerTest method testChannelStarted_StartWorkflow.
@Test
public void testChannelStarted_StartWorkflow() 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);
Workflow workflow = createWorkflow("w1");
WorkflowManager realWorkflowManager = new WorkflowManager(workflow, channelManager);
List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
adapterManager.createObjectName();
ObjectName workflowObj = realWorkflowManager.createObjectName();
ObjectName channelObj = channelManager.createObjectName();
mBeans.add(adapterManager);
mBeans.addAll(adapterManager.getAllDescendants());
try {
register(mBeans);
WorkflowManagerMBean workflowManagerProxy = JMX.newMBeanProxy(mBeanServer, workflowObj, WorkflowManagerMBean.class);
JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
adapterManager.requestStart();
workflowManagerProxy.requestStart(TIMEOUT_MILLIS);
} finally {
adapter.requestClose();
}
}
use of com.adaptris.core.Workflow in project interlok by adaptris.
the class WorkflowManagerTest method testLastStartTime.
@Test
public void testLastStartTime() 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);
Workflow workflow = createWorkflow("w1");
WorkflowManager realWorkflowManager = new WorkflowManager(workflow, channelManager);
List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
adapterManager.createObjectName();
ObjectName workflowObj = realWorkflowManager.createObjectName();
mBeans.add(adapterManager);
mBeans.addAll(adapterManager.getAllDescendants());
try {
register(mBeans);
WorkflowManagerMBean workflowManagerProxy = JMX.newMBeanProxy(mBeanServer, workflowObj, WorkflowManagerMBean.class);
assertEquals(0, workflowManagerProxy.requestStartTime());
adapterManager.requestStart();
assertTrue(workflowManagerProxy.requestStartTime() > 0);
} finally {
adapter.requestClose();
}
}
Aggregations