use of com.adaptris.core.jms.PtpConsumer in project interlok by adaptris.
the class BasicActiveMqProducerTest method testQueueProduceAndConsumeWithSecurity.
@Test
public void testQueueProduceAndConsumeWithSecurity() throws Exception {
RequiresCredentialsBroker broker = new RequiresCredentialsBroker();
try {
broker.start();
PtpConsumer consumer = new PtpConsumer().withQueue(RequiresCredentialsBroker.DEFAULT_PREFIX + "queue");
consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
JmsConnection conn = broker.getJmsConnection(createVendorImpl(), true);
conn.setUserName(RequiresCredentialsBroker.DEFAULT_USERNAME);
conn.setPassword(RequiresCredentialsBroker.DEFAULT_PASSWORD);
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(conn, consumer);
MockMessageListener jms = new MockMessageListener();
standaloneConsumer.registerAdaptrisMessageListener(jms);
conn = broker.getJmsConnection(createVendorImpl());
conn.setUserName(RequiresCredentialsBroker.DEFAULT_USERNAME);
conn.setPassword(RequiresCredentialsBroker.DEFAULT_PASSWORD);
StandaloneProducer standaloneProducer = new StandaloneProducer(conn, new PtpProducer().withQueue((RequiresCredentialsBroker.DEFAULT_PREFIX + "queue")));
execute(standaloneConsumer, standaloneProducer, createMessage(), jms);
assertMessages(jms, 1);
} finally {
broker.destroy();
}
}
use of com.adaptris.core.jms.PtpConsumer in project interlok by adaptris.
the class BasicActiveMqConsumerTest method testQueueProduceAndConsume.
@Test
public void testQueueProduceAndConsume() 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((getName())));
// INTERLOK-3329 For coverage so the prepare() warning is executed 2x
LifecycleHelper.prepare(standaloneConsumer);
LifecycleHelper.prepare(standaloneProducer);
execute(standaloneConsumer, standaloneProducer, createMessage(null), jms);
assertMessages(jms, 1);
}
use of com.adaptris.core.jms.PtpConsumer in project interlok by adaptris.
the class BasicActiveMqConsumerTest method testBlobProduceConsume.
@Test
public void testBlobProduceConsume() throws Exception {
if (!ExternalResourcesHelper.isExternalServerAvailable()) {
log.debug("Blob Server not available; skipping test");
return;
}
PtpConsumer consumer = new PtpConsumer().withQueue(getName());
consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
consumer.setMessageTranslator(new BlobMessageTranslator());
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(createVendorImpl()), consumer);
MockMessageListener jms = new MockMessageListener();
standaloneConsumer.registerAdaptrisMessageListener(jms);
PtpProducer producer = new PtpProducer().withQueue((getName()));
producer.setMessageTranslator(new BlobMessageTranslator("blobUrl"));
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), producer);
execute(standaloneConsumer, standaloneProducer, addBlobUrlRef(createMessage(null), "blobUrl"), jms);
assertMessages(jms, 1, false);
}
use of com.adaptris.core.jms.PtpConsumer in project interlok by adaptris.
the class BasicActiveMqConsumerTest method retrieveObjectForSampleConfig.
@Override
protected Object retrieveObjectForSampleConfig() {
JmsConnection connection = new JmsConnection();
PtpConsumer producer = new PtpConsumer();
producer.setQueue("destination");
UrlVendorImplementation vendorImpl = createImpl();
vendorImpl.setBrokerUrl(BasicActiveMqImplementationTest.PRIMARY);
connection.setUserName("BrokerUsername");
connection.setPassword("BrokerPassword");
connection.setVendorImplementation(vendorImpl);
StandaloneConsumer result = new StandaloneConsumer();
result.setConnection(connection);
result.setConsumer(producer);
return result;
}
use of com.adaptris.core.jms.PtpConsumer in project interlok by adaptris.
the class BasicActiveMqConsumerTest method testQueueProduceAndConsumeWithExplicitFallbackMessageTranslation.
@Test
public void testQueueProduceAndConsumeWithExplicitFallbackMessageTranslation() throws Exception {
PtpConsumer consumer = new PtpConsumer().withQueue(getName());
consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
consumer.setMessageTranslator(new AutoConvertMessageTranslator());
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(createVendorImpl()), consumer);
MockMessageListener jms = new MockMessageListener();
standaloneConsumer.registerAdaptrisMessageListener(jms);
DefinedJmsProducer producer = new PtpProducer().withQueue((getName()));
producer.setMessageTranslator(new BytesMessageTranslator());
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), producer);
execute(standaloneConsumer, standaloneProducer, createMessage(null), jms);
assertMessages(jms, 1);
}
Aggregations