Search in sources :

Example 11 with Workflow

use of com.adaptris.core.Workflow in project interlok by adaptris.

the class WorkflowManagerTest method testClose.

@Test
public void testClose() 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.requestClose(TIMEOUT_MILLIS);
        assertEquals(ClosedState.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 12 with Workflow

use of com.adaptris.core.Workflow in project interlok by adaptris.

the class WorkflowManagerTest method testChannelClosed_StartWorkflow.

@Test
public void testChannelClosed_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);
        ChannelManagerMBean channelManagerProxy = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
        adapterManager.requestStart();
        channelManagerProxy.requestClose(TIMEOUT_MILLIS);
        try {
            workflowManagerProxy.requestStart(TIMEOUT_MILLIS);
            fail();
        } catch (CoreException e) {
            assertEquals(createErrorMessageString(ClosedState.getInstance(), StartedState.getInstance()), e.getMessage());
        }
    } 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) CoreException(com.adaptris.core.CoreException) Test(org.junit.Test)

Example 13 with Workflow

use of com.adaptris.core.Workflow in project interlok by adaptris.

the class WorkflowManagerTest method testGetConfiguration.

@Test
public void testGetConfiguration() 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 workflowManager = new WorkflowManager(workflow, channelManager);
    Workflow marshalledWorkflow = (Workflow) new XStreamMarshaller().unmarshal(workflowManager.getConfiguration());
    assertRoundtripEquality(workflow, marshalledWorkflow);
    Channel marshalledChannel = (Channel) new XStreamMarshaller().unmarshal(channelManager.getConfiguration());
    assertRoundtripEquality(channel, marshalledChannel);
    Adapter marshalledAdapter = (Adapter) new XStreamMarshaller().unmarshal(adapterManager.getConfiguration());
    assertRoundtripEquality(adapter, marshalledAdapter);
}
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) XStreamMarshaller(com.adaptris.core.XStreamMarshaller) Test(org.junit.Test)

Example 14 with Workflow

use of com.adaptris.core.Workflow in project interlok by adaptris.

the class WorkflowManagerTest method testMessageCounter_Enabled.

@Test
public void testMessageCounter_Enabled() 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");
    new WorkflowManager(workflow, channelManager);
    assertEquals(2, workflow.getInterceptors().size());
    assertEquals(MessageMetricsInterceptor.class, workflow.getInterceptors().get(0).getClass());
    assertEquals(InFlightWorkflowInterceptor.class, workflow.getInterceptors().get(1).getClass());
}
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 15 with Workflow

use of com.adaptris.core.Workflow in project interlok by adaptris.

the class WorkflowManagerTest method testChannelClosed_CloseWorkflow.

@Test
public void testChannelClosed_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);
        ChannelManagerMBean channelManagerProxy = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
        adapterManager.requestStart();
        channelManagerProxy.requestClose(TIMEOUT_MILLIS);
        workflowManagerProxy.requestClose(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)

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