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;
}
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;
}
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);
}
}
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;
}
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;
}
Aggregations