use of com.adaptris.core.stubs.MockChannel in project interlok by adaptris.
the class ActiveJmsConnectionErrorHandlerTest method testConnectionErrorHandlerWhileConnectionIsClosed.
@Test
public void testConnectionErrorHandlerWhileConnectionIsClosed() throws Exception {
String queueName = testName.getMethodName() + "_queue";
String topicName = testName.getMethodName() + "_topic";
JmsConnection jmsCon = activeMqBroker.getJndiPasConnection(new StandardJndiImplementation(), false, queueName, topicName);
jmsCon.setConnectionAttempts(null);
MockChannel channel = createChannel(activeMqBroker, jmsCon, topicName);
try {
ActiveJmsConnectionErrorHandler handler = new ActiveJmsConnectionErrorHandler();
handler.setCheckInterval(new TimeInterval(100L, TimeUnit.MILLISECONDS));
handler.setAdditionalLogging(Boolean.TRUE);
channel.getConsumeConnection().setConnectionErrorHandler(handler);
channel.requestStart();
assertEquals(StartedState.getInstance(), channel.retrieveComponentState());
channel.requestClose();
activeMqBroker.stop();
activeMqBroker.start();
assertEquals(ClosedState.getInstance(), channel.retrieveComponentState());
} finally {
channel.requestClose();
}
}
use of com.adaptris.core.stubs.MockChannel in project interlok by adaptris.
the class JmsConnectionErrorHandlerTest method testConnectionErrorHandlerWithJndi.
@Test
public void testConnectionErrorHandlerWithJndi() throws Exception {
String queueName = testName.getMethodName() + "_queue";
String topicName = testName.getMethodName() + "_topic";
MockChannel channel = createChannel(activeMqBroker, activeMqBroker.getJndiPasConnection(new StandardJndiImplementation(), false, queueName, topicName), topicName, new JmsConnectionErrorHandler());
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();
}
}
use of com.adaptris.core.stubs.MockChannel in project interlok by adaptris.
the class JmsConnectionErrorHandlerTest method testConnectionErrorHandler.
@Test
public void testConnectionErrorHandler() throws Exception {
MockChannel channel = createChannel(activeMqBroker, activeMqBroker.getJmsConnection(new BasicActiveMqImplementation(), true), testName.getMethodName(), new JmsConnectionErrorHandler());
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();
}
}
use of com.adaptris.core.stubs.MockChannel 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;
}
use of com.adaptris.core.stubs.MockChannel in project interlok by adaptris.
the class JmsConnectionErrorHandlerTest method testBug1926.
@Test
public void testBug1926() throws Exception {
MockChannel channel = createChannel(activeMqBroker, activeMqBroker.getJmsConnection(new BasicActiveMqImplementation(), true), testName.getMethodName(), new JmsConnectionErrorHandler());
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();
}
}
Aggregations