Search in sources :

Example 81 with MockChannel

use of com.adaptris.core.stubs.MockChannel in project interlok by adaptris.

the class ActiveMqJmsTransactedWorkflowTest method createStartableChannel.

private Channel createStartableChannel(Workflow w) throws Exception {
    Channel channel = new MockChannel();
    channel.getWorkflowList().add(w);
    channel.prepare();
    return channel;
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) MockChannel(com.adaptris.core.stubs.MockChannel) Channel(com.adaptris.core.Channel)

Example 82 with MockChannel

use of com.adaptris.core.stubs.MockChannel in project interlok by adaptris.

the class ActiveMqJmsTransactedWorkflowTest method createPlainChannel.

private Channel createPlainChannel(EmbeddedActiveMq mq, boolean isPtp) throws Exception {
    Channel result = new MockChannel();
    result.setUniqueId(mq.getName() + "_channel");
    result.setConsumeConnection(isPtp ? mq.getJmsConnection() : mq.getJmsConnection());
    return result;
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) MockChannel(com.adaptris.core.stubs.MockChannel) Channel(com.adaptris.core.Channel)

Example 83 with MockChannel

use of com.adaptris.core.stubs.MockChannel in project interlok by adaptris.

the class JmsConnectionErrorHandlerTest method testConnectionErrorHandler_WithRuntimeException.

// Tests INTERLOK-2063
@Test
public void testConnectionErrorHandler_WithRuntimeException() throws Exception {
    MockChannel channel = createChannel(activeMqBroker, new JmsConnectionCloseWithRuntimeException(activeMqBroker.getJmsConnection(new BasicActiveMqImplementation(), true)), testName.getMethodName(), new JmsConnectionErrorHandler() {

        @Override
        protected long retryWaitTimeMs() {
            return 500L;
        }
    });
    try {
        channel.requestStart();
        assertEquals(StartedState.getInstance(), channel.retrieveComponentState());
        activeMqBroker.stop();
        Thread.sleep(1000);
        activeMqBroker.start();
        waitForChannelToMatchState(StartedState.getInstance(), channel);
        assertEquals(StartedState.getInstance(), channel.retrieveComponentState());
        assertEquals(2, channel.getStartCount());
    } finally {
        channel.requestClose();
    }
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) JmsConnectionErrorHandler(com.adaptris.core.jms.JmsConnectionErrorHandler) Test(org.junit.Test)

Example 84 with MockChannel

use of com.adaptris.core.stubs.MockChannel in project interlok by adaptris.

the class JmsConnectionErrorHandlerTest method testConnectionErrorHandler_NotSingleExecution.

@Test
public void testConnectionErrorHandler_NotSingleExecution() throws Exception {
    MockChannel channel = createChannel(activeMqBroker, activeMqBroker.getJmsConnection(new BasicActiveMqImplementation(), true), testName.getMethodName(), new JmsConnectionErrorHandler(false));
    try {
        channel.requestStart();
        assertEquals(StartedState.getInstance(), channel.retrieveComponentState());
        activeMqBroker.stop();
        Thread.sleep(1000);
        activeMqBroker.start();
        waitForChannelToMatchState(StartedState.getInstance(), channel);
        assertEquals(StartedState.getInstance(), channel.retrieveComponentState());
        assertEquals(2, channel.getStartCount());
    } finally {
        channel.requestClose();
    }
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) JmsConnectionErrorHandler(com.adaptris.core.jms.JmsConnectionErrorHandler) Test(org.junit.Test)

Example 85 with MockChannel

use of com.adaptris.core.stubs.MockChannel in project interlok by adaptris.

the class JmsConnectionErrorHandlerTest method testConnectionErrorHandlerWithUnamedChannel.

@Test
public void testConnectionErrorHandlerWithUnamedChannel() throws Exception {
    MockChannel channel = createChannel(null, activeMqBroker, activeMqBroker.getJmsConnection(new BasicActiveMqImplementation(), true), testName.getMethodName());
    try {
        channel.requestStart();
        assertEquals(StartedState.getInstance(), channel.retrieveComponentState());
        activeMqBroker.stop();
        Thread.sleep(1000);
        activeMqBroker.start();
        waitForChannelToMatchState(StartedState.getInstance(), channel);
        assertEquals(StartedState.getInstance(), channel.retrieveComponentState());
        assertEquals(2, channel.getStartCount());
    } finally {
        channel.requestClose();
    }
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) Test(org.junit.Test)

Aggregations

MockChannel (com.adaptris.core.stubs.MockChannel)145 Test (org.junit.Test)125 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)92 ThrowExceptionService (com.adaptris.core.services.exception.ThrowExceptionService)62 MockSkipProducerService (com.adaptris.core.stubs.MockSkipProducerService)59 PayloadFromTemplateService (com.adaptris.core.services.metadata.PayloadFromTemplateService)56 AddMetadataService (com.adaptris.core.services.metadata.AddMetadataService)44 FailFirstMockMessageProducer (com.adaptris.core.stubs.FailFirstMockMessageProducer)40 StaticMockMessageProducer (com.adaptris.core.stubs.StaticMockMessageProducer)32 TimeInterval (com.adaptris.util.TimeInterval)28 EventHandlerAwareService (com.adaptris.core.stubs.EventHandlerAwareService)22 Iterator (java.util.Iterator)17 StandardWorkflow (com.adaptris.core.StandardWorkflow)13 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)13 ConfiguredException (com.adaptris.core.services.exception.ConfiguredException)11 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)10 Channel (com.adaptris.core.Channel)10 JmsConnectionErrorHandler (com.adaptris.core.jms.JmsConnectionErrorHandler)9 MockMessageConsumer (com.adaptris.core.stubs.MockMessageConsumer)9 JmsConnection (com.adaptris.core.jms.JmsConnection)8