use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.
the class StoredProcedureProducerTest method testOneMetadataParamInButDoesntExist.
@Test
public void testOneMetadataParamInButDoesntExist() throws Exception {
if (areTestsEnabled()) {
JdbcStoredProcedureProducer spp = new JdbcStoredProcedureProducer();
spp.setProcedureName(("one_in"));
JdbcMetadataParameter inParameter = new JdbcMetadataParameter();
inParameter.setMetadataKey("xType");
inParameter.setName("xType");
inParameter.setType(ParameterValueType.VARCHAR);
InParameters inParameters = new InParameters();
inParameters.add(inParameter);
spp.setInParameters(inParameters);
StandaloneProducer producer = configureForTests(spp, true);
AdaptrisMessage message = createMessage();
try {
start(producer);
producer.doService(message);
fail("Should have thrown ProduceException, because the metadata does not exist in the message.");
} catch (ServiceException ex) {
// pass, expected
} finally {
stop(producer);
}
}
}
use of com.adaptris.core.StandaloneProducer 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);
}
}
}
use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.
the class StoredProcedureProducerTest method testOneObjectMetadataParamInOut.
@Test
public void testOneObjectMetadataParamInOut() throws Exception {
if (areTestsEnabled()) {
JdbcStoredProcedureProducer spp = new JdbcStoredProcedureProducer();
spp.setProcedureName(("one_inout"));
JdbcObjectMetadataParameter inOutParameter = new JdbcObjectMetadataParameter();
inOutParameter.setMetadataKey("xSomeAmount");
inOutParameter.setName("xSomeAmount");
inOutParameter.setType(ParameterValueType.INTEGER);
AdaptrisMessage message = createMessage();
message.addObjectHeader("xSomeAmount", 100);
InOutParameters inOutParameters = new InOutParameters();
inOutParameters.add(inOutParameter);
spp.setInOutParameters(inOutParameters);
Map<Object, Object> objectMetadata = message.getObjectHeaders();
assertEquals(1, objectMetadata.size());
assertTrue("100".equals(objectMetadata.get("xSomeAmount").toString()));
StandaloneProducer producer = configureForTests(spp, true);
try {
start(producer);
producer.doService(message);
assertEquals(1, objectMetadata.size());
assertTrue("105".equals(objectMetadata.get("xSomeAmount").toString()));
} finally {
stop(producer);
}
}
}
use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.
the class StoredProcedureProducerTest method testManyMetadataParametersOut.
@Test
public void testManyMetadataParametersOut() throws Exception {
if (areTestsEnabled()) {
JdbcStoredProcedureProducer spp = new JdbcStoredProcedureProducer();
spp.setProcedureName(("many_out"));
JdbcMetadataParameter outParameter1 = new JdbcMetadataParameter();
outParameter1.setMetadataKey("numberSold");
outParameter1.setName("numberSold");
outParameter1.setType(ParameterValueType.INTEGER);
JdbcMetadataParameter outParameter2 = new JdbcMetadataParameter();
outParameter2.setMetadataKey("numberPurchased");
outParameter2.setName("numberPurchased");
outParameter2.setType(ParameterValueType.INTEGER);
JdbcMetadataParameter outParameter3 = new JdbcMetadataParameter();
outParameter3.setMetadataKey("totalTransfers");
outParameter3.setName("totalTransfers");
outParameter3.setType(ParameterValueType.INTEGER);
OutParameters outParameters = new OutParameters();
outParameters.add(outParameter1);
outParameters.add(outParameter2);
outParameters.add(outParameter3);
spp.setOutParameters(outParameters);
AdaptrisMessage message = createMessage();
assertEquals(0, message.getMetadata().size());
StandaloneProducer producer = configureForTests(spp, true);
try {
start(producer);
producer.doService(message);
assertEquals(3, message.getMetadata().size());
assertEquals("15", message.getMetadataValue("numberSold"));
assertEquals("15", message.getMetadataValue("numberPurchased"));
assertEquals("31", message.getMetadataValue("totalTransfers"));
} finally {
stop(producer);
}
}
}
use of com.adaptris.core.StandaloneProducer 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);
}
}
}
Aggregations