Search in sources :

Example 41 with StandaloneProducer

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

the class StoredProcedureProducerTest method testStringPayloadParamIn.

@Test
public void testStringPayloadParamIn() throws Exception {
    if (areTestsEnabled()) {
        JdbcStoredProcedureProducer spp = new JdbcStoredProcedureProducer();
        spp.setProcedureName(("one_in"));
        JdbcStringPayloadParameter inParameter = new JdbcStringPayloadParameter();
        inParameter.setName("xType");
        inParameter.setType(ParameterValueType.VARCHAR);
        AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("Sold");
        InParameters inParameters = new InParameters();
        inParameters.add(inParameter);
        spp.setInParameters(inParameters);
        StandaloneProducer producer = configureForTests(spp, true);
        try {
            start(producer);
            producer.doService(msg);
        } finally {
            stop(producer);
        }
    }
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 42 with StandaloneProducer

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

the class StoredProcedureProducerTest method testOneMetadataParamOutAndOneResultSet.

@Test
public void testOneMetadataParamOutAndOneResultSet() throws Exception {
    if (areTestsEnabled()) {
        JdbcStoredProcedureProducer spp = new JdbcStoredProcedureProducer();
        spp.setProcedureName(("one_resultset_one_out"));
        spp.setResultSetTranslator(new FirstRowMetadataTranslator());
        JdbcMetadataParameter outParameter = new JdbcMetadataParameter();
        outParameter.setMetadataKey("completed");
        outParameter.setName("completed");
        outParameter.setType(ParameterValueType.INTEGER);
        OutParameters outParameters = new OutParameters();
        outParameters.add(outParameter);
        spp.setOutParameters(outParameters);
        AdaptrisMessage message = createMessage();
        assertEquals(0, message.getMetadata().size());
        StandaloneProducer producer = configureForTests(spp, true);
        try {
            start(producer);
            producer.doService(message);
            assertEquals(4, message.getMetadata().size());
            assertEquals("1", message.getMetadataValue("completed"));
        } finally {
            stop(producer);
        }
    }
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) FirstRowMetadataTranslator(com.adaptris.core.services.jdbc.FirstRowMetadataTranslator) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 43 with StandaloneProducer

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

the class JmsAsyncProducerTest method testEmbeddedSuccessHandler.

@Test
public void testEmbeddedSuccessHandler() throws Exception {
    JmsAsyncProducer producer = new JmsAsyncProducer();
    producer.setEndpoint("jms:topic:myTopicName?priority=4");
    AdaptrisMessage message = DefaultMessageFactory.getDefaultInstance().newMessage("Some message content");
    StandaloneProducer standaloneProducer = new StandaloneProducer();
    try {
        standaloneProducer.setConnection(activeMqBroker.getJmsConnection());
        standaloneProducer.setProducer(producer);
        LifecycleHelper.initAndStart(standaloneProducer);
        standaloneProducer.doService(message);
    } finally {
        LifecycleHelper.stopAndClose(standaloneProducer);
    }
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 44 with StandaloneProducer

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

the class JmsConsumerTest method testQueueConsume.

@Test
public void testQueueConsume() throws Exception {
    Assume.assumeTrue(JmsConfig.jmsTestsEnabled());
    String rfc6167 = "jms:queue:" + getName();
    JmsConsumer consumer = new JmsConsumer().withEndpoint(rfc6167);
    consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(), consumer);
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    StandaloneProducer producer = new StandaloneProducer(activeMqBroker.getJmsConnection(), new JmsProducer().withEndpoint(rfc6167));
    // INTERLOK-3329 For coverage so the prepare() warning is executed 2x
    LifecycleHelper.prepare(standaloneConsumer);
    LifecycleHelper.prepare(producer);
    execute(standaloneConsumer, producer, createMessage(null), jms);
    assertMessages(jms, 1);
}
Also used : StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 45 with StandaloneProducer

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

the class JmsConsumerTest method testTopicConsume.

@Test
public void testTopicConsume() throws Exception {
    Assume.assumeTrue(JmsConfig.jmsTestsEnabled());
    String rfc6167 = "jms:topic:" + getName();
    JmsConsumer consumer = new JmsConsumer().withEndpoint(rfc6167);
    ;
    consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(), consumer);
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(), new JmsProducer().withEndpoint(rfc6167));
    execute(standaloneConsumer, standaloneProducer, createMessage(null), jms);
    assertMessages(jms, 1);
}
Also used : StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Aggregations

StandaloneProducer (com.adaptris.core.StandaloneProducer)266 Test (org.junit.Test)238 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)125 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)91 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)91 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)68 Channel (com.adaptris.core.Channel)64 PtpProducer (com.adaptris.core.jms.PtpProducer)46 ServiceList (com.adaptris.core.ServiceList)39 PasProducer (com.adaptris.core.jms.PasProducer)34 JettyHelper.createChannel (com.adaptris.core.http.jetty.JettyHelper.createChannel)32 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)27 HttpConsumerTest (com.adaptris.core.http.jetty.HttpConsumerTest)23 PtpConsumer (com.adaptris.core.jms.PtpConsumer)23 TimeInterval (com.adaptris.util.TimeInterval)23 MockChannel (com.adaptris.core.stubs.MockChannel)22 ServiceException (com.adaptris.core.ServiceException)20 StandardWorkflow (com.adaptris.core.StandardWorkflow)20 HttpConnection (com.adaptris.core.http.jetty.HttpConnection)20 JettyMessageConsumer (com.adaptris.core.http.jetty.JettyMessageConsumer)20