Search in sources :

Example 1 with Sometime

use of com.adaptris.core.jms.activemq.ActiveMqPasPollingConsumerTest.Sometime in project interlok by adaptris.

the class ActiveMqJmsPollingConsumerTest method testTopic_ProduceConsume.

@Test
public void testTopic_ProduceConsume() throws Exception {
    int msgCount = 5;
    String rfc6167 = "jms:topic:" + testName.getMethodName() + "?subscriptionId=" + testName.getMethodName();
    final StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new JmsProducer().withEndpoint(rfc6167));
    Sometime poller = new Sometime();
    JmsPollingConsumer consumer = createConsumer(activeMqBroker, testName.getMethodName(), rfc6167, poller);
    final StandaloneConsumer receiver = new StandaloneConsumer(consumer);
    try {
        MockMessageListener jms = new MockMessageListener();
        receiver.registerAdaptrisMessageListener(jms);
        startAndStop(receiver);
        start(receiver);
        start(sender);
        for (int i = 0; i < msgCount; i++) {
            sender.doService(createMessage());
        }
        waitForMessages(jms, msgCount);
        assertMessages(jms, msgCount);
    } finally {
        shutdownQuietly(sender, receiver);
    }
}
Also used : JmsProducer(com.adaptris.core.jms.JmsProducer) JmsPollingConsumer(com.adaptris.core.jms.JmsPollingConsumer) Sometime(com.adaptris.core.jms.activemq.ActiveMqPasPollingConsumerTest.Sometime) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 2 with Sometime

use of com.adaptris.core.jms.activemq.ActiveMqPasPollingConsumerTest.Sometime in project interlok by adaptris.

the class ActiveMqJmsSyncConsumerTest method testTopic_ProduceConsume.

@Test
public void testTopic_ProduceConsume() throws Exception {
    int msgCount = 5;
    String rfc6167 = "jms:topic:" + testName.getMethodName() + "?subscriptionId=" + testName.getMethodName();
    final StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new JmsProducer().withEndpoint(rfc6167));
    Sometime poller = new Sometime();
    JmsSyncConsumer consumer = createConsumer(testName.getMethodName(), rfc6167, poller);
    final StandaloneConsumer receiver = new StandaloneConsumer(activeMqBroker.getJmsConnection(), consumer);
    try {
        MockMessageListener jms = new MockMessageListener();
        receiver.registerAdaptrisMessageListener(jms);
        startAndStop(receiver);
        start(receiver);
        start(sender);
        for (int i = 0; i < msgCount; i++) {
            sender.doService(createMessage());
        }
        waitForMessages(jms, msgCount);
        assertMessages(jms, msgCount);
    } finally {
        shutdownQuietly(sender, receiver);
    }
}
Also used : JmsSyncConsumer(com.adaptris.core.jms.JmsSyncConsumer) JmsProducer(com.adaptris.core.jms.JmsProducer) Sometime(com.adaptris.core.jms.activemq.ActiveMqPasPollingConsumerTest.Sometime) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Aggregations

StandaloneConsumer (com.adaptris.core.StandaloneConsumer)2 StandaloneProducer (com.adaptris.core.StandaloneProducer)2 JmsProducer (com.adaptris.core.jms.JmsProducer)2 Sometime (com.adaptris.core.jms.activemq.ActiveMqPasPollingConsumerTest.Sometime)2 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)2 Test (org.junit.Test)2 JmsPollingConsumer (com.adaptris.core.jms.JmsPollingConsumer)1 JmsSyncConsumer (com.adaptris.core.jms.JmsSyncConsumer)1