Search in sources :

Example 31 with Workflow

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());
}
Also used : Channel(com.adaptris.core.Channel) PoolingWorkflow(com.adaptris.core.PoolingWorkflow) StandardWorkflow(com.adaptris.core.StandardWorkflow) Workflow(com.adaptris.core.Workflow) Adapter(com.adaptris.core.Adapter) Test(org.junit.Test)

Example 32 with Workflow

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());
}
Also used : Channel(com.adaptris.core.Channel) PoolingWorkflow(com.adaptris.core.PoolingWorkflow) StandardWorkflow(com.adaptris.core.StandardWorkflow) Workflow(com.adaptris.core.Workflow) Adapter(com.adaptris.core.Adapter) Test(org.junit.Test)

Example 33 with Workflow

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();
    }
}
Also used : Channel(com.adaptris.core.Channel) ArrayList(java.util.ArrayList) PoolingWorkflow(com.adaptris.core.PoolingWorkflow) StandardWorkflow(com.adaptris.core.StandardWorkflow) Workflow(com.adaptris.core.Workflow) Adapter(com.adaptris.core.Adapter) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 34 with Workflow

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();
    }
}
Also used : Channel(com.adaptris.core.Channel) ArrayList(java.util.ArrayList) PoolingWorkflow(com.adaptris.core.PoolingWorkflow) StandardWorkflow(com.adaptris.core.StandardWorkflow) Workflow(com.adaptris.core.Workflow) Adapter(com.adaptris.core.Adapter) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 35 with Workflow

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();
    }
}
Also used : Channel(com.adaptris.core.Channel) ArrayList(java.util.ArrayList) PoolingWorkflow(com.adaptris.core.PoolingWorkflow) StandardWorkflow(com.adaptris.core.StandardWorkflow) Workflow(com.adaptris.core.Workflow) Adapter(com.adaptris.core.Adapter) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Aggregations

Workflow (com.adaptris.core.Workflow)53 StandardWorkflow (com.adaptris.core.StandardWorkflow)49 Channel (com.adaptris.core.Channel)44 PoolingWorkflow (com.adaptris.core.PoolingWorkflow)44 Test (org.junit.Test)43 Adapter (com.adaptris.core.Adapter)40 ObjectName (javax.management.ObjectName)30 ArrayList (java.util.ArrayList)27 CoreException (com.adaptris.core.CoreException)8 MockChannel (com.adaptris.core.stubs.MockChannel)5 Notification (javax.management.Notification)3 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)2 MessageMetricsInterceptor (com.adaptris.core.interceptor.MessageMetricsInterceptor)2 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)2 StaticMockMessageProducer (com.adaptris.core.stubs.StaticMockMessageProducer)2 TimeInterval (com.adaptris.util.TimeInterval)2 DefaultEventHandler (com.adaptris.core.DefaultEventHandler)1 NullProcessingExceptionHandler (com.adaptris.core.NullProcessingExceptionHandler)1 XStreamMarshaller (com.adaptris.core.XStreamMarshaller)1