Search in sources :

Example 1 with NullMessageProducer

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();
}
Also used : JMSException(javax.jms.JMSException) NullMessageProducer(com.adaptris.core.NullMessageProducer) NullMessageConsumer(com.adaptris.core.NullMessageConsumer) Test(org.junit.Test)

Example 2 with NullMessageProducer

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();
}
Also used : JMSException(javax.jms.JMSException) NullMessageProducer(com.adaptris.core.NullMessageProducer) NullMessageConsumer(com.adaptris.core.NullMessageConsumer) Test(org.junit.Test)

Example 3 with NullMessageProducer

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();
}
Also used : NullMessageProducer(com.adaptris.core.NullMessageProducer) NullMessageConsumer(com.adaptris.core.NullMessageConsumer) Test(org.junit.Test)

Example 4 with NullMessageProducer

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);
}
Also used : SharedConnection(com.adaptris.core.SharedConnection) ServiceList(com.adaptris.core.ServiceList) JdbcServiceList(com.adaptris.core.services.jdbc.JdbcServiceList) ArrayList(java.util.ArrayList) JdbcServiceList(com.adaptris.core.services.jdbc.JdbcServiceList) MetadataElement(com.adaptris.core.MetadataElement) AddMetadataService(com.adaptris.core.services.metadata.AddMetadataService) StandaloneProducer(com.adaptris.core.StandaloneProducer) NullMessageProducer(com.adaptris.core.NullMessageProducer) StatelessServiceWrapper(com.adaptris.core.services.StatelessServiceWrapper) MockAllowsRetriesConnection(com.adaptris.core.stubs.MockAllowsRetriesConnection)

Example 5 with NullMessageProducer

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());
}
Also used : NullConnection(com.adaptris.core.NullConnection) StandaloneProducer(com.adaptris.core.StandaloneProducer) NullMessageProducer(com.adaptris.core.NullMessageProducer) Test(org.junit.Test)

Aggregations

NullMessageProducer (com.adaptris.core.NullMessageProducer)12 Test (org.junit.Test)7 NullMessageConsumer (com.adaptris.core.NullMessageConsumer)5 StandaloneProducer (com.adaptris.core.StandaloneProducer)5 NullConnection (com.adaptris.core.NullConnection)3 MockAllowsRetriesConnection (com.adaptris.core.stubs.MockAllowsRetriesConnection)3 JMSException (javax.jms.JMSException)3 MetadataElement (com.adaptris.core.MetadataElement)2 ServiceList (com.adaptris.core.ServiceList)2 StatelessServiceWrapper (com.adaptris.core.services.StatelessServiceWrapper)2 JdbcServiceList (com.adaptris.core.services.jdbc.JdbcServiceList)2 AddMetadataService (com.adaptris.core.services.metadata.AddMetadataService)2 ArrayList (java.util.ArrayList)2 Adapter (com.adaptris.core.Adapter)1 AdaptrisMessageConsumer (com.adaptris.core.AdaptrisMessageConsumer)1 Channel (com.adaptris.core.Channel)1 CoreException (com.adaptris.core.CoreException)1 SharedConnection (com.adaptris.core.SharedConnection)1 StandardWorkflow (com.adaptris.core.StandardWorkflow)1