use of com.adaptris.core.stubs.MockMessageListener in project interlok by adaptris.
the class JmsProducerTest method testProduceAndConsume_TimeToLive.
@Test
public void testProduceAndConsume_TimeToLive() throws Exception {
String rfc6167 = "jms:queue:" + getName() + "?timeToLive=60000";
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);
}
use of com.adaptris.core.stubs.MockMessageListener in project interlok by adaptris.
the class JmsProducerTest method testProduceAndConsume_ResolvedEndpoint.
@Test
public void testProduceAndConsume_ResolvedEndpoint() throws Exception {
Queue queue = activeMqBroker.createQueue(getName());
String endpoint = "%message{metadataEndpoint}";
String rfc6167 = "jms:queue:" + getName();
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.addMessageHeader("metadataEndpoint", rfc6167);
execute(standaloneConsumer, standaloneProducer, msg, jms);
assertMessages(jms, 1);
}
use of com.adaptris.core.stubs.MockMessageListener in project interlok by adaptris.
the class JmsProducerTest method testProduceAndConsume_Priority.
@Test
public void testProduceAndConsume_Priority() throws Exception {
String rfc6167 = "jms:queue:" + getName() + "?priority=5";
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);
}
use of com.adaptris.core.stubs.MockMessageListener in project interlok by adaptris.
the class JmsProducerTest method testDefaultSessionFactory.
@Test
public void testDefaultSessionFactory() 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);
producer.setSessionFactory(new DefaultProducerSessionFactory());
StandaloneProducer sp = new StandaloneProducer(activeMqBroker.getJmsConnection(), producer);
standaloneConsumer.registerAdaptrisMessageListener(jms);
try {
start(standaloneConsumer, sp);
sp.doService(createMessage());
sp.doService(createMessage());
waitForMessages(jms, 2);
assertMessages(jms, 2);
} finally {
stop(sp, standaloneConsumer);
}
}
use of com.adaptris.core.stubs.MockMessageListener in project interlok by adaptris.
the class JmsSyncConsumerTest method testDeferConsumerCreationToVendor.
@Test
public void testDeferConsumerCreationToVendor() throws Exception {
Assume.assumeTrue(JmsConfig.jmsTestsEnabled());
when(mockVendor.createConsumer(any(), any(), any(JmsActorConfig.class))).thenReturn(mockMessageConsumer);
when(mockVendor.getBrokerUrl()).thenReturn("vm://" + activeMqBroker.getName());
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://" + activeMqBroker.getName());
when(mockVendor.createConnectionFactory()).thenReturn(factory);
when(mockVendor.createConnection(any(), any())).thenReturn(factory.createConnection());
JmsConnection jmsConnection = activeMqBroker.getJmsConnection();
jmsConnection.setVendorImplementation(mockVendor);
StandaloneConsumer standaloneConsumer = createStandaloneConsumer(jmsConnection, false, true);
MockMessageListener jms = new MockMessageListener();
standaloneConsumer.registerAdaptrisMessageListener(jms);
LifecycleHelper.initAndStart(standaloneConsumer);
verify(mockVendor).createConsumer(any(), any(), any(JmsSyncConsumer.class));
LifecycleHelper.stopAndClose(standaloneConsumer);
}
Aggregations