Search in sources :

Example 16 with PtpConsumer

use of com.adaptris.core.jms.PtpConsumer in project interlok by adaptris.

the class BasicActiveMqProducerTest method testQueueProduceAndConsume_CustomMessageFactory.

@Test
public void testQueueProduceAndConsume_CustomMessageFactory() throws Exception {
    PtpConsumer consumer = new PtpConsumer().withQueue(getName());
    consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
    consumer.setMessageFactory(new StubMessageFactory());
    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())));
    execute(standaloneConsumer, standaloneProducer, createMessage(), jms);
    assertMessages(jms, 1);
    assertEquals(AdaptrisMessageStub.class, jms.getMessages().get(0).getClass());
}
Also used : PtpConsumer(com.adaptris.core.jms.PtpConsumer) StubMessageFactory(com.adaptris.core.stubs.StubMessageFactory) PtpProducer(com.adaptris.core.jms.PtpProducer) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 17 with PtpConsumer

use of com.adaptris.core.jms.PtpConsumer in project interlok by adaptris.

the class BasicActiveMqProducerTest 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())));
    execute(standaloneConsumer, standaloneProducer, createMessage(), jms);
    assertMessages(jms, 1);
}
Also used : PtpConsumer(com.adaptris.core.jms.PtpConsumer) PtpProducer(com.adaptris.core.jms.PtpProducer) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 18 with PtpConsumer

use of com.adaptris.core.jms.PtpConsumer in project interlok by adaptris.

the class BasicActiveMqProducerTest method testBlobProduceAndConsumeWithFileMessageFactory.

@Test
public void testBlobProduceAndConsumeWithFileMessageFactory() 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(EmbeddedActiveMq.createMessage(new FileBackedMessageFactory()), "blobUrl"), jms);
    assertMessages(jms, 1, false);
}
Also used : PtpConsumer(com.adaptris.core.jms.PtpConsumer) FileBackedMessageFactory(com.adaptris.core.lms.FileBackedMessageFactory) PtpProducer(com.adaptris.core.jms.PtpProducer) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 19 with PtpConsumer

use of com.adaptris.core.jms.PtpConsumer in project interlok by adaptris.

the class BasicActiveMqProducerTest method testBlobConsumeWithNonBlob.

@Test
public void testBlobConsumeWithNonBlob() throws Exception {
    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 TextMessageTranslator());
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), producer);
    execute(standaloneConsumer, standaloneProducer, EmbeddedActiveMq.createMessage(null), jms);
    assertMessages(jms, 1, true);
}
Also used : PtpConsumer(com.adaptris.core.jms.PtpConsumer) TextMessageTranslator(com.adaptris.core.jms.TextMessageTranslator) PtpProducer(com.adaptris.core.jms.PtpProducer) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 20 with PtpConsumer

use of com.adaptris.core.jms.PtpConsumer 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();
    }
}
Also used : PtpConsumer(com.adaptris.core.jms.PtpConsumer) JmsConnection(com.adaptris.core.jms.JmsConnection) PtpProducer(com.adaptris.core.jms.PtpProducer) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Aggregations

PtpConsumer (com.adaptris.core.jms.PtpConsumer)27 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)24 PtpProducer (com.adaptris.core.jms.PtpProducer)24 StandaloneProducer (com.adaptris.core.StandaloneProducer)23 Test (org.junit.Test)23 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)22 JmsConnection (com.adaptris.core.jms.JmsConnection)5 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)3 BytesMessageTranslator (com.adaptris.core.jms.BytesMessageTranslator)3 StandardJndiImplementation (com.adaptris.core.jms.jndi.StandardJndiImplementation)3 DefinedJmsProducer (com.adaptris.core.jms.DefinedJmsProducer)2 TextMessageTranslator (com.adaptris.core.jms.TextMessageTranslator)2 UrlVendorImplementation (com.adaptris.core.jms.UrlVendorImplementation)2 FileBackedMessageFactory (com.adaptris.core.lms.FileBackedMessageFactory)2 MockChannel (com.adaptris.core.stubs.MockChannel)2 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)2 Channel (com.adaptris.core.Channel)1 MimeEncoder (com.adaptris.core.MimeEncoder)1 StandardWorkflow (com.adaptris.core.StandardWorkflow)1 AutoConvertMessageTranslator (com.adaptris.core.jms.AutoConvertMessageTranslator)1