Search in sources :

Example 1 with SqlServerStatementCreator

use of com.adaptris.jdbc.SqlServerStatementCreator in project interlok by adaptris.

the class StoredProcedureProducerTest method configureForTests.

private StandaloneProducer configureForTests(JdbcStoredProcedureProducer p, boolean addConnection) {
    if (PROPERTIES.getProperty(JDBC_VENDOR).equals("mysql"))
        p.setStatementCreator(new MysqlStatementCreator());
    else if (PROPERTIES.getProperty(JDBC_VENDOR).equals("sqlserver"))
        p.setStatementCreator(new SqlServerStatementCreator());
    else
        fail("Vendor for JDBC tests unknown: " + PROPERTIES.getProperty(JDBC_VENDOR));
    if (addConnection) {
        JdbcConnection jdbcConnection = new JdbcConnection(PROPERTIES.getProperty(JDBC_URL), PROPERTIES.getProperty(JDBC_DRIVER));
        jdbcConnection.setUsername(PROPERTIES.getProperty(JDBC_USER));
        jdbcConnection.setPassword(PROPERTIES.getProperty(JDBC_PASSWORD));
        return new StandaloneProducer(jdbcConnection, p);
    }
    return new StandaloneProducer(p);
}
Also used : MysqlStatementCreator(com.adaptris.jdbc.MysqlStatementCreator) SqlServerStatementCreator(com.adaptris.jdbc.SqlServerStatementCreator) StandaloneProducer(com.adaptris.core.StandaloneProducer)

Example 2 with SqlServerStatementCreator

use of com.adaptris.jdbc.SqlServerStatementCreator in project interlok by adaptris.

the class StoredProcedureProducerTest method testConnectionInObjectMetadata.

@Test
public void testConnectionInObjectMetadata() throws Exception {
    JdbcServiceList serviceList = new JdbcServiceList();
    try {
        if (areTestsEnabled()) {
            JdbcConnection jdbcConnection = new JdbcConnection(PROPERTIES.getProperty(JDBC_URL), PROPERTIES.getProperty(JDBC_DRIVER));
            jdbcConnection.setUsername(PROPERTIES.getProperty(JDBC_USER));
            jdbcConnection.setPassword(PROPERTIES.getProperty(JDBC_PASSWORD));
            serviceList.setConnection(jdbcConnection);
            JdbcStoredProcedureProducer myStoredProc = new JdbcStoredProcedureProducer();
            if (PROPERTIES.getProperty(JDBC_VENDOR).equals("mysql"))
                myStoredProc.setStatementCreator(new MysqlStatementCreator());
            else if (PROPERTIES.getProperty(JDBC_VENDOR).equals("sqlserver"))
                myStoredProc.setStatementCreator(new SqlServerStatementCreator());
            myStoredProc.setProcedureName(("one_in_one_out"));
            serviceList.add(new StandaloneProducer(myStoredProc));
            start(serviceList);
            AdaptrisMessage message = createMessage(XML_PAYLOAD);
            AdaptrisMessage message2 = createMessage(XML_PAYLOAD);
            JdbcXPathParameter inParameter = new JdbcXPathParameter();
            inParameter.setXpath("/head/body/element1");
            inParameter.setName("xType");
            inParameter.setType(ParameterValueType.VARCHAR);
            InParameters inParameters = new InParameters();
            inParameters.add(inParameter);
            JdbcMetadataParameter outParameter = new JdbcMetadataParameter();
            outParameter.setMetadataKey("result");
            outParameter.setName("transferCount");
            outParameter.setType(ParameterValueType.INTEGER);
            OutParameters outParameters = new OutParameters();
            outParameters.add(outParameter);
            myStoredProc.setInParameters(inParameters);
            myStoredProc.setOutParameters(outParameters);
            assertEquals(0, message.getMetadata().size());
            serviceList.doService(message);
            assertEquals("15", message.getMetadataValue("result"));
            assertEquals(0, message2.getMetadata().size());
            serviceList.doService(message2);
            assertEquals("15", message2.getMetadataValue("result"));
        }
    } finally {
        stop(serviceList);
    }
}
Also used : MysqlStatementCreator(com.adaptris.jdbc.MysqlStatementCreator) SqlServerStatementCreator(com.adaptris.jdbc.SqlServerStatementCreator) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) JdbcServiceList(com.adaptris.core.services.jdbc.JdbcServiceList) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Aggregations

StandaloneProducer (com.adaptris.core.StandaloneProducer)2 MysqlStatementCreator (com.adaptris.jdbc.MysqlStatementCreator)2 SqlServerStatementCreator (com.adaptris.jdbc.SqlServerStatementCreator)2 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)1 JdbcServiceList (com.adaptris.core.services.jdbc.JdbcServiceList)1 Test (org.junit.Test)1