use of com.adaptris.core.StandaloneProducer 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.StandaloneProducer 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);
}
}
}
use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.
the class StoredProcedureProducerTest method testMultipleResultSetsMetadataTranslator.
@Test
public void testMultipleResultSetsMetadataTranslator() throws Exception {
if (areTestsEnabled()) {
JdbcStoredProcedureProducer spp = new JdbcStoredProcedureProducer();
spp.setProcedureName(("many_resultsets"));
spp.setResultSetTranslator(new AllRowsMetadataTranslator());
AdaptrisMessage message = createMessage();
assertEquals(0, message.getMetadata().size());
StandaloneProducer producer = configureForTests(spp, true);
try {
start(producer);
producer.doService(message);
assertEquals(30, message.getMetadata().size());
} finally {
stop(producer);
}
}
}
use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.
the class StoredProcedureProducerTest method testOneConstantParamInOneMetadataOut.
@Test
public void testOneConstantParamInOneMetadataOut() throws Exception {
if (areTestsEnabled()) {
JdbcStoredProcedureProducer spp = new JdbcStoredProcedureProducer();
spp.setProcedureName(("one_in_one_out"));
JdbcConstantParameter inParameter = new JdbcConstantParameter();
inParameter.setConstant("Sold");
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);
spp.setInParameters(inParameters);
spp.setOutParameters(outParameters);
AdaptrisMessage message = createMessage();
assertEquals(0, message.getMetadata().size());
StandaloneProducer producer = configureForTests(spp, true);
try {
start(producer);
producer.doService(message);
assertEquals(1, message.getMetadata().size());
assertEquals("15", message.getMetadataValue("result"));
} finally {
stop(producer);
}
}
}
use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.
the class StoredProcedureProducerTest method testProduce_PooledConnection.
@Test
public void testProduce_PooledConnection() throws Exception {
int maxServices = 5;
final int iterations = 5;
int poolsize = maxServices - 1;
if (areTestsEnabled()) {
List<Service> serviceList = new ArrayList<Service>();
String name = Thread.currentThread().getName();
Thread.currentThread().setName(getName());
JdbcPooledConnection conn = PooledConnectionHelper.createPooledConnection(PROPERTIES.getProperty(JDBC_DRIVER), PROPERTIES.getProperty(JDBC_URL), poolsize);
conn.setUsername(PROPERTIES.getProperty(JDBC_USER));
conn.setPassword(PROPERTIES.getProperty(JDBC_PASSWORD));
try {
for (int i = 0; i < maxServices; i++) {
JdbcStoredProcedureProducer spp = new JdbcStoredProcedureProducer();
spp.setProcedureName(("one_in"));
JdbcStringPayloadParameter inParameter = new JdbcStringPayloadParameter();
inParameter.setName("xType");
inParameter.setType(ParameterValueType.VARCHAR);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("Sold");
InParameters inParameters = new InParameters();
inParameters.add(inParameter);
spp.setInParameters(inParameters);
StandaloneProducer service = configureForTests(spp, false);
service.setConnection(conn);
serviceList.add(service);
start(service);
}
PooledConnectionHelper.executeTest(serviceList, iterations, new PooledConnectionHelper.MessageCreator() {
@Override
public AdaptrisMessage createMsgForPooledConnectionTest() throws Exception {
return createMessage("Sold");
}
});
assertEquals(0, conn.currentBusyConnectionCount());
assertEquals(poolsize, conn.currentIdleConnectionCount());
assertEquals(poolsize, conn.currentConnectionCount());
} finally {
stop(serviceList.toArray(new ComponentLifecycle[0]));
Thread.currentThread().setName(name);
}
}
}
Aggregations