use of com.adaptris.core.stubs.MockMessageListener in project interlok by adaptris.
the class BasicActiveMqProducerTest method testQueueProduceAndConsume_ObjectEndpoint.
@Test
public void testQueueProduceAndConsume_ObjectEndpoint() throws Exception {
Queue queue = activeMqBroker.createQueue(getName());
PtpConsumer consumer = new PtpConsumer().withQueue(getName());
consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(createVendorImpl()), consumer);
MockMessageListener jms = new MockMessageListener();
standaloneConsumer.registerAdaptrisMessageListener(jms);
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), new PtpProducer().withQueue("%messageObject{objectEndpoint}"));
AdaptrisMessage msg = createMessage();
msg.addObjectHeader("objectEndpoint", queue);
execute(standaloneConsumer, standaloneProducer, msg, jms);
assertMessages(jms, 1);
}
use of com.adaptris.core.stubs.MockMessageListener in project interlok by adaptris.
the class BasicActiveMqProducerTest method testTopicProduceAndConsume_DurableSubscriber.
@Test
public // INTERLOK-3537, if subscriptionId != "", then it should be durable.
void testTopicProduceAndConsume_DurableSubscriber() throws Exception {
String subscriptionId = GUID.safeUUID();
String clientId = GUID.safeUUID();
PasConsumer consumer = new PasConsumer().withTopic(getName());
consumer.setSubscriptionId(subscriptionId);
consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
JmsConnection conn = activeMqBroker.getJmsConnection(createVendorImpl(), true);
conn.setClientId(clientId);
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(conn, consumer);
MockMessageListener jms = new MockMessageListener();
standaloneConsumer.registerAdaptrisMessageListener(jms);
// Start it once to get some durable Action.
start(standaloneConsumer);
stop(standaloneConsumer);
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), new PasProducer().withTopic(getName()));
int count = 10;
for (int i = 0; i < count; i++) {
ExampleServiceCase.execute(standaloneProducer, createMessage());
}
start(standaloneConsumer);
waitForMessages(jms, count);
assertMessages(jms, 10);
}
use of com.adaptris.core.stubs.MockMessageListener in project interlok by adaptris.
the class BasicActiveMqProducerTest method testQueueProduceAndConsume_ResolveableEndpoint.
@Test
public void testQueueProduceAndConsume_ResolveableEndpoint() throws Exception {
PtpConsumer consumer = new PtpConsumer().withQueue(getName());
consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(createVendorImpl()), consumer);
MockMessageListener jms = new MockMessageListener();
standaloneConsumer.registerAdaptrisMessageListener(jms);
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), new PtpProducer().withQueue("%message{metadataEndpoint}"));
AdaptrisMessage msg = createMessage();
msg.addMessageHeader("metadataEndpoint", getName());
execute(standaloneConsumer, standaloneProducer, msg, jms);
assertMessages(jms, 1);
}
use of com.adaptris.core.stubs.MockMessageListener in project interlok by adaptris.
the class BasicActiveMqProducerTest method testQueueProduceAndConsume_WithEncoder.
@Test
public void testQueueProduceAndConsume_WithEncoder() throws Exception {
PtpConsumer consumer = new PtpConsumer().withQueue(getName());
consumer.setEncoder(new MimeEncoder());
consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(createVendorImpl()), consumer);
MockMessageListener jms = new MockMessageListener();
standaloneConsumer.registerAdaptrisMessageListener(jms);
PtpProducer producer = new PtpProducer().withQueue((getName()));
producer.setEncoder(new MimeEncoder());
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), producer);
execute(standaloneConsumer, standaloneProducer, createMessage(), jms);
assertMessages(jms, 1);
}
use of com.adaptris.core.stubs.MockMessageListener in project interlok by adaptris.
the class ActiveMqJmsPollingConsumerTest method testQueue_ProduceConsume.
@Test
public void testQueue_ProduceConsume() throws Exception {
int msgCount = 5;
String rfc6167 = "jms:queue:" + testName.getMethodName();
final StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new JmsProducer().withEndpoint(rfc6167));
final StandaloneConsumer receiver = createStandaloneConsumer(activeMqBroker, testName.getMethodName(), rfc6167);
try {
MockMessageListener jms = new MockMessageListener();
receiver.registerAdaptrisMessageListener(jms);
// INTERLOK-3329 For coverage so the prepare() warning is executed 2x
LifecycleHelper.prepare(sender);
LifecycleHelper.prepare(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);
}
}
Aggregations