Search in sources :

Example 1 with FirstRowMetadataTranslator

use of com.adaptris.core.services.jdbc.FirstRowMetadataTranslator 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 2 with FirstRowMetadataTranslator

use of com.adaptris.core.services.jdbc.FirstRowMetadataTranslator 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)

Example 3 with FirstRowMetadataTranslator

use of com.adaptris.core.services.jdbc.FirstRowMetadataTranslator 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)

Aggregations

AdaptrisMessage (com.adaptris.core.AdaptrisMessage)3 StandaloneProducer (com.adaptris.core.StandaloneProducer)3 FirstRowMetadataTranslator (com.adaptris.core.services.jdbc.FirstRowMetadataTranslator)3 Test (org.junit.Test)3