Search in sources :

Example 1 with JdbcServiceList

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);
}
Also used : SharedConnection(com.adaptris.core.SharedConnection) ServiceList(com.adaptris.core.ServiceList) JdbcServiceList(com.adaptris.core.services.jdbc.JdbcServiceList) ArrayList(java.util.ArrayList) JdbcServiceList(com.adaptris.core.services.jdbc.JdbcServiceList) MetadataElement(com.adaptris.core.MetadataElement) AddMetadataService(com.adaptris.core.services.metadata.AddMetadataService) StandaloneProducer(com.adaptris.core.StandaloneProducer) NullMessageProducer(com.adaptris.core.NullMessageProducer) StatelessServiceWrapper(com.adaptris.core.services.StatelessServiceWrapper) MockAllowsRetriesConnection(com.adaptris.core.stubs.MockAllowsRetriesConnection)

Example 2 with JdbcServiceList

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));
}
Also used : ServiceList(com.adaptris.core.ServiceList) JdbcServiceList(com.adaptris.core.services.jdbc.JdbcServiceList) NullService(com.adaptris.core.NullService) JdbcServiceList(com.adaptris.core.services.jdbc.JdbcServiceList) StatelessServiceWrapper(com.adaptris.core.services.StatelessServiceWrapper) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 3 with JdbcServiceList

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);
}
Also used : ServiceList(com.adaptris.core.ServiceList) JdbcServiceList(com.adaptris.core.services.jdbc.JdbcServiceList) ArrayList(java.util.ArrayList) JdbcServiceList(com.adaptris.core.services.jdbc.JdbcServiceList) MetadataElement(com.adaptris.core.MetadataElement) AddMetadataService(com.adaptris.core.services.metadata.AddMetadataService) StandaloneProducer(com.adaptris.core.StandaloneProducer) NullMessageProducer(com.adaptris.core.NullMessageProducer) StatelessServiceWrapper(com.adaptris.core.services.StatelessServiceWrapper) MockAllowsRetriesConnection(com.adaptris.core.stubs.MockAllowsRetriesConnection)

Example 4 with JdbcServiceList

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);
    }
}
Also used : MysqlStatementCreator(com.adaptris.jdbc.MysqlStatementCreator) SqlServerStatementCreator(com.adaptris.jdbc.SqlServerStatementCreator) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) JdbcServiceList(com.adaptris.core.services.jdbc.JdbcServiceList) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Aggregations

StandaloneProducer (com.adaptris.core.StandaloneProducer)4 JdbcServiceList (com.adaptris.core.services.jdbc.JdbcServiceList)4 ServiceList (com.adaptris.core.ServiceList)3 StatelessServiceWrapper (com.adaptris.core.services.StatelessServiceWrapper)3 MetadataElement (com.adaptris.core.MetadataElement)2 NullMessageProducer (com.adaptris.core.NullMessageProducer)2 AddMetadataService (com.adaptris.core.services.metadata.AddMetadataService)2 MockAllowsRetriesConnection (com.adaptris.core.stubs.MockAllowsRetriesConnection)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)1 NullService (com.adaptris.core.NullService)1 SharedConnection (com.adaptris.core.SharedConnection)1 MysqlStatementCreator (com.adaptris.jdbc.MysqlStatementCreator)1 SqlServerStatementCreator (com.adaptris.jdbc.SqlServerStatementCreator)1