use of com.adaptris.core.AdaptrisMessage 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.AdaptrisMessage in project interlok by adaptris.
the class StoredProcedureProducerTest method testOneConstantParamInOut.
@Test
public void testOneConstantParamInOut() throws Exception {
if (areTestsEnabled()) {
JdbcStoredProcedureProducer spp = new JdbcStoredProcedureProducer();
spp.setProcedureName(("one_inout"));
JdbcConstantParameter inParameter = new JdbcConstantParameter();
inParameter.setName("xSomeAmount");
inParameter.setType(ParameterValueType.VARCHAR);
inParameter.setConstant("100");
InOutParameters inOutParameters = new InOutParameters();
inOutParameters.add(inParameter);
spp.setInOutParameters(inOutParameters);
StandaloneProducer producer = configureForTests(spp, true);
AdaptrisMessage message = createMessage();
try {
start(producer);
producer.doService(message);
fail("Cannot use a constant for InOut parameters");
} catch (ServiceException ex) {
// pass, expected
} finally {
stop(producer);
}
}
}
use of com.adaptris.core.AdaptrisMessage in project interlok by adaptris.
the class StoredProcedureProducerTest method testOneObjectMetadataParamOut.
@Test
public void testOneObjectMetadataParamOut() throws Exception {
if (areTestsEnabled()) {
JdbcStoredProcedureProducer spp = new JdbcStoredProcedureProducer();
spp.setProcedureName(("one_out"));
JdbcObjectMetadataParameter outParameter = new JdbcObjectMetadataParameter();
outParameter.setMetadataKey("transferCount");
outParameter.setName("transferCount");
outParameter.setType(ParameterValueType.INTEGER);
OutParameters outParameters = new OutParameters();
outParameters.add(outParameter);
spp.setOutParameters(outParameters);
AdaptrisMessage message = createMessage();
Map<Object, Object> objectMetadata = message.getObjectHeaders();
assertEquals(0, objectMetadata.size());
StandaloneProducer producer = configureForTests(spp, true);
try {
start(producer);
producer.doService(message);
objectMetadata = message.getObjectHeaders();
assertEquals(1, objectMetadata.size());
assertTrue("31".equals(objectMetadata.get("transferCount").toString()));
} finally {
stop(producer);
}
}
}
use of com.adaptris.core.AdaptrisMessage in project interlok by adaptris.
the class StoredProcedureProducerTest method testOneMetadataParamInOut.
@Test
public void testOneMetadataParamInOut() throws Exception {
if (areTestsEnabled()) {
JdbcStoredProcedureProducer spp = new JdbcStoredProcedureProducer();
spp.setProcedureName(("one_inout"));
JdbcMetadataParameter inParameter = new JdbcMetadataParameter();
inParameter.setMetadataKey("xSomeAmount");
inParameter.setName("xSomeAmount");
inParameter.setType(ParameterValueType.INTEGER);
AdaptrisMessage message = createMessage();
message.addMetadata("xSomeAmount", "100");
InOutParameters inOutParameters = new InOutParameters();
inOutParameters.add(inParameter);
spp.setInOutParameters(inOutParameters);
assertEquals(1, message.getMetadata().size());
assertEquals("100", message.getMetadataValue("xSomeAmount"));
ExampleServiceCase.execute(configureForTests(spp, true), message);
assertEquals(1, message.getMetadata().size());
assertEquals("105", message.getMetadataValue("xSomeAmount"));
}
}
use of com.adaptris.core.AdaptrisMessage in project interlok by adaptris.
the class StoredProcedureProducerTest method testBytePayloadParamIn.
@Test
public void testBytePayloadParamIn() throws Exception {
if (areTestsEnabled()) {
JdbcStoredProcedureProducer spp = new JdbcStoredProcedureProducer();
spp.setProcedureName(("one_in"));
JdbcBytePayloadParameter inParameter = new JdbcBytePayloadParameter();
inParameter.setName("xType");
inParameter.setType(ParameterValueType.VARCHAR);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("Sold");
InParameters inParameters = new InParameters();
inParameters.add(inParameter);
spp.setInParameters(inParameters);
StandaloneProducer producer = configureForTests(spp, true);
try {
start(producer);
producer.doService(msg);
} finally {
stop(producer);
}
}
}
Aggregations