Search in sources :

Example 51 with Workflow

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

the class EmbeddedHttpConsumerTest method testBasicConsumeWorkflow_UpdatedConfig.

// INTERLOK-201
@Test
public void testBasicConsumeWorkflow_UpdatedConfig() throws Exception {
    EmbeddedJettyHelper helper = new EmbeddedJettyHelper();
    helper.startServer();
    MockMessageProducer mockProducer = new MockMessageProducer();
    MockMessageProducer mock2 = new MockMessageProducer();
    Channel channel = JettyHelper.createChannel(new EmbeddedConnection(), JettyHelper.createConsumer(URL_TO_POST_TO), mockProducer);
    Workflow workflow = JettyHelper.createWorkflow(JettyHelper.createConsumer(URL_TO_POST_TO), mock2);
    try {
        channel.requestStart();
        channel.requestClose();
        // Update the configuration.
        channel.getWorkflowList().clear();
        channel.getWorkflowList().add(workflow);
        // Now restart
        channel.requestStart();
        AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML_PAYLOAD);
        msg.addMetadata(CONTENT_TYPE_METADATA_KEY, "text/xml");
        httpProducer.setUrl(helper.createProduceDestination());
        start(httpProducer);
        AdaptrisMessage reply = httpProducer.request(msg);
        assertEquals("Reply Payloads", XML_PAYLOAD, reply.getContent());
        doAssertions(mock2);
    } finally {
        stop(httpProducer);
        channel.requestClose();
        helper.stopServer();
    }
}
Also used : MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) StaticMockMessageProducer(com.adaptris.core.stubs.StaticMockMessageProducer) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Channel(com.adaptris.core.Channel) PoolingWorkflow(com.adaptris.core.PoolingWorkflow) StandardWorkflow(com.adaptris.core.StandardWorkflow) Workflow(com.adaptris.core.Workflow) Test(org.junit.Test)

Example 52 with Workflow

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

the class JettyHelper method createChannel.

public static Channel createChannel(AdaptrisConnection connection, Workflow... workflows) throws Exception {
    Channel result = new MockChannel();
    result.setUniqueId("channel");
    result.registerEventHandler(createEventHandler());
    result.setMessageErrorHandler(new NullProcessingExceptionHandler());
    result.setConsumeConnection(connection);
    for (Workflow w : workflows) {
        result.getWorkflowList().add(w);
    }
    return result;
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) MockChannel(com.adaptris.core.stubs.MockChannel) Channel(com.adaptris.core.Channel) StandardWorkflow(com.adaptris.core.StandardWorkflow) Workflow(com.adaptris.core.Workflow) NullProcessingExceptionHandler(com.adaptris.core.NullProcessingExceptionHandler)

Example 53 with Workflow

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

the class HttpConsumerTest method testBasicConsumeWorkflow_UpdatedConfig.

@Test
public void testBasicConsumeWorkflow_UpdatedConfig() throws Exception {
    HttpConnection connection = createConnection(null);
    MockMessageProducer mockProducer = new MockMessageProducer();
    MockMessageProducer mock2 = new MockMessageProducer();
    Channel channel = JettyHelper.createChannel(connection, JettyHelper.createConsumer(URL_TO_POST_TO), mockProducer);
    Workflow workflow = JettyHelper.createWorkflow(JettyHelper.createConsumer(URL_TO_POST_TO), mock2);
    try {
        channel.requestStart();
        channel.requestClose();
        channel.getWorkflowList().clear();
        channel.getWorkflowList().add(workflow);
        channel.requestStart();
        AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML_PAYLOAD);
        msg.addMetadata(CONTENT_TYPE_METADATA_KEY, "text/xml");
        httpProducer.setUrl(createProduceDestinationUrl(connection.getPort()));
        start(httpProducer);
        AdaptrisMessage reply = httpProducer.request(msg);
        assertEquals("Reply Payloads", XML_PAYLOAD, reply.getContent());
        doAssertions(mock2);
    } finally {
        stop(httpProducer);
        channel.requestClose();
        PortManager.release(connection.getPort());
    }
}
Also used : MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) StaticMockMessageProducer(com.adaptris.core.stubs.StaticMockMessageProducer) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Channel(com.adaptris.core.Channel) PoolingWorkflow(com.adaptris.core.PoolingWorkflow) StandardWorkflow(com.adaptris.core.StandardWorkflow) Workflow(com.adaptris.core.Workflow) 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