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);
}
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);
}
}
Aggregations