Search in sources :

Example 1 with MockSkipProducerService

use of com.adaptris.core.stubs.MockSkipProducerService in project interlok by adaptris.

the class ActiveMqJmsTransactedWorkflowTest method testWorkflow_SkipProducer.

@Test
public void testWorkflow_SkipProducer() throws Exception {
    int msgCount = 10;
    String destination = createSafeUniqueId(new Object());
    Channel channel = createStartableChannel(activeMqBroker, true, "testWorkflow_SkipProducer", destination);
    JmsTransactedWorkflow workflow = (JmsTransactedWorkflow) channel.getWorkflowList().get(0);
    MockMessageProducer serviceProducer = new MockMessageProducer();
    workflow.getServiceCollection().addAll(Arrays.asList(new Service[] { new StandaloneProducer(serviceProducer), new MockSkipProducerService() }));
    MockMessageProducer workflowProducer = (MockMessageProducer) workflow.getProducer();
    try {
        channel.requestStart();
        StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new PtpProducer().withQueue((destination)));
        send(sender, msgCount);
        waitForMessages(serviceProducer, msgCount);
        assertEquals(msgCount, serviceProducer.messageCount());
        assertEquals(0, workflowProducer.messageCount());
    } finally {
        channel.requestClose();
    }
    assertEquals(0, activeMqBroker.messagesOnQueue(destination));
}
Also used : MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) MockSkipProducerService(com.adaptris.core.stubs.MockSkipProducerService) MockChannel(com.adaptris.core.stubs.MockChannel) Channel(com.adaptris.core.Channel) JmsTransactedWorkflow(com.adaptris.core.jms.JmsTransactedWorkflow) Service(com.adaptris.core.Service) MockSkipProducerService(com.adaptris.core.stubs.MockSkipProducerService) ThrowExceptionService(com.adaptris.core.services.exception.ThrowExceptionService) PtpProducer(com.adaptris.core.jms.PtpProducer) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 2 with MockSkipProducerService

use of com.adaptris.core.stubs.MockSkipProducerService in project interlok by adaptris.

the class MultiProducerWorkflowTest method testOnMessage_SkipProducer.

@Test
public void testOnMessage_SkipProducer() throws Exception {
    MockMessageProducer mock1 = new MockMessageProducer();
    MockMessageProducer mock2 = new MockMessageProducer();
    MockMessageProducer workflowProducer = new MockMessageProducer();
    MockMessageProducer serviceProducer = new MockMessageProducer();
    MockChannel channel = createChannel(Arrays.asList(new AdaptrisMessageProducer[] { mock1, mock2 }), Arrays.asList(new Service[] { new StandaloneProducer(serviceProducer), new MockSkipProducerService() }));
    try {
        MultiProducerWorkflow workflow = (MultiProducerWorkflow) channel.getWorkflowList().get(0);
        workflow.setProducer(workflowProducer);
        workflow.setUseProcessedMessage(false);
        channel.prepare();
        channel.requestStart();
        AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(ORIGINAL_PAYLOAD);
        workflow.onAdaptrisMessage(msg);
        assertEquals(1, mock1.messageCount());
        assertEquals(1, mock2.messageCount());
        assertEquals(1, serviceProducer.messageCount());
        assertEquals(0, workflowProducer.messageCount());
    } finally {
        channel.requestClose();
    }
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) MockSkipProducerService(com.adaptris.core.stubs.MockSkipProducerService) PayloadFromTemplateService(com.adaptris.core.services.metadata.PayloadFromTemplateService) MockSkipProducerService(com.adaptris.core.stubs.MockSkipProducerService) ThrowExceptionService(com.adaptris.core.services.exception.ThrowExceptionService) Test(org.junit.Test)

Example 3 with MockSkipProducerService

use of com.adaptris.core.stubs.MockSkipProducerService in project interlok by adaptris.

the class PoolingWorkflowTest method testOnMessage_SkipProducer.

@Test
public void testOnMessage_SkipProducer() throws Exception {
    StaticMockMessageProducer serviceProducer = new StaticMockMessageProducer();
    serviceProducer.getMessages().clear();
    MockChannel channel = createAndPrepareChannel(Arrays.asList(new Service[] { createService(), new StandaloneProducer(serviceProducer), new MockSkipProducerService() }));
    try {
        PoolingWorkflow workflow = (PoolingWorkflow) channel.getWorkflowList().get(0);
        MockMessageProducer workflowProducer = (MockMessageProducer) workflow.getProducer();
        start(channel);
        submitMessages(workflow, 10);
        waitForMessages(serviceProducer, 10);
        // assertEquals(10, serviceProducer.messageCount());
        assertEquals(0, workflowProducer.messageCount());
    } finally {
        stop(channel);
    }
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) MockSkipProducerService(com.adaptris.core.stubs.MockSkipProducerService) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) StaticMockMessageProducer(com.adaptris.core.stubs.StaticMockMessageProducer) WaitService(com.adaptris.core.services.WaitService) XmlRoundTripService(com.adaptris.core.stubs.XmlRoundTripService) MockSkipProducerService(com.adaptris.core.stubs.MockSkipProducerService) ThrowExceptionService(com.adaptris.core.services.exception.ThrowExceptionService) StaticMockMessageProducer(com.adaptris.core.stubs.StaticMockMessageProducer) Test(org.junit.Test)

Example 4 with MockSkipProducerService

use of com.adaptris.core.stubs.MockSkipProducerService in project interlok by adaptris.

the class StandardWorkflowTest method testOnMessage_SkipProducer.

@Test
public void testOnMessage_SkipProducer() throws Exception {
    MockMessageProducer producer = new MockMessageProducer();
    MockMessageProducer serviceProducer = new MockMessageProducer();
    MockChannel channel = createChannel(producer, Arrays.asList(new Service[] { new StandaloneProducer(serviceProducer), new MockSkipProducerService() }));
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(PAYLOAD_1);
    StandardWorkflow workflow = (StandardWorkflow) channel.getWorkflowList().get(0);
    try {
        start(channel);
        workflow.onAdaptrisMessage(msg);
        assertEquals(1, serviceProducer.messageCount());
        assertEquals(0, producer.messageCount());
    } finally {
        stop(channel);
    }
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) FailFirstMockMessageProducer(com.adaptris.core.stubs.FailFirstMockMessageProducer) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) MockSkipProducerService(com.adaptris.core.stubs.MockSkipProducerService) PayloadFromTemplateService(com.adaptris.core.services.metadata.PayloadFromTemplateService) EventHandlerAwareService(com.adaptris.core.stubs.EventHandlerAwareService) MockSkipProducerService(com.adaptris.core.stubs.MockSkipProducerService) ThrowExceptionService(com.adaptris.core.services.exception.ThrowExceptionService) AddMetadataService(com.adaptris.core.services.metadata.AddMetadataService) Test(org.junit.Test)

Example 5 with MockSkipProducerService

use of com.adaptris.core.stubs.MockSkipProducerService in project interlok by adaptris.

the class ThreadContextWorkflowTest method testOnMessage_SkipProducer.

@Test
public void testOnMessage_SkipProducer() throws Exception {
    MockMessageProducer producer = new MockMessageProducer();
    StaticMockMessageProducer serviceProducer = new StaticMockMessageProducer();
    serviceProducer.getMessages().clear();
    MockChannel channel = createChannel(producer, Arrays.asList(new Service[] { new StandaloneProducer(serviceProducer), new MockSkipProducerService() }));
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(PAYLOAD_1);
    ThreadContextWorkflow workflow = (ThreadContextWorkflow) channel.getWorkflowList().get(0);
    try {
        start(channel);
        workflow.onAdaptrisMessage(msg);
        assertEquals(1, serviceProducer.messageCount());
        assertEquals(0, producer.messageCount());
    } finally {
        stop(channel);
    }
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) FailFirstMockMessageProducer(com.adaptris.core.stubs.FailFirstMockMessageProducer) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) StaticMockMessageProducer(com.adaptris.core.stubs.StaticMockMessageProducer) MockSkipProducerService(com.adaptris.core.stubs.MockSkipProducerService) PayloadFromTemplateService(com.adaptris.core.services.metadata.PayloadFromTemplateService) MockSkipProducerService(com.adaptris.core.stubs.MockSkipProducerService) ThrowExceptionService(com.adaptris.core.services.exception.ThrowExceptionService) AddMetadataService(com.adaptris.core.services.metadata.AddMetadataService) StaticMockMessageProducer(com.adaptris.core.stubs.StaticMockMessageProducer) Test(org.junit.Test)

Aggregations

MockChannel (com.adaptris.core.stubs.MockChannel)6 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)6 MockSkipProducerService (com.adaptris.core.stubs.MockSkipProducerService)6 Test (org.junit.Test)6 ThrowExceptionService (com.adaptris.core.services.exception.ThrowExceptionService)5 PayloadFromTemplateService (com.adaptris.core.services.metadata.PayloadFromTemplateService)3 AddMetadataService (com.adaptris.core.services.metadata.AddMetadataService)2 FailFirstMockMessageProducer (com.adaptris.core.stubs.FailFirstMockMessageProducer)2 StaticMockMessageProducer (com.adaptris.core.stubs.StaticMockMessageProducer)2 Channel (com.adaptris.core.Channel)1 Service (com.adaptris.core.Service)1 StandaloneProducer (com.adaptris.core.StandaloneProducer)1 JmsTransactedWorkflow (com.adaptris.core.jms.JmsTransactedWorkflow)1 PtpProducer (com.adaptris.core.jms.PtpProducer)1 WaitService (com.adaptris.core.services.WaitService)1 EventHandlerAwareService (com.adaptris.core.stubs.EventHandlerAwareService)1 MockRequestReplyProducer (com.adaptris.core.stubs.MockRequestReplyProducer)1 XmlRoundTripService (com.adaptris.core.stubs.XmlRoundTripService)1