Search in sources :

Example 6 with MockMessageListener

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

the class JmsConsumerTest method testQueueConsume.

@Test
public void testQueueConsume() throws Exception {
    Assume.assumeTrue(JmsConfig.jmsTestsEnabled());
    String rfc6167 = "jms:queue:" + getName();
    JmsConsumer consumer = new JmsConsumer().withEndpoint(rfc6167);
    consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(), consumer);
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    StandaloneProducer producer = new StandaloneProducer(activeMqBroker.getJmsConnection(), new JmsProducer().withEndpoint(rfc6167));
    // INTERLOK-3329 For coverage so the prepare() warning is executed 2x
    LifecycleHelper.prepare(standaloneConsumer);
    LifecycleHelper.prepare(producer);
    execute(standaloneConsumer, producer, createMessage(null), jms);
    assertMessages(jms, 1);
}
Also used : StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 7 with MockMessageListener

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

the class JmsConsumerTest method testTopicConsume.

@Test
public void testTopicConsume() throws Exception {
    Assume.assumeTrue(JmsConfig.jmsTestsEnabled());
    String rfc6167 = "jms:topic:" + getName();
    JmsConsumer consumer = new JmsConsumer().withEndpoint(rfc6167);
    ;
    consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(), consumer);
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(), new JmsProducer().withEndpoint(rfc6167));
    execute(standaloneConsumer, standaloneProducer, createMessage(null), jms);
    assertMessages(jms, 1);
}
Also used : StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 8 with MockMessageListener

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

the class JmsProducerTest method testTimedInactivitySession_SessionStillValid.

@Test
public void testTimedInactivitySession_SessionStillValid() throws Exception {
    String rfc6167 = "jms:queue:" + getName() + "";
    JmsConsumerImpl consumer = createConsumer(getName());
    consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(), consumer);
    MockMessageListener jms = new MockMessageListener();
    JmsProducer producer = createProducer(rfc6167);
    TimedInactivityProducerSessionFactory psf = new TimedInactivityProducerSessionFactory();
    producer.setSessionFactory(psf);
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(), producer);
    try {
        start(standaloneConsumer, standaloneProducer);
        standaloneProducer.doService(createMessage());
        Thread.sleep(200);
        assertFalse(psf.newSessionRequired());
        // Still should be a valid session; and could produce regardless.
        standaloneProducer.doService(createMessage());
        waitForMessages(jms, 2);
        assertMessages(jms, 2);
    } finally {
        stop(standaloneProducer, standaloneConsumer);
    }
}
Also used : StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 9 with MockMessageListener

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

the class JmsProducerTest method testProduceAndConsume_ObjectEndpoint.

@Test
public void testProduceAndConsume_ObjectEndpoint() throws Exception {
    Queue queue = activeMqBroker.createQueue(getName());
    String endpoint = "%messageObject{objectEndpoint}";
    JmsConsumerImpl consumer = createConsumer(getName());
    consumer.setAcknowledgeMode(String.valueOf(AcknowledgeMode.Mode.AUTO_ACKNOWLEDGE.acknowledgeMode()));
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(), consumer);
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    JmsProducer producer = createProducer(endpoint);
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(), producer);
    AdaptrisMessage msg = createMessage();
    msg.addObjectHeader("objectEndpoint", queue);
    execute(standaloneConsumer, standaloneProducer, msg, jms);
    assertMessages(jms, 1);
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Queue(javax.jms.Queue) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 10 with MockMessageListener

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

the class JmsProducerTest method testProduceAndConsume_DeliveryMode.

@Test
public void testProduceAndConsume_DeliveryMode() throws Exception {
    String rfc6167 = "jms:queue:" + getName() + "?deliveryMode=PERSISTENT";
    JmsConsumerImpl consumer = createConsumer(getName());
    consumer.setAcknowledgeMode(String.valueOf(AcknowledgeMode.Mode.AUTO_ACKNOWLEDGE.acknowledgeMode()));
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(), consumer);
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    JmsProducer producer = createProducer(rfc6167);
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(), producer);
    execute(standaloneConsumer, standaloneProducer, createMessage(), jms);
    assertMessages(jms, 1);
}
Also used : StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Aggregations

MockMessageListener (com.adaptris.core.stubs.MockMessageListener)173 Test (org.junit.Test)171 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)160 StandaloneProducer (com.adaptris.core.StandaloneProducer)91 TimeInterval (com.adaptris.util.TimeInterval)42 FakeFtpServer (org.mockftpserver.fake.FakeFtpServer)36 FixedIntervalPoller (com.adaptris.core.FixedIntervalPoller)32 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)28 File (java.io.File)28 GuidGenerator (com.adaptris.util.GuidGenerator)27 FilenameFilter (java.io.FilenameFilter)24 Perl5FilenameFilter (org.apache.oro.io.Perl5FilenameFilter)24 PtpProducer (com.adaptris.core.jms.PtpProducer)23 PtpConsumer (com.adaptris.core.jms.PtpConsumer)22 RandomAccessFile (java.io.RandomAccessFile)21 QuartzCronPoller (com.adaptris.core.QuartzCronPoller)16 FileSystem (org.mockftpserver.fake.filesystem.FileSystem)16 PasProducer (com.adaptris.core.jms.PasProducer)15 LargeFsConsumer (com.adaptris.core.lms.LargeFsConsumer)15 CoreException (com.adaptris.core.CoreException)14