Search in sources :

Example 1 with NullMessageConsumer

use of com.adaptris.core.NullMessageConsumer 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 NullMessageConsumer

use of com.adaptris.core.NullMessageConsumer 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 NullMessageConsumer

use of com.adaptris.core.NullMessageConsumer 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 NullMessageConsumer

use of com.adaptris.core.NullMessageConsumer in project interlok by adaptris.

the class ExampleChannelCase method configureWorkflow.

protected Workflow configureWorkflow(WorkflowImp impl) throws CoreException {
    impl.setUniqueId(UUID.randomUUID().toString());
    AdaptrisMessageConsumer consumer = new NullMessageConsumer();
    impl.setConsumer(consumer);
    impl.setProducer(new NullMessageProducer());
    impl.setServiceCollection(createServiceCollection());
    return impl;
}
Also used : AdaptrisMessageConsumer(com.adaptris.core.AdaptrisMessageConsumer) NullMessageProducer(com.adaptris.core.NullMessageProducer) NullMessageConsumer(com.adaptris.core.NullMessageConsumer)

Example 5 with NullMessageConsumer

use of com.adaptris.core.NullMessageConsumer in project interlok by adaptris.

the class DeprecatedConfigurationCheckerTest method createAdapterConfig.

private Adapter createAdapterConfig(boolean validates, boolean channels) throws Exception {
    Adapter adapter = new Adapter();
    // have a unique-id
    adapter.setUniqueId("MyAdapter");
    AddTimestampMetadataService atms = new AddTimestampMetadataService();
    atms.setUniqueId("valid-add-timestamp-service");
    adapter.getSharedComponents().addService(atms);
    if (!validates) {
        // Add a deprecated service
        DeprecatedService ds = new DeprecatedService();
        adapter.getSharedComponents().addService(ds);
        // Add a service with deprecated member
        DeprecatedMemberService dms = new DeprecatedMemberService();
        dms.setDeprecated("value");
        adapter.getSharedComponents().addService(dms);
    }
    if (channels) {
        Channel c = new Channel();
        StandardWorkflow w = new StandardWorkflow();
        if (!validates) {
            NullMessageConsumer consumer = new NullMessageConsumer();
            w.setConsumer(consumer);
            w.getServiceCollection().add(new DeprecatedService());
        }
        c.getWorkflowList().add(w);
        adapter.getChannelList().add(c);
    }
    return adapter;
}
Also used : StandardWorkflow(com.adaptris.core.StandardWorkflow) AddTimestampMetadataService(com.adaptris.core.services.metadata.AddTimestampMetadataService) Channel(com.adaptris.core.Channel) Adapter(com.adaptris.core.Adapter) NullMessageConsumer(com.adaptris.core.NullMessageConsumer)

Aggregations

NullMessageConsumer (com.adaptris.core.NullMessageConsumer)9 Test (org.junit.Test)6 NullMessageProducer (com.adaptris.core.NullMessageProducer)5 JMSException (javax.jms.JMSException)3 AdaptrisMessageConsumer (com.adaptris.core.AdaptrisMessageConsumer)2 Adapter (com.adaptris.core.Adapter)1 Channel (com.adaptris.core.Channel)1 CoreException (com.adaptris.core.CoreException)1 NullProduceExceptionHandler (com.adaptris.core.NullProduceExceptionHandler)1 ProduceException (com.adaptris.core.ProduceException)1 ProduceExceptionHandler (com.adaptris.core.ProduceExceptionHandler)1 StandardWorkflow (com.adaptris.core.StandardWorkflow)1 AddTimestampMetadataService (com.adaptris.core.services.metadata.AddTimestampMetadataService)1 MockProducer (com.adaptris.interlok.junit.scaffolding.jms.MockProducer)1