Search in sources :

Example 26 with JdbcConnection

use of com.adaptris.core.jdbc.JdbcConnection in project interlok by adaptris.

the class JdbcMapInsertCase method configureForTests.

protected static <T extends JdbcMapInsert> T configureForTests(T t) {
    JdbcMapInsert service = t;
    JdbcConnection connection = new JdbcConnection();
    connection.setConnectUrl(JDBC_URL);
    connection.setDriverImp(JDBC_DRIVER);
    service.setConnection(connection);
    KeyValuePairSet mappings = new KeyValuePairSet();
    mappings.add(new KeyValuePair("dob", JdbcMapInsert.BasicType.Date.name()));
    service.withTable(TABLE_NAME).withMappings(mappings);
    return t;
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) JdbcConnection(com.adaptris.core.jdbc.JdbcConnection) KeyValuePairSet(com.adaptris.util.KeyValuePairSet)

Example 27 with JdbcConnection

use of com.adaptris.core.jdbc.JdbcConnection in project interlok by adaptris.

the class JdbcCaptureNullsTest method configure.

private JdbcDataCaptureServiceImpl configure(JdbcDataCaptureServiceImpl service) {
    JdbcConnection connection = new JdbcConnection();
    connection.setConnectUrl(JDBC_URL);
    connection.setDriverImp(JDBC_DRIVER);
    service.setConnection(connection);
    service.addStatementParameter(new StringStatementParameter("/root/PurchaseDate", QueryType.xpath, false, null));
    service.addStatementParameter(new StringStatementParameter(ANYTHING, QueryType.constant, false, null));
    service.setStatement("insert into jdbc_capture_null (string_value, another_string_value) values (?, ?)");
    return service;
}
Also used : JdbcConnection(com.adaptris.core.jdbc.JdbcConnection)

Example 28 with JdbcConnection

use of com.adaptris.core.jdbc.JdbcConnection in project interlok by adaptris.

the class JdbcUtilTest method testGetConnection.

@Test
public void testGetConnection() throws Exception {
    Connection metadata = mock(Connection.class);
    Connection closed = mock(Connection.class);
    Connection configured = mock(Connection.class);
    Mockito.when(configured.getAutoCommit()).thenReturn(true);
    Mockito.when(closed.isClosed()).thenReturn(true);
    JdbcConnection jdbcCon = new MyJdbcConnection(configured);
    try {
        LifecycleHelper.initAndStart(jdbcCon);
        AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
        msg.getObjectHeaders().put(JdbcConstants.OBJ_METADATA_DATABASE_CONNECTION_KEY, metadata);
        assertEquals(metadata, getConnection(msg, jdbcCon));
        msg.getObjectHeaders().put(JdbcConstants.OBJ_METADATA_DATABASE_CONNECTION_KEY, closed);
        assertEquals(configured, getConnection(msg, jdbcCon));
        msg.getObjectHeaders().clear();
        assertEquals(configured, getConnection(msg, jdbcCon));
    } finally {
        LifecycleHelper.stopAndClose(jdbcCon);
    }
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Connection(java.sql.Connection) JdbcConnection(com.adaptris.core.jdbc.JdbcConnection) JdbcConnection(com.adaptris.core.jdbc.JdbcConnection) Test(org.junit.Test)

Example 29 with JdbcConnection

use of com.adaptris.core.jdbc.JdbcConnection in project interlok by adaptris.

the class JdbcRawDataCaptureServiceTest method createResolveableStatement.

private JdbcRawDataCaptureService createResolveableStatement(boolean createConnection) {
    JdbcRawDataCaptureService service = new JdbcRawDataCaptureService();
    if (createConnection) {
        JdbcConnection connection = new JdbcConnection();
        connection.setConnectUrl(PROPERTIES.getProperty(JDBC_CAPTURE_SERVICE_URL));
        connection.setDriverImp(PROPERTIES.getProperty(JDBC_CAPTURE_SERVICE_DRIVER));
        service.setConnection(connection);
    }
    service.addStatementParameter(new DateStatementParameter("timestamp", StatementParameter.QueryType.metadata, new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")));
    service.addStatementParameter(new TimestampStatementParameter("timestamp", StatementParameter.QueryType.metadata, new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")));
    service.addStatementParameter(new TimeStatementParameter("timestamp", StatementParameter.QueryType.metadata, new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")));
    service.addStatementParameter(new StatementParameter(null, "java.lang.String", StatementParameter.QueryType.payload));
    service.addStatementParameter(new BytePayloadStatementParameter());
    service.addStatementParameter(new CharacterStreamStatementParameter());
    service.addStatementParameter(new BinaryStreamStatementParameter());
    service.addStatementParameter(new StatementParameter(null, "java.lang.String", StatementParameter.QueryType.id));
    service.addStatementParameter(new StatementParameter(CONSTANT_VALUE, "java.lang.String", StatementParameter.QueryType.constant));
    service.setStatement("insert into jdbc_raw_data_capture_basic " + "(string_value, date_value, timestamp_value, time_value, payload_clob, payload_blob, payload_clob2, payload_blob2, id_value, constant_value) " + "values ('%message{jdbcRawDataCaptureServiceTest}', ?, ?, ?, ?, ?, ?, ?, ?, ?)");
    return service;
}
Also used : BytePayloadStatementParameter(com.adaptris.core.services.jdbc.BytePayloadStatementParameter) CharacterStreamStatementParameter(com.adaptris.core.services.jdbc.CharacterStreamStatementParameter) DateStatementParameter(com.adaptris.core.services.jdbc.DateStatementParameter) BinaryStreamStatementParameter(com.adaptris.core.services.jdbc.BinaryStreamStatementParameter) TimeStatementParameter(com.adaptris.core.services.jdbc.TimeStatementParameter) TimestampStatementParameter(com.adaptris.core.services.jdbc.TimestampStatementParameter) BinaryStreamStatementParameter(com.adaptris.core.services.jdbc.BinaryStreamStatementParameter) TimestampStatementParameter(com.adaptris.core.services.jdbc.TimestampStatementParameter) DateStatementParameter(com.adaptris.core.services.jdbc.DateStatementParameter) BytePayloadStatementParameter(com.adaptris.core.services.jdbc.BytePayloadStatementParameter) TimeStatementParameter(com.adaptris.core.services.jdbc.TimeStatementParameter) StatementParameter(com.adaptris.core.services.jdbc.StatementParameter) CharacterStreamStatementParameter(com.adaptris.core.services.jdbc.CharacterStreamStatementParameter) JdbcConnection(com.adaptris.core.jdbc.JdbcConnection) SimpleDateFormat(java.text.SimpleDateFormat)

Example 30 with JdbcConnection

use of com.adaptris.core.jdbc.JdbcConnection in project interlok by adaptris.

the class JdbcRawDataCaptureServiceTest method createService.

private JdbcRawDataCaptureService createService(boolean createConnection) {
    JdbcRawDataCaptureService service = new JdbcRawDataCaptureService();
    if (createConnection) {
        JdbcConnection connection = new JdbcConnection();
        connection.setConnectUrl(PROPERTIES.getProperty(JDBC_CAPTURE_SERVICE_URL));
        connection.setDriverImp(PROPERTIES.getProperty(JDBC_CAPTURE_SERVICE_DRIVER));
        service.setConnection(connection);
    }
    service.addStatementParameter(new StatementParameter(METADATA_KEY, "java.lang.String", StatementParameter.QueryType.metadata));
    service.addStatementParameter(new DateStatementParameter("timestamp", StatementParameter.QueryType.metadata, new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")));
    service.addStatementParameter(new TimestampStatementParameter("timestamp", StatementParameter.QueryType.metadata, new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")));
    service.addStatementParameter(new TimeStatementParameter("timestamp", StatementParameter.QueryType.metadata, new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")));
    service.addStatementParameter(new StatementParameter(null, "java.lang.String", StatementParameter.QueryType.payload));
    service.addStatementParameter(new BytePayloadStatementParameter());
    service.addStatementParameter(new CharacterStreamStatementParameter());
    service.addStatementParameter(new BinaryStreamStatementParameter());
    service.addStatementParameter(new StatementParameter(null, "java.lang.String", StatementParameter.QueryType.id));
    service.addStatementParameter(new StatementParameter(CONSTANT_VALUE, "java.lang.String", StatementParameter.QueryType.constant));
    service.setStatement("insert into jdbc_raw_data_capture_basic " + "(string_value, date_value, timestamp_value, time_value, payload_clob, payload_blob, payload_clob2, payload_blob2, id_value, constant_value) " + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
    return service;
}
Also used : BytePayloadStatementParameter(com.adaptris.core.services.jdbc.BytePayloadStatementParameter) CharacterStreamStatementParameter(com.adaptris.core.services.jdbc.CharacterStreamStatementParameter) DateStatementParameter(com.adaptris.core.services.jdbc.DateStatementParameter) BinaryStreamStatementParameter(com.adaptris.core.services.jdbc.BinaryStreamStatementParameter) TimeStatementParameter(com.adaptris.core.services.jdbc.TimeStatementParameter) TimestampStatementParameter(com.adaptris.core.services.jdbc.TimestampStatementParameter) BinaryStreamStatementParameter(com.adaptris.core.services.jdbc.BinaryStreamStatementParameter) TimestampStatementParameter(com.adaptris.core.services.jdbc.TimestampStatementParameter) DateStatementParameter(com.adaptris.core.services.jdbc.DateStatementParameter) BytePayloadStatementParameter(com.adaptris.core.services.jdbc.BytePayloadStatementParameter) TimeStatementParameter(com.adaptris.core.services.jdbc.TimeStatementParameter) StatementParameter(com.adaptris.core.services.jdbc.StatementParameter) CharacterStreamStatementParameter(com.adaptris.core.services.jdbc.CharacterStreamStatementParameter) JdbcConnection(com.adaptris.core.jdbc.JdbcConnection) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

JdbcConnection (com.adaptris.core.jdbc.JdbcConnection)30 TimeInterval (com.adaptris.util.TimeInterval)6 Test (org.junit.Test)6 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)4 BinaryStreamStatementParameter (com.adaptris.core.services.jdbc.BinaryStreamStatementParameter)3 BytePayloadStatementParameter (com.adaptris.core.services.jdbc.BytePayloadStatementParameter)3 CharacterStreamStatementParameter (com.adaptris.core.services.jdbc.CharacterStreamStatementParameter)3 DateStatementParameter (com.adaptris.core.services.jdbc.DateStatementParameter)3 StatementParameter (com.adaptris.core.services.jdbc.StatementParameter)3 TimeStatementParameter (com.adaptris.core.services.jdbc.TimeStatementParameter)3 TimestampStatementParameter (com.adaptris.core.services.jdbc.TimestampStatementParameter)3 SimpleDateFormat (java.text.SimpleDateFormat)3 ServiceException (com.adaptris.core.ServiceException)2 JdbcService (com.adaptris.core.jdbc.JdbcService)2 KeyValuePair (com.adaptris.util.KeyValuePair)2 KeyValuePairSet (com.adaptris.util.KeyValuePairSet)2 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 CoreException (com.adaptris.core.CoreException)1 XStreamMarshaller (com.adaptris.core.XStreamMarshaller)1