Search in sources :

Example 51 with MockChannel

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

the class RetryMessageErrorHandlerTest method testFilterStarted.

@Test
public void testFilterStarted() throws Exception {
    Map<String, Workflow> workflows = new HashMap<>();
    StandardWorkflow started = new StandardWorkflow();
    workflows.put("1", new StandardWorkflow());
    MockChannel mockChannel = LifecycleHelper.initAndStart(new MockChannel(started));
    workflows.put("2", started);
    Map<String, Workflow> filtered = RetryMessageErrorHandlerImp.filterStarted(workflows);
    assertEquals(1, filtered.size());
    for (Workflow w : workflows.values()) {
        LifecycleHelper.stopAndClose(w);
    }
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 52 with MockChannel

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

the class QuartzCronPollerTest method testGeneratedQuartzId_NoDestination.

@Test
public void testGeneratedQuartzId_NoDestination() throws Exception {
    QuartzCronPoller p1 = new QuartzCronPoller();
    p1.setCronExpression("*/5 * * * * ?");
    StandardWorkflow wf1 = createWorkflow(p1, new MockMessageProducer());
    Channel channel = new MockChannel();
    channel.getWorkflowList().add(wf1);
    channel.prepare();
    try {
        channel.requestInit();
        assertNotNull(p1.getName());
    } finally {
        channel.requestClose();
    }
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) MockChannel(com.adaptris.core.stubs.MockChannel) Test(org.junit.Test)

Example 53 with MockChannel

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

the class QuartzCronPollerTest method testWithMessages_StandardThreadPool.

@Test
public void testWithMessages_StandardThreadPool() throws Exception {
    MockMessageProducer mock1 = new MockMessageProducer();
    MockMessageProducer mock2 = new MockMessageProducer();
    StandardWorkflow wf1 = createWorkflow(new QuartzCronPoller("*/2 * * * * ?", false), mock1);
    StandardWorkflow wf2 = createWorkflow(new QuartzCronPoller("0 00 00 31 * ?", false), mock2);
    Channel channel = new MockChannel();
    channel.getWorkflowList().add(wf1);
    channel.getWorkflowList().add(wf2);
    channel.prepare();
    try {
        channel.requestStart();
        waitForMessages(mock1, 1);
    } finally {
        channel.requestClose();
    }
    assertTrue("No. Produced Messages >=1", mock1.getMessages().size() >= 1);
    for (Iterator i = mock1.getMessages().iterator(); i.hasNext(); ) {
        AdaptrisMessage msg = (AdaptrisMessage) i.next();
        assertEquals("Payloads", PAYLOAD, msg.getContent());
    }
    assertEquals("No. Produced messages = 0", 0, mock2.getMessages().size());
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) MockChannel(com.adaptris.core.stubs.MockChannel) Iterator(java.util.Iterator) Test(org.junit.Test)

Example 54 with MockChannel

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

the class QuartzCronPollerTest method testBug917.

@Test
public void testBug917() throws Exception {
    QuartzCronPoller p1 = new QuartzCronPoller();
    p1.setCronExpression("*/5 * * * * ?");
    StandardWorkflow wf1 = createWorkflow(p1, new MockMessageProducer());
    Channel channel = new MockChannel();
    channel.getWorkflowList().add(wf1);
    channel.prepare();
    try {
        channel.requestInit();
        assertNotNull(p1.getName());
    } finally {
        channel.requestClose();
    }
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) MockChannel(com.adaptris.core.stubs.MockChannel) Test(org.junit.Test)

Example 55 with MockChannel

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

the class QuartzCronPollerTest method testGeneratedQuartzId_hasQuartzId.

@Test
public void testGeneratedQuartzId_hasQuartzId() throws Exception {
    QuartzCronPoller p1 = new QuartzCronPoller();
    p1.setCronExpression("*/5 * * * * ?");
    p1.setQuartzId("quartzId");
    StandardWorkflow wf1 = createWorkflow(p1, new MockMessageProducer());
    Channel channel = new MockChannel();
    channel.getWorkflowList().add(wf1);
    channel.prepare();
    try {
        channel.requestInit();
        assertEquals("quartzId", p1.getName());
    } finally {
        channel.requestClose();
    }
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) MockChannel(com.adaptris.core.stubs.MockChannel) Test(org.junit.Test)

Aggregations

MockChannel (com.adaptris.core.stubs.MockChannel)145 Test (org.junit.Test)125 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)92 ThrowExceptionService (com.adaptris.core.services.exception.ThrowExceptionService)62 MockSkipProducerService (com.adaptris.core.stubs.MockSkipProducerService)59 PayloadFromTemplateService (com.adaptris.core.services.metadata.PayloadFromTemplateService)56 AddMetadataService (com.adaptris.core.services.metadata.AddMetadataService)44 FailFirstMockMessageProducer (com.adaptris.core.stubs.FailFirstMockMessageProducer)40 StaticMockMessageProducer (com.adaptris.core.stubs.StaticMockMessageProducer)32 TimeInterval (com.adaptris.util.TimeInterval)28 EventHandlerAwareService (com.adaptris.core.stubs.EventHandlerAwareService)22 Iterator (java.util.Iterator)17 StandardWorkflow (com.adaptris.core.StandardWorkflow)13 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)13 ConfiguredException (com.adaptris.core.services.exception.ConfiguredException)11 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)10 Channel (com.adaptris.core.Channel)10 JmsConnectionErrorHandler (com.adaptris.core.jms.JmsConnectionErrorHandler)9 MockMessageConsumer (com.adaptris.core.stubs.MockMessageConsumer)9 JmsConnection (com.adaptris.core.jms.JmsConnection)8