Search in sources :

Example 46 with ServiceList

use of com.adaptris.core.ServiceList 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 47 with ServiceList

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

the class BasicJmsProducerCase method testMultipleProducersWithSession.

@Test
public void testMultipleProducersWithSession() throws Exception {
    JmsConsumerImpl consumer = createConsumer(getName());
    consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(), consumer);
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    ServiceList serviceList = new ServiceList(new Service[] { new StandaloneProducer(activeMqBroker.getJmsConnection(), createProducer(getName())), new StandaloneProducer(activeMqBroker.getJmsConnection(), createProducer(getName())) });
    try {
        start(standaloneConsumer, serviceList);
        AdaptrisMessage msg1 = createMessage();
        AdaptrisMessage msg2 = createMessage();
        serviceList.doService(msg1);
        serviceList.doService(msg2);
        waitForMessages(jms, 4);
        assertMessages(jms, 4);
    } finally {
        stop(serviceList, standaloneConsumer);
    }
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ServiceList(com.adaptris.core.ServiceList) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 48 with ServiceList

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

the class JmsProducerTest method testMultipleProducersWithSession.

@Test
public void testMultipleProducersWithSession() throws Exception {
    String rfc6167 = "jms:queue:" + getName() + "";
    JmsConsumerImpl consumer = createConsumer(getName());
    consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(), consumer);
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    ServiceList serviceList = new ServiceList(new Service[] { new StandaloneProducer(activeMqBroker.getJmsConnection(), createProducer(rfc6167)), new StandaloneProducer(activeMqBroker.getJmsConnection(), createProducer(rfc6167)) });
    try {
        start(standaloneConsumer, serviceList);
        AdaptrisMessage msg1 = createMessage();
        AdaptrisMessage msg2 = createMessage();
        serviceList.doService(msg1);
        serviceList.doService(msg2);
        waitForMessages(jms, 4);
        assertMessages(jms, 4);
    } finally {
        stop(serviceList, standaloneConsumer);
    }
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ServiceList(com.adaptris.core.ServiceList) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 49 with ServiceList

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

the class ServiceUtilTest method createConnectedServices.

private String createConnectedServices() throws Exception {
    ServiceList nestedList = new ServiceList();
    nestedList.add(new StandaloneProducer(new MockAllowsRetriesConnection(6), new NullMessageProducer()));
    nestedList.add(new StatelessServiceWrapper(new StandaloneProducer()));
    nestedList.add(new AddMetadataService(new ArrayList(Arrays.asList(new MetadataElement[] { new MetadataElement("key", "value") }))));
    ServiceList list = new ServiceList();
    list.add(nestedList);
    list.add(new JdbcServiceList());
    return DefaultMarshaller.getDefaultMarshaller().marshal(list);
}
Also used : ServiceList(com.adaptris.core.ServiceList) JdbcServiceList(com.adaptris.core.services.jdbc.JdbcServiceList) ArrayList(java.util.ArrayList) JdbcServiceList(com.adaptris.core.services.jdbc.JdbcServiceList) MetadataElement(com.adaptris.core.MetadataElement) AddMetadataService(com.adaptris.core.services.metadata.AddMetadataService) StandaloneProducer(com.adaptris.core.StandaloneProducer) NullMessageProducer(com.adaptris.core.NullMessageProducer) StatelessServiceWrapper(com.adaptris.core.services.StatelessServiceWrapper) MockAllowsRetriesConnection(com.adaptris.core.stubs.MockAllowsRetriesConnection)

Example 50 with ServiceList

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

the class AddTimestampMetadataServiceTest method testBug1552.

@Test
public void testBug1552() throws Exception {
    AdaptrisMessage m = AdaptrisMessageFactory.getDefaultInstance().newMessage();
    ServiceList sl = new ServiceList();
    sl.addService(new AddTimestampMetadataService(DEFAULT_TS_FORMAT, KEY1, true));
    sl.addService(new AddTimestampMetadataService("yyyy-MM-dd HH:mm:ssZ", KEY2, true));
    execute(sl, m);
    assertTrue(m.headersContainsKey(KEY1));
    assertTrue(m.headersContainsKey(KEY2));
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ssZ");
    String key2 = m.getMetadataValue(KEY2);
    try {
        sdf.parse(key2);
    } catch (ParseException e) {
        fail("Failed to parse " + key2);
    }
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ServiceList(com.adaptris.core.ServiceList) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) Test(org.junit.Test)

Aggregations

ServiceList (com.adaptris.core.ServiceList)64 Test (org.junit.Test)52 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)43 StandaloneProducer (com.adaptris.core.StandaloneProducer)39 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)33 Channel (com.adaptris.core.Channel)31 JettyHelper.createChannel (com.adaptris.core.http.jetty.JettyHelper.createChannel)29 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)23 HttpConnection (com.adaptris.core.http.jetty.HttpConnection)20 JettyMessageConsumer (com.adaptris.core.http.jetty.JettyMessageConsumer)20 StandardResponseProducer (com.adaptris.core.http.jetty.StandardResponseProducer)20 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)18 HttpConsumerTest (com.adaptris.core.http.jetty.HttpConsumerTest)18 PayloadFromTemplateService (com.adaptris.core.services.metadata.PayloadFromTemplateService)17 Service (com.adaptris.core.Service)16 AddMetadataService (com.adaptris.core.services.metadata.AddMetadataService)16 MetadataElement (com.adaptris.core.MetadataElement)14 ConfiguredRequestMethodProvider (com.adaptris.core.http.client.ConfiguredRequestMethodProvider)11 LogMessageService (com.adaptris.core.services.LogMessageService)11 StandardWorkflow (com.adaptris.core.StandardWorkflow)10