use of com.adaptris.core.Workflow in project interlok by adaptris.
the class WorkflowManagerTest method testMBean_NotificationOnStart.
@Test
public void testMBean_NotificationOnStart() 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);
workflowManagerProxy.requestStart(TIMEOUT_MILLIS);
assertEquals(StartedState.getInstance(), workflowManagerProxy.getComponentState());
listener.waitForMessages(2);
assertEquals(2, listener.getNotifications().size());
Notification n = listener.getNotifications().get(1);
assertEquals(NOTIF_TYPE_WORKFLOW_LIFECYCLE, n.getType());
assertEquals(NOTIF_MSG_STARTED, 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 testChannelStarted_InitWorkflow.
@Test
public void testChannelStarted_InitWorkflow() 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.requestClose(TIMEOUT_MILLIS);
workflowManagerProxy.requestInit(TIMEOUT_MILLIS);
} finally {
adapter.requestClose();
}
}
use of com.adaptris.core.Workflow in project interlok by adaptris.
the class WorkflowManagerTest method testChannelStarted_CloseWorkflow.
@Test
public void testChannelStarted_CloseWorkflow() 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.requestClose(TIMEOUT_MILLIS);
} finally {
adapter.requestClose();
}
}
use of com.adaptris.core.Workflow in project interlok by adaptris.
the class WorkflowManagerTest method testMBean_NotificationOnRestart.
@Test
public void testMBean_NotificationOnRestart() 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.requestRestart(TIMEOUT_MILLIS);
assertEquals(StartedState.getInstance(), workflowManagerProxy.getComponentState());
// restart generated 3 notificates 1-close 2-start 3-restart
// Timing issue on Jenkins, doesn't happen locally.
// listener.waitForMessages(3);
// assertEquals(3, listener.getNotifications().size());
// Notification n = listener.getNotifications().get(2);
// assertEquals(NOTIF_TYPE_WORKFLOW_LIFECYCLE, n.getType());
// assertEquals(NOTIF_MSG_RESTARTED, 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 testEqualityHashCode.
@Test
public void testEqualityHashCode() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
AdapterManager am1 = new AdapterManager(createAdapter(adapterName));
AdapterManager am2 = new AdapterManager(createAdapter(adapterName));
AdapterManager fam = new AdapterManager(createAdapter(adapterName));
ChannelManager cm1 = new ChannelManager(createChannel("c1"), am1);
ChannelManager cm2 = new ChannelManager(createChannel("c1"), am2);
ChannelManager fcm = new ChannelManager(createChannel("c1"), fam);
Workflow workflow = createWorkflow("w1");
WorkflowManager wm1 = new WorkflowManager(workflow, cm1);
WorkflowManager wm2 = new WorkflowManager(workflow, cm2);
WorkflowManager fm = new FailingWorkflowManager(workflow, fcm);
WorkflowManager wm3 = new WorkflowManager(createWorkflow("w2"), cm1);
assertEquals(wm1, wm1);
assertEquals(wm1, wm2);
assertNotSame(wm1, wm3);
assertFalse(wm1.equals(fm));
assertFalse(wm1.equals(new Object()));
assertFalse(wm1.equals(null));
assertEquals(wm1.hashCode(), wm1.hashCode());
}
Aggregations