use of com.adaptris.core.jms.PtpProducer in project interlok by adaptris.
the class BasicActiveMqProducerTest method testQueueProduceAndConsumeWithSecurity_EncryptedPassword.
@Test
public void testQueueProduceAndConsumeWithSecurity_EncryptedPassword() 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(Password.encode(RequiresCredentialsBroker.DEFAULT_PASSWORD, Password.PORTABLE_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.PtpProducer in project interlok by adaptris.
the class BasicActiveMqProducerTest method testQueueRequestReplyWithMessageWrongType.
@Test
public void testQueueRequestReplyWithMessageWrongType() throws Exception {
QueueLoopback echo = new QueueLoopback(activeMqBroker, getName(), false);
try {
echo.start();
PtpProducer producer = new PtpProducer().withQueue((getName()));
producer.setMessageTranslator(new BytesMessageTranslator());
StandaloneRequestor standaloneProducer = new StandaloneRequestor(activeMqBroker.getJmsConnection(createVendorImpl()), producer);
AdaptrisMessage msg = createMessage();
ExampleServiceCase.execute(standaloneProducer, msg);
echo.waitFor(DEFAULT_TIMEOUT);
assertNotNull(echo.getLastMessage());
assertNotNull(echo.getLastMessage().getJMSReplyTo());
assertEquals(DEFAULT_PAYLOAD.toUpperCase(), msg.getContent());
} finally {
echo.stop();
}
}
use of com.adaptris.core.jms.PtpProducer 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.PtpProducer in project interlok by adaptris.
the class DestinationCacheJndiPtpProducerTest method testProduceWithCacheExceeded.
@Test
public void testProduceWithCacheExceeded() throws Exception {
DestinationCachingJndiVendorImpl jv = new DestinationCachingJndiVendorImpl(2);
String queueName = testName.getMethodName() + "_queue";
String topicName = testName.getMethodName() + "_topic";
StandaloneProducer sp1 = new StandaloneProducer(activeMqBroker.getJndiPtpConnection(jv, false, queueName, topicName), new PtpProducer().withQueue("%message{testProduceWithCacheExceeded}"));
jv.setUseJndiForQueues(true);
jv.getJndiParams().addKeyValuePair(new KeyValuePair("queue.testProduceWithCacheExceeded1", "testProduceWithCacheExceeded1"));
jv.getJndiParams().addKeyValuePair(new KeyValuePair("queue.testProduceWithCacheExceeded2", "testProduceWithCacheExceeded2"));
try {
start(sp1);
AdaptrisMessage m1 = createMessage(null);
m1.addMetadata("testProduceWithCacheExceeded", queueName);
AdaptrisMessage m2 = createMessage(null);
m2.addMetadata("testProduceWithCacheExceeded", "testProduceWithCacheExceeded2");
AdaptrisMessage m3 = createMessage(null);
m3.addMetadata("testProduceWithCacheExceeded", "testProduceWithCacheExceeded1");
sp1.doService(m1);
sp1.doService(m2);
// This 2nd produce will expire get(QUEUE) on a LRU
sp1.doService(m2);
// basis.
sp1.doService(m3);
assertEquals(2, jv.queueCacheSize());
assertFalse(jv.queueCache().containsKey(queueName));
assertTrue(jv.queueCache().containsKey("testProduceWithCacheExceeded1"));
assertTrue(jv.queueCache().containsKey("testProduceWithCacheExceeded2"));
} finally {
stop(sp1);
}
}
use of com.adaptris.core.jms.PtpProducer 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);
}
Aggregations