Search in sources :

Example 21 with PtpConsumer

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();
    }
}
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)

Example 22 with PtpConsumer

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);
}
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 23 with PtpConsumer

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);
}
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 24 with PtpConsumer

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;
}
Also used : PtpConsumer(com.adaptris.core.jms.PtpConsumer) UrlVendorImplementation(com.adaptris.core.jms.UrlVendorImplementation) JmsConnection(com.adaptris.core.jms.JmsConnection) StandaloneConsumer(com.adaptris.core.StandaloneConsumer)

Example 25 with PtpConsumer

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);
}
Also used : PtpConsumer(com.adaptris.core.jms.PtpConsumer) DefinedJmsProducer(com.adaptris.core.jms.DefinedJmsProducer) AutoConvertMessageTranslator(com.adaptris.core.jms.AutoConvertMessageTranslator) PtpProducer(com.adaptris.core.jms.PtpProducer) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) BytesMessageTranslator(com.adaptris.core.jms.BytesMessageTranslator) 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