Search in sources :

Example 1 with Workflow

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

the class ActiveJmsConnectionErrorHandlerTest method createChannel.

private MockChannel createChannel(EmbeddedActiveMq mq, JmsConnection con, String destName) throws Exception {
    MockChannel result = new MockChannel();
    result.setUniqueId(testName.getMethodName() + "_channel");
    con.setConnectionRetryInterval(new TimeInterval(100L, TimeUnit.MILLISECONDS.name()));
    con.setConnectionAttempts(50);
    con.setConnectionErrorHandler(createErrorHandler());
    result.setConsumeConnection(con);
    Workflow workflow = createWorkflow(mq, destName);
    result.getWorkflowList().add(workflow);
    return result;
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) TimeInterval(com.adaptris.util.TimeInterval) StandardWorkflow(com.adaptris.core.StandardWorkflow) Workflow(com.adaptris.core.Workflow)

Example 2 with Workflow

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

the class ActiveJmsConnectionErrorHandlerTest method createChannel.

private MockChannel createChannel(EmbeddedActiveMq mq, SharedConnection con, String destinationName) throws Exception {
    MockChannel result = new MockChannel();
    result.setUniqueId(mq.getName() + "_channel" + "_" + destinationName);
    result.setConsumeConnection(con);
    Workflow workflow = createWorkflow(mq, destinationName);
    result.getWorkflowList().add(workflow);
    return result;
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) StandardWorkflow(com.adaptris.core.StandardWorkflow) Workflow(com.adaptris.core.Workflow)

Example 3 with Workflow

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

the class JmsConnectionErrorHandlerTest method createChannel.

private MockChannel createChannel(String channelName, EmbeddedActiveMq mq, JmsConnection con, String destinationName, JmsConnectionErrorHandler handler) throws Exception {
    MockChannel result = new MockChannel();
    result.setUniqueId(channelName);
    con.setConnectionRetryInterval(new TimeInterval(1L, TimeUnit.SECONDS.name()));
    con.setConnectionAttempts(50);
    con.setConnectionErrorHandler(handler);
    result.setConsumeConnection(con);
    Workflow workflow = createWorkflow(mq, destinationName);
    result.getWorkflowList().add(workflow);
    return result;
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) TimeInterval(com.adaptris.util.TimeInterval) StandardWorkflow(com.adaptris.core.StandardWorkflow) Workflow(com.adaptris.core.Workflow)

Example 4 with Workflow

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

the class ChannelManagerTest method testRemoveChildren.

@Test
public void testRemoveChildren() 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);
    List<WorkflowRuntimeManager> workflows = new ArrayList<WorkflowRuntimeManager>(Arrays.asList(new WorkflowManager[] { child1, child2 }));
    assertEquals(2, channelManager.getChildren().size());
    assertEquals(2, channel.getWorkflowList().size());
    assertTrue(channelManager.removeChildren(workflows));
    assertFalse(channelManager.removeChildren(workflows));
    assertEquals(0, channelManager.getChildren().size());
    assertEquals(0, channel.getWorkflowList().size());
}
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) Test(org.junit.Test)

Example 5 with Workflow

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

the class WorkflowManagerTest method testMBean_NotificationOnInit.

@Test
public void testMBean_NotificationOnInit() 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.requestInit(TIMEOUT_MILLIS);
        assertEquals(InitialisedState.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_INITIALISED, n.getMessage());
    } finally {
        mBeanServer.removeNotificationListener(workflowObj, listener);
        adapterManager.requestClose();
        adapterManager.unregisterMBean();
    }
}
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) Notification(javax.management.Notification) 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