Search in sources :

Example 46 with MockChannel

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

the class PoolingWorkflowTest method testMinIdle_Changes_MaxIdle.

@Test
public void testMinIdle_Changes_MaxIdle() throws Exception {
    MockChannel channel = createChannel();
    PoolingWorkflow wf = (PoolingWorkflow) channel.getWorkflowList().get(0);
    wf.setPoolSize(1000);
    wf.setMaxIdle(10);
    wf.setMinIdle(100);
    wf.setThreadKeepAlive(new TimeInterval(100L, TimeUnit.MILLISECONDS));
    LifecycleHelper.init(channel);
    assertEquals(100, wf.maxIdle());
    LifecycleHelper.close(channel);
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) TimeInterval(com.adaptris.util.TimeInterval) Test(org.junit.Test)

Example 47 with MockChannel

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

the class PoolingWorkflowTest method testFixedPoolsizeOnStart.

@Test
public void testFixedPoolsizeOnStart() throws Exception {
    MockChannel channel = createChannel();
    PoolingWorkflow wf = (PoolingWorkflow) channel.getWorkflowList().get(0);
    wf.setMaxIdle(DEFAULT_MAX_POOLSIZE);
    wf.setMinIdle(DEFAULT_MAX_POOLSIZE);
    wf.setThreadKeepAlive(new TimeInterval(100L, TimeUnit.MILLISECONDS));
    try {
        start(channel);
        Thread.sleep(200);
        assertTrue("ObjectPool >= 10", wf.currentObjectPoolCount() >= 1);
        assertTrue("ObjectPool idle >= 1", wf.currentlyIdleObjects() >= 1);
    } finally {
        stop(channel);
    }
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) TimeInterval(com.adaptris.util.TimeInterval) Test(org.junit.Test)

Example 48 with MockChannel

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

the class PoolingWorkflowTest method testRedmine1681.

@Test
public void testRedmine1681() throws Exception {
    MockChannel channel = createChannel();
    PoolingWorkflow wf = (PoolingWorkflow) channel.getWorkflowList().get(0);
    MockMessageProducer meh = new MockMessageProducer();
    MockMessageProducer prod = (MockMessageProducer) wf.getProducer();
    wf.getServiceCollection().add(new XmlRoundTripService());
    channel.setMessageErrorHandler(new StandardProcessingExceptionHandler(new ServiceList(new ArrayList<Service>(Arrays.asList(new Service[] { new StandaloneProducer(meh) })))));
    try {
        start(channel);
        submitMessages(wf, 1);
        waitForMessages(prod, 1);
        assertEquals(0, meh.messageCount());
        assertEquals(1, prod.messageCount());
    } finally {
        stop(channel);
    }
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) 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) XmlRoundTripService(com.adaptris.core.stubs.XmlRoundTripService) Test(org.junit.Test)

Example 49 with MockChannel

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

the class ProduceExceptionHandlerTest method testRestartProduceExceptionHandler.

@Test
public void testRestartProduceExceptionHandler() throws Exception {
    MockChannel channel = new MockChannel();
    MyStandardWorkflow wf = new MyStandardWorkflow();
    wf.setProducer(new FailingProducer());
    wf.setProduceExceptionHandler(new RestartProduceExceptionHandler());
    channel.getWorkflowList().add(wf);
    start(channel);
    wf.onAdaptrisMessage(AdaptrisMessageFactory.getDefaultInstance().newMessage());
    Thread.sleep(1000);
    assertEquals(1, channel.getStartCount());
    assertEquals(2, wf.getStartCount());
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) Test(org.junit.Test)

Example 50 with MockChannel

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

the class ProduceExceptionHandlerTest method testNullProduceExceptionHandler.

@Test
public void testNullProduceExceptionHandler() throws Exception {
    MockChannel channel = new MockChannel();
    MyStandardWorkflow wf = new MyStandardWorkflow();
    wf.setProducer(new FailingProducer());
    wf.setProduceExceptionHandler(new NullProduceExceptionHandler());
    channel.getWorkflowList().add(wf);
    start(channel);
    wf.onAdaptrisMessage(AdaptrisMessageFactory.getDefaultInstance().newMessage());
    Thread.sleep(1000);
    assertEquals(1, channel.getStartCount());
}
Also used : 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