Search in sources :

Example 26 with StandaloneRequestor

use of com.adaptris.core.StandaloneRequestor 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();
    }
}
Also used : StandaloneRequestor(com.adaptris.core.StandaloneRequestor) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) PtpProducer(com.adaptris.core.jms.PtpProducer) BytesMessageTranslator(com.adaptris.core.jms.BytesMessageTranslator) Test(org.junit.Test)

Example 27 with StandaloneRequestor

use of com.adaptris.core.StandaloneRequestor in project interlok by adaptris.

the class BasicJmsProducerCase method testMultipleRequestorWithSession.

@Test
public void testMultipleRequestorWithSession() throws Exception {
    ServiceList serviceList = new ServiceList(new Service[] { new StandaloneRequestor(activeMqBroker.getJmsConnection(), createProducer(getName()), new TimeInterval(1L, TimeUnit.SECONDS)), new StandaloneRequestor(activeMqBroker.getJmsConnection(), createProducer(getName()), new TimeInterval(1L, TimeUnit.SECONDS)) });
    Loopback echo = createLoopback(activeMqBroker, getName());
    try {
        echo.start();
        start(serviceList);
        AdaptrisMessage msg1 = createMessage();
        AdaptrisMessage msg2 = createMessage();
        serviceList.doService(msg1);
        serviceList.doService(msg2);
        assertEquals(DEFAULT_PAYLOAD.toUpperCase(), msg1.getContent());
        assertEquals(DEFAULT_PAYLOAD.toUpperCase(), msg2.getContent());
    } finally {
        stop(serviceList);
        echo.stop();
    }
}
Also used : StandaloneRequestor(com.adaptris.core.StandaloneRequestor) TimeInterval(com.adaptris.util.TimeInterval) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ServiceList(com.adaptris.core.ServiceList) Test(org.junit.Test)

Example 28 with StandaloneRequestor

use of com.adaptris.core.StandaloneRequestor in project interlok by adaptris.

the class JmsProducerTest method testRequest_AsyncReplyTo_Metadata.

@Test
public void testRequest_AsyncReplyTo_Metadata() throws Exception {
    String rfc6167 = "jms:queue:" + getName() + "";
    StandaloneRequestor serviceList = new StandaloneRequestor(activeMqBroker.getJmsConnection(), createProducer(rfc6167), new TimeInterval(1L, TimeUnit.SECONDS));
    Loopback echo = createLoopback(activeMqBroker, getName());
    try {
        echo.start();
        start(serviceList);
        AdaptrisMessage msg = createMessage();
        msg.addMetadata(JmsConstants.JMS_ASYNC_STATIC_REPLY_TO, getName() + "_reply");
        serviceList.doService(msg);
        assertEquals(DEFAULT_PAYLOAD.toUpperCase(), msg.getContent());
    } finally {
        stop(serviceList);
        echo.stop();
    }
}
Also used : StandaloneRequestor(com.adaptris.core.StandaloneRequestor) TimeInterval(com.adaptris.util.TimeInterval) Loopback(com.adaptris.core.jms.BasicJmsProducerCase.Loopback) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 29 with StandaloneRequestor

use of com.adaptris.core.StandaloneRequestor in project interlok by adaptris.

the class JmsProducerTest method testRequest_Timeout.

@Test(expected = ServiceException.class)
public void testRequest_Timeout() throws Exception {
    String rfc6167 = "jms:queue:" + getName() + "";
    JmsProducer producer = createProducer(rfc6167);
    producer.setPerMessageProperties(false);
    StandaloneRequestor serviceList = new StandaloneRequestor(activeMqBroker.getJmsConnection(), producer, new TimeInterval(1L, TimeUnit.SECONDS));
    try {
        start(serviceList);
        AdaptrisMessage msg1 = createMessage();
        serviceList.doService(msg1);
    } finally {
        stop(serviceList);
    }
}
Also used : StandaloneRequestor(com.adaptris.core.StandaloneRequestor) TimeInterval(com.adaptris.util.TimeInterval) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 30 with StandaloneRequestor

use of com.adaptris.core.StandaloneRequestor in project interlok by adaptris.

the class FtpProducerTest method testRequestReply_NoReplyDirectory.

@Test
public void testRequestReply_NoReplyDirectory() throws Exception {
    EmbeddedFtpServer helper = new EmbeddedFtpServer();
    FileSystem filesystem = helper.createFilesystem_DirsOnly();
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(PAYLOAD);
    filesystem.add(new FileEntry(DEFAULT_REPLY_DIR_CANONICAL + SLASH + msg.getUniqueId(), PAYLOAD_ALTERNATE));
    FakeFtpServer server = helper.createAndStart(filesystem);
    StandaloneRequestor requestor = null;
    try {
        FtpProducer ftpProducer = createForTests();
        FtpConnection produceConnection = create(server);
        requestor = new StandaloneRequestor(produceConnection, ftpProducer);
        requestor.setReplyTimeout(DEFAULT_TIMEOUT);
        start(requestor);
        requestor.doService(msg);
        fail();
    } catch (ServiceException expected) {
    } finally {
        stop(requestor);
        server.stop();
    }
}
Also used : StandaloneRequestor(com.adaptris.core.StandaloneRequestor) FakeFtpServer(org.mockftpserver.fake.FakeFtpServer) ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) FileSystem(org.mockftpserver.fake.filesystem.FileSystem) FileEntry(org.mockftpserver.fake.filesystem.FileEntry) Test(org.junit.Test)

Aggregations

StandaloneRequestor (com.adaptris.core.StandaloneRequestor)50 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)49 Test (org.junit.Test)49 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)33 Channel (com.adaptris.core.Channel)30 JettyHelper.createChannel (com.adaptris.core.http.jetty.JettyHelper.createChannel)30 ServiceList (com.adaptris.core.ServiceList)23 StandaloneProducer (com.adaptris.core.StandaloneProducer)19 ConfiguredRequestMethodProvider (com.adaptris.core.http.client.ConfiguredRequestMethodProvider)16 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)15 HttpConsumerTest (com.adaptris.core.http.jetty.HttpConsumerTest)15 StandardWorkflow (com.adaptris.core.StandardWorkflow)12 HttpConnection (com.adaptris.core.http.jetty.HttpConnection)12 JettyMessageConsumer (com.adaptris.core.http.jetty.JettyMessageConsumer)12 StandardResponseProducer (com.adaptris.core.http.jetty.StandardResponseProducer)12 StandardHttpProducer (com.adaptris.core.http.client.net.StandardHttpProducer)8 PayloadFromTemplateService (com.adaptris.core.services.metadata.PayloadFromTemplateService)8 TimeInterval (com.adaptris.util.TimeInterval)7 MetadataContentTypeProvider (com.adaptris.core.http.MetadataContentTypeProvider)6 ServiceException (com.adaptris.core.ServiceException)5