use of com.adaptris.core.stubs.MockChannel in project interlok by adaptris.
the class JmsTransactedWorkflowTest method createPlainChannel.
private Channel createPlainChannel() throws Exception {
GuidGenerator guid = new GuidGenerator();
Channel result = new MockChannel();
result.setUniqueId(guid.create(result));
result.setMessageErrorHandler(new NullProcessingExceptionHandler());
return result;
}
use of com.adaptris.core.stubs.MockChannel in project interlok by adaptris.
the class FailoverJmsConsumerCase method testBug1012.
@Test
public void testBug1012() throws Exception {
FailoverJmsConnection connection = new FailoverJmsConnection();
try {
List<JmsConnection> ptp = new ArrayList<JmsConnection>();
ptp.add(activeMqBroker.getJmsConnection(new BasicActiveMqImplementation(), true));
ptp.add(activeMqBroker.getJmsConnection(new BasicActiveMqImplementation(), false));
connection.setConnections(ptp);
LifecycleHelper.init(connection);
assertEquals(1, connection.currentJmsConnection().retrieveExceptionListeners().size());
AdaptrisComponent owner = (AdaptrisComponent) connection.currentJmsConnection().retrieveExceptionListeners().toArray()[0];
assertTrue("Owner should be failover connection", connection == owner);
LifecycleHelper.close(connection);
Channel channel = new MockChannel();
connection = new FailoverJmsConnection();
connection.setRegisterOwner(true);
channel.setConsumeConnection(connection);
ptp = new ArrayList<JmsConnection>();
ptp.add(activeMqBroker.getJmsConnection(new BasicActiveMqImplementation(), true));
ptp.add(activeMqBroker.getJmsConnection(new BasicActiveMqImplementation(), false));
connection.setConnections(ptp);
connection.setConnectionAttempts(1);
LifecycleHelper.init(connection);
assertEquals(0, connection.currentJmsConnection().retrieveExceptionListeners().size());
LifecycleHelper.close(connection);
} finally {
LifecycleHelper.close(connection);
}
}
use of com.adaptris.core.stubs.MockChannel 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;
}
use of com.adaptris.core.stubs.MockChannel in project interlok by adaptris.
the class ActiveJmsConnectionErrorHandlerTest method testActiveRestartSharedConnection.
@Test
public void testActiveRestartSharedConnection() throws Exception {
Adapter adapter = new Adapter();
adapter.setUniqueId(testName.getMethodName());
JmsConnection connection = activeMqBroker.getJmsConnection(new BasicActiveMqImplementation(), true);
connection.setConnectionErrorHandler(createErrorHandler());
connection.setUniqueId(testName.getMethodName());
connection.setConnectionRetryInterval(new TimeInterval(5L, "SECONDS"));
connection.setConnectionAttempts(null);
adapter.getSharedComponents().addConnection(connection);
MockChannel channel = createChannel(activeMqBroker, new SharedConnection(testName.getMethodName()), testName.getMethodName());
MockMessageProducer producer = (MockMessageProducer) channel.getWorkflowList().get(0).getProducer();
adapter.getChannelList().add(channel);
try {
adapter.requestStart();
assertEquals(StartedState.getInstance(), channel.retrieveComponentState());
// Now try and send a message
ExampleServiceCase.execute(createProducer(activeMqBroker, testName.getMethodName()), AdaptrisMessageFactory.getDefaultInstance().newMessage("ABC"));
waitForMessages(producer, 1);
activeMqBroker.stop();
log.trace(testName.getMethodName() + ": Waiting for channel death (i.e. !StartedState)");
long totalWaitTime = waitForChannelToChangeState(StartedState.getInstance(), channel);
log.trace(testName.getMethodName() + ": Channel appears to be not started now, and I waited for " + totalWaitTime);
activeMqBroker.start();
totalWaitTime = waitForChannelToMatchState(StartedState.getInstance(), channel);
log.trace(testName.getMethodName() + ": Channel now started now, and I waited for " + totalWaitTime);
assertEquals(StartedState.getInstance(), channel.retrieveComponentState());
// Now try and send a message
ExampleServiceCase.execute(createProducer(activeMqBroker, testName.getMethodName()), AdaptrisMessageFactory.getDefaultInstance().newMessage("ABC"));
waitForMessages(producer, 2);
} finally {
adapter.requestClose();
}
}
use of com.adaptris.core.stubs.MockChannel 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;
}
Aggregations