use of com.adaptris.core.NullMessageProducer in project interlok by adaptris.
the class OnMessageHandlerTest method testOnMessageHandlerTranslatorFailsRollback.
@Test
public void testOnMessageHandlerTranslatorFailsRollback() throws Exception {
when(mockSession.getTransacted()).thenReturn(true);
doThrow(new JMSException("Expected")).when(jmsMessage).getPropertyNames();
JmsTransactedWorkflow jmsTransactedWorkflow = new JmsTransactedWorkflow();
jmsTransactedWorkflow.setConsumer(new NullMessageConsumer());
jmsTransactedWorkflow.setProducer(new NullMessageProducer());
jmsTransactedWorkflow.registerChannel(mockChannel);
config.setCorrelationIdSource(mockCorrelationSourceId);
config.setMessageTranslator(mockTranslator);
config.registerAdaptrisMessageListener(jmsTransactedWorkflow);
handler = new OnMessageHandler(config);
handler.onMessage(jmsMessage);
verify(mockSession).rollback();
}
use of com.adaptris.core.NullMessageProducer in project interlok by adaptris.
the class OnMessageHandlerTest method testOnMessageHandlerCommitRollbackFailsCaughtExceptions.
@Test
public void testOnMessageHandlerCommitRollbackFailsCaughtExceptions() throws Exception {
when(mockSession.getTransacted()).thenReturn(true);
doThrow(new JMSException("Expected")).when(mockSession).commit();
doThrow(new JMSException("Expected")).when(mockSession).rollback();
JmsTransactedWorkflow jmsTransactedWorkflow = new JmsTransactedWorkflow();
jmsTransactedWorkflow.setConsumer(new NullMessageConsumer());
jmsTransactedWorkflow.setProducer(new NullMessageProducer());
jmsTransactedWorkflow.registerChannel(mockChannel);
config.setCorrelationIdSource(mockCorrelationSourceId);
config.setMessageTranslator(mockTranslator);
config.registerAdaptrisMessageListener(jmsTransactedWorkflow);
handler = new OnMessageHandler(config);
handler.onMessage(jmsMessage);
verify(mockSession).commit();
verify(mockSession).rollback();
}
use of com.adaptris.core.NullMessageProducer in project interlok by adaptris.
the class OnMessageHandlerTest method testOnMessageHandlerSuccessTransactedCommit.
@Test
public void testOnMessageHandlerSuccessTransactedCommit() throws Exception {
when(mockSession.getTransacted()).thenReturn(true);
JmsTransactedWorkflow jmsTransactedWorkflow = new JmsTransactedWorkflow();
jmsTransactedWorkflow.setConsumer(new NullMessageConsumer());
jmsTransactedWorkflow.setProducer(new NullMessageProducer());
jmsTransactedWorkflow.registerChannel(mockChannel);
config.setCorrelationIdSource(mockCorrelationSourceId);
config.setMessageTranslator(mockTranslator);
config.registerAdaptrisMessageListener(jmsTransactedWorkflow);
handler = new OnMessageHandler(config);
handler.onMessage(jmsMessage);
verify(mockSession).commit();
}
use of com.adaptris.core.NullMessageProducer in project interlok by adaptris.
the class AdapterComponentCheckerTest method createConnectedServices.
private String createConnectedServices(String sharedName) throws Exception {
ServiceList nestedList = new ServiceList();
nestedList.add(new StandaloneProducer(new MockAllowsRetriesConnection(6), new NullMessageProducer()));
if (!StringUtils.isEmpty(sharedName)) {
nestedList.add(new StatelessServiceWrapper(new StandaloneProducer(new SharedConnection(sharedName), new NullMessageProducer())));
} else {
nestedList.add(new StatelessServiceWrapper(new StandaloneProducer()));
}
nestedList.add(new AddMetadataService(new ArrayList(Arrays.asList(new MetadataElement[] { new MetadataElement("key", "value") }))));
ServiceList list = new ServiceList();
list.add(nestedList);
list.add(new JdbcServiceList());
return DefaultMarshaller.getDefaultMarshaller().marshal(list);
}
use of com.adaptris.core.NullMessageProducer in project interlok by adaptris.
the class ServiceUtilTest method testRewriteForTesting_Connection.
@Test
public void testRewriteForTesting_Connection() throws Exception {
NullConnection conn = new NullConnection();
StandaloneProducer service = new StandaloneProducer(conn, new NullMessageProducer());
StandaloneProducer rewritten = ((StandaloneProducer) rewriteConnectionsForTesting(service));
assertNotSame(conn, rewritten.getConnection());
}
Aggregations