use of com.adaptris.core.Workflow in project interlok by adaptris.
the class WorkflowManagerTest method testStop.
@Test
public void testStop() 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());
} finally {
adapter.requestClose();
}
}
use of com.adaptris.core.Workflow in project interlok by adaptris.
the class WorkflowManagerTest method testMBean_NotificationOnClose.
@Test
public void testMBean_NotificationOnClose() 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);
adapterManager.createObjectName();
ObjectName workflowObj = realWorkflowManager.createObjectName();
SimpleNotificationListener listener = new SimpleNotificationListener();
try {
adapterManager.registerMBean();
adapterManager.requestStart();
mBeanServer.addNotificationListener(workflowObj, listener, null, null);
WorkflowManagerMBean workflowManagerProxy = JMX.newMBeanProxy(mBeanServer, workflowObj, WorkflowManagerMBean.class);
workflowManagerProxy.requestClose(TIMEOUT_MILLIS);
assertEquals(ClosedState.getInstance(), workflowManagerProxy.getComponentState());
listener.waitForMessages(1);
// Timing issues under gradle
// assertEquals(1, listener.getNotifications().size());
// Notification n = listener.getNotifications().get(0);
// assertEquals(NOTIF_TYPE_WORKFLOW_LIFECYCLE, n.getType());
// assertEquals(NOTIF_MSG_CLOSED, n.getMessage());
} finally {
mBeanServer.removeNotificationListener(workflowObj, listener);
adapterManager.requestClose();
adapterManager.unregisterMBean();
}
}
use of com.adaptris.core.Workflow in project interlok by adaptris.
the class WorkflowManagerTest method testChannelInitialised_StartWorkflow.
@Test
public void testChannelInitialised_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();
channelManager.requestClose();
channelManager.requestInit();
try {
workflowManagerProxy.requestStart(TIMEOUT_MILLIS);
fail();
} catch (CoreException e) {
assertEquals(createErrorMessageString(InitialisedState.getInstance(), StartedState.getInstance()), e.getMessage());
}
} finally {
adapter.requestClose();
}
}
use of com.adaptris.core.Workflow in project interlok by adaptris.
the class WorkflowManagerTest method testChannelStopped_StopWorkflow.
@Test
public void testChannelStopped_StopWorkflow() 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();
channelManager.requestStop();
workflowManagerProxy.requestStop(TIMEOUT_MILLIS);
} finally {
adapter.requestClose();
}
}
use of com.adaptris.core.Workflow in project interlok by adaptris.
the class WorkflowManagerTest method testGetState.
@Test
public void testGetState() 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(ClosedState.getInstance(), workflowManagerProxy.getComponentState());
} finally {
adapter.requestClose();
}
}
Aggregations