use of com.adaptris.core.stubs.MockMessageListener in project interlok by adaptris.
the class ActiveMqJmsSyncConsumerTest 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);
}
}
use of com.adaptris.core.stubs.MockMessageListener in project interlok by adaptris.
the class ActiveMqJmsSyncConsumerTest method testTopic_NoSubscriptionId.
@Test
public void testTopic_NoSubscriptionId() throws Exception {
String rfc6167 = "jms:topic:" + testName.getMethodName();
final StandaloneConsumer consumer = createStandaloneConsumer(activeMqBroker, testName.getMethodName(), rfc6167);
try {
consumer.registerAdaptrisMessageListener(new MockMessageListener());
// This won't fail, but... there will be errors in the log file...
start(consumer);
} finally {
shutdownQuietly(null, consumer);
}
}
use of com.adaptris.core.stubs.MockMessageListener in project interlok by adaptris.
the class OnMessageHandlerTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.openMocks(this);
mockCorrelationSourceId = new MessageIdCorrelationIdSource();
mockListener = new MockMessageListener();
mockListener.setChannel(mockChannel);
mockTranslator = new TextMessageTranslator();
config = new MockConsumer();
config.setCurrentSession(mockSession);
messageProperties = Collections.emptyEnumeration();
when(jmsMessage.getPropertyNames()).thenReturn(messageProperties);
when(jmsMessage.getJMSMessageID()).thenReturn("id");
when(mockSession.getTransacted()).thenReturn(false);
when(mockChannel.isAvailable()).thenReturn(true);
when(mockChannel.getConsumeConnection()).thenReturn(mockConnection);
when(mockChannel.getProduceConnection()).thenReturn(mockConnection);
}
use of com.adaptris.core.stubs.MockMessageListener in project interlok by adaptris.
the class JndiPtpProducerCase method testProduceAndConsumeUsingJndiOnly.
@Test
public void testProduceAndConsumeUsingJndiOnly() throws Exception {
StandardJndiImplementation recvVendorImp = createVendorImplementation();
StandardJndiImplementation sendVendorImp = createVendorImplementation();
String queueName = testName.getMethodName() + "_queue";
String topicName = testName.getMethodName() + "_topic";
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJndiPtpConnection(recvVendorImp, true, queueName, topicName), new PtpConsumer().withQueue(queueName));
MockMessageListener jms = new MockMessageListener();
standaloneConsumer.registerAdaptrisMessageListener(jms);
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJndiPtpConnection(sendVendorImp, true, queueName, topicName), new PtpProducer().withQueue((queueName)));
execute(standaloneConsumer, standaloneProducer, createMessage(null), jms);
assertMessages(jms);
}
use of com.adaptris.core.stubs.MockMessageListener in project interlok by adaptris.
the class JndiPtpProducerCase method testProduceAndConsume_ExtraConfig.
@Test
public void testProduceAndConsume_ExtraConfig() throws Exception {
SimpleFactoryConfiguration sfc = new SimpleFactoryConfiguration();
KeyValuePairSet kvps = new KeyValuePairSet();
kvps.add(new KeyValuePair("ClientID", "testProduceAndConsume_ExtraConfig"));
kvps.add(new KeyValuePair("UseCompression", "true"));
sfc.setProperties(kvps);
String queueName = testName.getMethodName() + "_queue";
String topicName = testName.getMethodName() + "_topic";
StandardJndiImplementation recvVendorImp = createVendorImplementation();
StandardJndiImplementation sendVendorImp = createVendorImplementation();
sendVendorImp.setExtraFactoryConfiguration(sfc);
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJndiPtpConnection(recvVendorImp, false, queueName, topicName), new PtpConsumer().withQueue(queueName));
MockMessageListener jms = new MockMessageListener();
standaloneConsumer.registerAdaptrisMessageListener(jms);
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJndiPtpConnection(sendVendorImp, false, queueName, topicName), new PtpProducer().withQueue((queueName)));
execute(standaloneConsumer, standaloneProducer, createMessage(null), jms);
assertMessages(jms);
}
Aggregations