use of com.adaptris.core.services.jdbc.XmlPayloadTranslator in project interlok by adaptris.
the class StoredProcedureProducerTest method testMultiResultSetXmlTranslator.
@Test
public void testMultiResultSetXmlTranslator() throws Exception {
if (areTestsEnabled()) {
JdbcStoredProcedureProducer spp = new JdbcStoredProcedureProducer();
spp.setProcedureName(("many_resultsets"));
XmlPayloadTranslator xmlPayloadTranslator = new XmlPayloadTranslator();
xmlPayloadTranslator.setPreserveOriginalMessage(true);
spp.setResultSetTranslator(xmlPayloadTranslator);
AdaptrisMessage message = createMessage();
assertEquals(0, message.getMetadata().size());
StandaloneProducer producer = configureForTests(spp, true);
try {
start(producer);
producer.doService(message);
assertEquals("Robbie Fowler", resolveXPath(message, "/Results/Row[1]/player"));
assertEquals("Michael Owen", resolveXPath(message, "/Results/Row[2]/player"));
assertEquals("Stan Collymore", resolveXPath(message, "/Results/Row[3]/player"));
assertEquals("Emile Heskey", resolveXPath(message, "/Results/Row[5]/player"));
assertEquals("Djibril Cisse", resolveXPath(message, "/Results/Row[6]/player"));
assertEquals("Emile Heskey", resolveXPath(message, "/Results/Row[7]/player"));
assertEquals("Xabi Alonso", resolveXPath(message, "/Results/Row[8]/player"));
assertEquals("El-Hadji Diouf", resolveXPath(message, "/Results/Row[9]/player"));
assertEquals("Stan Collymore", resolveXPath(message, "/Results/Row[10]/player"));
assertNull(resolveXPath(message, "/Results/Row[11]/player"));
} finally {
stop(producer);
}
}
}
use of com.adaptris.core.services.jdbc.XmlPayloadTranslator in project interlok by adaptris.
the class StoredProcedureProducerTest method testOneResultSetXmlTranslator.
@Test
public void testOneResultSetXmlTranslator() throws Exception {
if (areTestsEnabled()) {
JdbcStoredProcedureProducer spp = new JdbcStoredProcedureProducer();
spp.setProcedureName(("one_resultset"));
XmlPayloadTranslator xmlPayloadTranslator = new XmlPayloadTranslator();
xmlPayloadTranslator.setPreserveOriginalMessage(true);
spp.setResultSetTranslator(xmlPayloadTranslator);
AdaptrisMessage message = createMessage();
assertEquals(0, message.getMetadata().size());
StandaloneProducer producer = configureForTests(spp, true);
try {
start(producer);
producer.doService(message);
assertEquals("Djibril Cisse", resolveXPath(message, "/Results/Row[1]/player"));
assertEquals("Robbie Fowler", resolveXPath(message, "/Results/Row[2]/player"));
assertEquals("Emile Heskey", resolveXPath(message, "/Results/Row[3]/player"));
assertEquals("Xabi Alonso", resolveXPath(message, "/Results/Row[4]/player"));
assertEquals("El-Hadji Diouf", resolveXPath(message, "/Results/Row[5]/player"));
assertNull(resolveXPath(message, "/Results/Row[6]/player"));
} finally {
stop(producer);
}
}
}
use of com.adaptris.core.services.jdbc.XmlPayloadTranslator in project interlok by adaptris.
the class StoredProcedureProducerTest method retrieveObjectForSampleConfig.
@Override
protected Object retrieveObjectForSampleConfig() {
JdbcStoredProcedureProducer exampleProducer = new JdbcStoredProcedureProducer();
exampleProducer.setStatementCreator(new MysqlStatementCreator());
exampleProducer.setStatementExecutor(new ExecuteQueryCallableStatementExecutor());
exampleProducer.setProcedureName("The Stored Procedure to call");
TimeInterval timeout = new TimeInterval(10L, TimeUnit.SECONDS);
exampleProducer.setTimeout(timeout);
JdbcConnection jdbcConnection = new JdbcConnection("jdbc:mysql://localhost:3306/mydatabase", "com.mysql.jdbc.Driver");
jdbcConnection.setUsername("optional_username");
jdbcConnection.setPassword("optional_password");
exampleProducer.setResultSetTranslator(new XmlPayloadTranslator());
JdbcMetadataParameter inMetaParameter = new JdbcMetadataParameter();
inMetaParameter.setMetadataKey("InParam1MetaKey");
inMetaParameter.setName("InParam1");
inMetaParameter.setType(ParameterValueType.VARCHAR);
inMetaParameter.setOrder(5);
JdbcObjectMetadataParameter inObjectParameter = new JdbcObjectMetadataParameter();
inObjectParameter.setMetadataKey("InParam2MetaKey");
inObjectParameter.setName("InParam2");
inObjectParameter.setType(ParameterValueType.INTEGER);
inObjectParameter.setOrder(6);
JdbcXPathParameter inXPathParameter = new JdbcXPathParameter();
inXPathParameter.setName("InParam3");
inXPathParameter.setType(ParameterValueType.VARCHAR);
inXPathParameter.setXpath("/some/xpath");
inXPathParameter.setOrder(7);
JdbcConstantParameter inConstantParameter = new JdbcConstantParameter();
inConstantParameter.setConstant("InParam4Value");
inConstantParameter.setName("InParam4");
inConstantParameter.setType(ParameterValueType.VARCHAR);
inConstantParameter.setOrder(8);
JdbcStringPayloadParameter inPayloadParameter = new JdbcStringPayloadParameter();
inPayloadParameter.setName("InParam4");
inPayloadParameter.setType(ParameterValueType.CLOB);
inPayloadParameter.setOrder(9);
JdbcBytePayloadParameter inBytePayloadParameter = new JdbcBytePayloadParameter();
inBytePayloadParameter.setName("InParam5");
inBytePayloadParameter.setType(ParameterValueType.BLOB);
inBytePayloadParameter.setOrder(10);
JdbcMetadataParameter outMetaParameter = new JdbcMetadataParameter();
outMetaParameter.setMetadataKey("OutParam1MetaKey");
outMetaParameter.setName("OutParam1");
outMetaParameter.setType(ParameterValueType.VARCHAR);
outMetaParameter.setOrder(1);
JdbcObjectMetadataParameter outObjectParameter = new JdbcObjectMetadataParameter();
outObjectParameter.setMetadataKey("OutParam2MetaKey");
outObjectParameter.setName("OutParam2");
outObjectParameter.setType(ParameterValueType.BLOB);
outObjectParameter.setOrder(2);
JdbcMetadataParameter inOutMetaParameter = new JdbcMetadataParameter();
inOutMetaParameter.setMetadataKey("InOutParam1MetaKey");
inOutMetaParameter.setName("InOutParam1");
inOutMetaParameter.setType(ParameterValueType.VARCHAR);
inOutMetaParameter.setOrder(3);
JdbcObjectMetadataParameter inOutObjectParameter = new JdbcObjectMetadataParameter();
inOutObjectParameter.setMetadataKey("InOutParam2MetaKey");
inOutObjectParameter.setName("InOutParam2");
inOutObjectParameter.setType(ParameterValueType.VARCHAR);
inOutObjectParameter.setOrder(4);
InParameters inParams = new InParameters();
inParams.add(inMetaParameter);
inParams.add(inObjectParameter);
inParams.add(inXPathParameter);
inParams.add(inConstantParameter);
inParams.add(inPayloadParameter);
inParams.add(inBytePayloadParameter);
OutParameters outParams = new OutParameters();
outParams.add(outMetaParameter);
outParams.add(outObjectParameter);
InOutParameters inOutParams = new InOutParameters();
inOutParams.add(inOutMetaParameter);
inOutParams.add(inOutObjectParameter);
exampleProducer.setInParameters(inParams);
exampleProducer.setOutParameters(outParams);
exampleProducer.setInOutParameters(inOutParams);
return new StandaloneProducer(jdbcConnection, exampleProducer);
}
Aggregations