Search in sources :

Example 36 with StandaloneProducer

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

the class StoredProcedureProducerTest method testOneMetadataParamInButDoesntExist.

@Test
public void testOneMetadataParamInButDoesntExist() throws Exception {
    if (areTestsEnabled()) {
        JdbcStoredProcedureProducer spp = new JdbcStoredProcedureProducer();
        spp.setProcedureName(("one_in"));
        JdbcMetadataParameter inParameter = new JdbcMetadataParameter();
        inParameter.setMetadataKey("xType");
        inParameter.setName("xType");
        inParameter.setType(ParameterValueType.VARCHAR);
        InParameters inParameters = new InParameters();
        inParameters.add(inParameter);
        spp.setInParameters(inParameters);
        StandaloneProducer producer = configureForTests(spp, true);
        AdaptrisMessage message = createMessage();
        try {
            start(producer);
            producer.doService(message);
            fail("Should have thrown ProduceException, because the metadata does not exist in the message.");
        } catch (ServiceException ex) {
        // pass, expected
        } finally {
            stop(producer);
        }
    }
}
Also used : ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 37 with StandaloneProducer

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

the class StoredProcedureProducerTest method testOneResultSetFirstRowMetadataTranslator.

@Test
public void testOneResultSetFirstRowMetadataTranslator() throws Exception {
    if (areTestsEnabled()) {
        JdbcStoredProcedureProducer spp = new JdbcStoredProcedureProducer();
        spp.setProcedureName(("one_resultset"));
        spp.setResultSetTranslator(new FirstRowMetadataTranslator());
        AdaptrisMessage message = createMessage();
        assertEquals(0, message.getMetadata().size());
        StandaloneProducer producer = configureForTests(spp, true);
        try {
            start(producer);
            producer.doService(message);
            assertEquals(3, message.getMetadata().size());
        } 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 38 with StandaloneProducer

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

the class StoredProcedureProducerTest method testOneObjectMetadataParamInOut.

@Test
public void testOneObjectMetadataParamInOut() throws Exception {
    if (areTestsEnabled()) {
        JdbcStoredProcedureProducer spp = new JdbcStoredProcedureProducer();
        spp.setProcedureName(("one_inout"));
        JdbcObjectMetadataParameter inOutParameter = new JdbcObjectMetadataParameter();
        inOutParameter.setMetadataKey("xSomeAmount");
        inOutParameter.setName("xSomeAmount");
        inOutParameter.setType(ParameterValueType.INTEGER);
        AdaptrisMessage message = createMessage();
        message.addObjectHeader("xSomeAmount", 100);
        InOutParameters inOutParameters = new InOutParameters();
        inOutParameters.add(inOutParameter);
        spp.setInOutParameters(inOutParameters);
        Map<Object, Object> objectMetadata = message.getObjectHeaders();
        assertEquals(1, objectMetadata.size());
        assertTrue("100".equals(objectMetadata.get("xSomeAmount").toString()));
        StandaloneProducer producer = configureForTests(spp, true);
        try {
            start(producer);
            producer.doService(message);
            assertEquals(1, objectMetadata.size());
            assertTrue("105".equals(objectMetadata.get("xSomeAmount").toString()));
        } finally {
            stop(producer);
        }
    }
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 39 with StandaloneProducer

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

the class StoredProcedureProducerTest method testManyMetadataParametersOut.

@Test
public void testManyMetadataParametersOut() throws Exception {
    if (areTestsEnabled()) {
        JdbcStoredProcedureProducer spp = new JdbcStoredProcedureProducer();
        spp.setProcedureName(("many_out"));
        JdbcMetadataParameter outParameter1 = new JdbcMetadataParameter();
        outParameter1.setMetadataKey("numberSold");
        outParameter1.setName("numberSold");
        outParameter1.setType(ParameterValueType.INTEGER);
        JdbcMetadataParameter outParameter2 = new JdbcMetadataParameter();
        outParameter2.setMetadataKey("numberPurchased");
        outParameter2.setName("numberPurchased");
        outParameter2.setType(ParameterValueType.INTEGER);
        JdbcMetadataParameter outParameter3 = new JdbcMetadataParameter();
        outParameter3.setMetadataKey("totalTransfers");
        outParameter3.setName("totalTransfers");
        outParameter3.setType(ParameterValueType.INTEGER);
        OutParameters outParameters = new OutParameters();
        outParameters.add(outParameter1);
        outParameters.add(outParameter2);
        outParameters.add(outParameter3);
        spp.setOutParameters(outParameters);
        AdaptrisMessage message = createMessage();
        assertEquals(0, message.getMetadata().size());
        StandaloneProducer producer = configureForTests(spp, true);
        try {
            start(producer);
            producer.doService(message);
            assertEquals(3, message.getMetadata().size());
            assertEquals("15", message.getMetadataValue("numberSold"));
            assertEquals("15", message.getMetadataValue("numberPurchased"));
            assertEquals("31", message.getMetadataValue("totalTransfers"));
        } finally {
            stop(producer);
        }
    }
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 40 with StandaloneProducer

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

the class StoredProcedureProducerTest method testMultipleResultSetsFirstRowMetadataTranslator.

@Test
public void testMultipleResultSetsFirstRowMetadataTranslator() throws Exception {
    if (areTestsEnabled()) {
        JdbcStoredProcedureProducer spp = new JdbcStoredProcedureProducer();
        spp.setProcedureName(("many_resultsets"));
        spp.setResultSetTranslator(new FirstRowMetadataTranslator());
        AdaptrisMessage message = createMessage();
        assertEquals(0, message.getMetadata().size());
        StandaloneProducer producer = configureForTests(spp, true);
        try {
            start(producer);
            producer.doService(message);
            assertEquals(6, message.getMetadata().size());
        } 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)

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