use of com.adaptris.core.services.jdbc.JdbcServiceList in project interlok by adaptris.
the class AdapterComponentCheckerTest method createConnectedServices.
private String createConnectedServices(String sharedName) throws Exception {
ServiceList nestedList = new ServiceList();
nestedList.add(new StandaloneProducer(new MockAllowsRetriesConnection(6), new NullMessageProducer()));
if (!StringUtils.isEmpty(sharedName)) {
nestedList.add(new StatelessServiceWrapper(new StandaloneProducer(new SharedConnection(sharedName), new NullMessageProducer())));
} else {
nestedList.add(new StatelessServiceWrapper(new StandaloneProducer()));
}
nestedList.add(new AddMetadataService(new ArrayList(Arrays.asList(new MetadataElement[] { new MetadataElement("key", "value") }))));
ServiceList list = new ServiceList();
list.add(nestedList);
list.add(new JdbcServiceList());
return DefaultMarshaller.getDefaultMarshaller().marshal(list);
}
use of com.adaptris.core.services.jdbc.JdbcServiceList in project interlok by adaptris.
the class ServiceUtilTest method testRewriteForTesting_NoConnection.
@Test
public void testRewriteForTesting_NoConnection() throws Exception {
NullService nullService = new NullService();
JdbcServiceList jdbcService = new JdbcServiceList();
StatelessServiceWrapper stateless = new StatelessServiceWrapper(new StandaloneProducer());
assertTrue(nullService == rewriteConnectionsForTesting(nullService));
assertTrue(jdbcService == rewriteConnectionsForTesting(jdbcService));
assertTrue(stateless == rewriteConnectionsForTesting(stateless));
ServiceList nestedList = new ServiceList();
ServiceList list = new ServiceList();
list.add(nestedList);
assertTrue(list == rewriteConnectionsForTesting(list));
}
use of com.adaptris.core.services.jdbc.JdbcServiceList in project interlok by adaptris.
the class ServiceUtilTest method createConnectedServices.
private String createConnectedServices() throws Exception {
ServiceList nestedList = new ServiceList();
nestedList.add(new StandaloneProducer(new MockAllowsRetriesConnection(6), new NullMessageProducer()));
nestedList.add(new StatelessServiceWrapper(new StandaloneProducer()));
nestedList.add(new AddMetadataService(new ArrayList(Arrays.asList(new MetadataElement[] { new MetadataElement("key", "value") }))));
ServiceList list = new ServiceList();
list.add(nestedList);
list.add(new JdbcServiceList());
return DefaultMarshaller.getDefaultMarshaller().marshal(list);
}
use of com.adaptris.core.services.jdbc.JdbcServiceList 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