use of com.adaptris.core.services.exception.ThrowExceptionService in project interlok by adaptris.
the class RetryFromJettyTest method testExecuteQuietly.
@Test
public void testExecuteQuietly() throws Exception {
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
NullService s1 = new NullService();
ThrowExceptionService s2 = new ThrowExceptionService(new ConfiguredException("failure"));
try {
start(s1, s2);
RetryFromJetty.executeQuietly(s1, msg);
RetryFromJetty.executeQuietly(s2, msg);
} finally {
stop(s1, s2);
}
}
use of com.adaptris.core.services.exception.ThrowExceptionService in project interlok by adaptris.
the class ActiveMqJmsTransactedWorkflowTest method testServiceExceptionNonStrictWithErrorHandler.
// In Non-Strict Mode, if you have configured an error handler, then
// the transaction is successful.
@Test
public void testServiceExceptionNonStrictWithErrorHandler() throws Exception {
int msgCount = 10;
String destination = createSafeUniqueId(new Object());
MockMessageProducer meh = new MockMessageProducer();
Channel channel = createStartableChannel(activeMqBroker, true, "testServiceExceptionNonStrictWithErrorHandler", destination);
JmsTransactedWorkflow workflow = (JmsTransactedWorkflow) channel.getWorkflowList().get(0);
workflow.setStrict(Boolean.FALSE);
workflow.getServiceCollection().addService(new ThrowExceptionService(new ConfiguredException("Fail")));
channel.setMessageErrorHandler(new StandardProcessingExceptionHandler(new ServiceList(new ArrayList<Service>(Arrays.asList(new Service[] { new StandaloneProducer(meh) })))));
channel.prepare();
try {
channel.requestStart();
StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new PtpProducer().withQueue((destination)));
send(sender, msgCount);
waitForMessages(meh, msgCount);
assertEquals(0, ((MockMessageProducer) workflow.getProducer()).getMessages().size());
} finally {
channel.requestClose();
}
assertEquals(0, activeMqBroker.messagesOnQueue(destination));
}
use of com.adaptris.core.services.exception.ThrowExceptionService in project interlok by adaptris.
the class ActiveMqJmsTransactedWorkflowTest method testMessagesRolledBackUsingTopic.
@Test
public void testMessagesRolledBackUsingTopic() throws Exception {
int msgCount = 10;
String destination = createSafeUniqueId(new Object());
Channel channel = createStartableChannel(activeMqBroker, false, "testMessagesRolledBackUsingTopic", destination);
JmsTransactedWorkflow workflow = (JmsTransactedWorkflow) channel.getWorkflowList().get(0);
workflow.getServiceCollection().addService(new ThrowExceptionService(new ConfiguredException("Fail")));
try {
channel.requestStart();
StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new PasProducer().withTopic(destination));
send(sender, msgCount);
assertEquals(0, ((MockMessageProducer) workflow.getProducer()).getMessages().size());
} finally {
channel.requestClose();
}
// can't actually check the count of messsages on a topic, that's a trifle
// silly; you might check per-subscription...
// assertEquals(msgCount, activeMqBroker.messageCount(get(TOPIC)));
}
use of com.adaptris.core.services.exception.ThrowExceptionService in project interlok by adaptris.
the class ActiveMqJmsTransactedWorkflowTest method testMessagesRolledBackUsingQueue.
@Test
public void testMessagesRolledBackUsingQueue() throws Exception {
int msgCount = 10;
String destination = createSafeUniqueId(new Object());
Channel channel = createStartableChannel(activeMqBroker, true, "testMessagesRolledBackUsingQueue", destination);
JmsTransactedWorkflow workflow = (JmsTransactedWorkflow) channel.getWorkflowList().get(0);
workflow.getServiceCollection().addService(new ThrowExceptionService(new ConfiguredException("Fail")));
try {
channel.requestStart();
StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new PtpProducer().withQueue((destination)));
send(sender, msgCount);
} finally {
channel.requestClose();
}
assertEquals(msgCount, activeMqBroker.messagesOnQueue(destination));
}
use of com.adaptris.core.services.exception.ThrowExceptionService in project interlok by adaptris.
the class ActiveMqJmsTransactedWorkflowTest method testServiceException.
@Test
public void testServiceException() throws Exception {
int msgCount = 10;
String destination = createSafeUniqueId(new Object());
Channel channel = createStartableChannel(activeMqBroker, true, "testServiceException", destination);
JmsTransactedWorkflow workflow = (JmsTransactedWorkflow) channel.getWorkflowList().get(0);
workflow.getServiceCollection().addService(new ThrowExceptionService(new ConfiguredException("Fail")));
try {
channel.requestStart();
StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new PtpProducer().withQueue((destination)));
send(sender, msgCount);
} finally {
channel.requestClose();
}
assertEquals(msgCount, activeMqBroker.messagesOnQueue(destination));
}
Aggregations