Search in sources :

Example 11 with PtpProducer

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

the class BasicActiveMqImplementationTest method testRfc6167_Invalid.

@Test
public void testRfc6167_Invalid() throws Exception {
    StandaloneProducer producer = null;
    try {
        BasicActiveMqImplementation vendorImp = create();
        PtpProducer ptp = new PtpProducer().withQueue((testName.getMethodName()));
        producer = new StandaloneProducer(activeMqBroker.getJmsConnection(vendorImp), ptp);
        start(producer);
        // Send a message so that the session is correct.
        producer.doService(AdaptrisMessageFactory.getDefaultInstance().newMessage("abcde"));
        try {
            vendorImp.createDestination("hello:queue:myQueueName", ptp);
        } catch (JMSException e) {
            assertTrue(e.getMessage().startsWith("failed to parse"));
        }
        try {
            vendorImp.createDestination(null, ptp);
        } catch (JMSException e) {
            assertTrue(e.getMessage().startsWith("failed to parse"));
        }
    } finally {
        stop(producer);
    }
}
Also used : JMSException(javax.jms.JMSException) PtpProducer(com.adaptris.core.jms.PtpProducer) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 12 with PtpProducer

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

the class BasicActiveMqProducerTest method testQueueProduceAndConsumeWrongType.

@Test
public void testQueueProduceAndConsumeWrongType() throws Exception {
    PtpConsumer consumer = new PtpConsumer().withQueue(getName());
    consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
    consumer.setMessageTranslator(new BytesMessageTranslator());
    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) BytesMessageTranslator(com.adaptris.core.jms.BytesMessageTranslator) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 13 with PtpProducer

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

the class BasicActiveMqProducerTest method testQueueProduce_WithStaticReplyTo.

@Test
public void testQueueProduce_WithStaticReplyTo() throws Exception {
    QueueLoopback echo = new QueueLoopback(activeMqBroker, getName());
    try {
        echo.start();
        StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), new PtpProducer().withQueue(getName()));
        AdaptrisMessage msg = EmbeddedActiveMq.createMessage(null);
        msg.addMetadata(JmsConstants.JMS_ASYNC_STATIC_REPLY_TO, getName() + "_reply");
        ExampleServiceCase.execute(standaloneProducer, msg);
        echo.waitFor(DEFAULT_TIMEOUT);
        assertNotNull(echo.getLastMessage());
        assertNotNull(echo.getLastMessage().getJMSReplyTo());
        assertEquals("queue://" + getName() + "_reply", echo.getLastMessage().getJMSReplyTo().toString());
    } finally {
        echo.stop();
    }
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) PtpProducer(com.adaptris.core.jms.PtpProducer) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 14 with PtpProducer

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

the class BasicActiveMqProducerTest 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(EmbeddedActiveMq.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 15 with PtpProducer

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

the class BasicActiveMqProducerTest method retrieveObjectForSampleConfig.

@Override
protected Object retrieveObjectForSampleConfig() {
    JmsConnection connection = new JmsConnection();
    PtpProducer producer = new PtpProducer();
    producer.setQueue("queueName");
    UrlVendorImplementation vendorImpl = createImpl();
    vendorImpl.setBrokerUrl(BasicActiveMqImplementationTest.PRIMARY);
    connection.setUserName("BrokerUsername");
    connection.setPassword("BrokerPassword");
    connection.setVendorImplementation(vendorImpl);
    StandaloneProducer result = new StandaloneProducer();
    result.setConnection(connection);
    result.setProducer(producer);
    return result;
}
Also used : UrlVendorImplementation(com.adaptris.core.jms.UrlVendorImplementation) JmsConnection(com.adaptris.core.jms.JmsConnection) PtpProducer(com.adaptris.core.jms.PtpProducer) StandaloneProducer(com.adaptris.core.StandaloneProducer)

Aggregations

PtpProducer (com.adaptris.core.jms.PtpProducer)52 StandaloneProducer (com.adaptris.core.StandaloneProducer)46 Test (org.junit.Test)46 PtpConsumer (com.adaptris.core.jms.PtpConsumer)24 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)23 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)23 MockChannel (com.adaptris.core.stubs.MockChannel)14 Channel (com.adaptris.core.Channel)13 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)12 JmsTransactedWorkflow (com.adaptris.core.jms.JmsTransactedWorkflow)12 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)10 JmsConnection (com.adaptris.core.jms.JmsConnection)8 StandardJndiImplementation (com.adaptris.core.jms.jndi.StandardJndiImplementation)6 ThrowExceptionService (com.adaptris.core.services.exception.ThrowExceptionService)6 ConfiguredException (com.adaptris.core.services.exception.ConfiguredException)5 BytesMessageTranslator (com.adaptris.core.jms.BytesMessageTranslator)4 TimeInterval (com.adaptris.util.TimeInterval)4 ProduceException (com.adaptris.core.ProduceException)3 Service (com.adaptris.core.Service)3 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)3