use of org.talend.components.jdbc.runtime.JDBCRowSourceOrSink in project components by Talend.
the class JDBCRowTestIT method test_use_preparedstatement_no_connector.
@Test
public void test_use_preparedstatement_no_connector() throws Exception {
TJDBCRowDefinition definition = new TJDBCRowDefinition();
TJDBCRowProperties properties = DBTestUtils.createCommonJDBCRowProperties(allSetting, definition);
properties.tableSelection.tablename.setValue(tablename);
properties.sql.setValue("insert into " + tablename + " values(?, ?)");
properties.dieOnError.setValue(true);
randomCommit(properties);
properties.usePreparedStatement.setValue(true);
properties.preparedStatementTable.indexs.setValue(Arrays.asList(1, 2));
properties.preparedStatementTable.types.setValue(Arrays.asList(PreparedStatementTable.Type.Int.name(), PreparedStatementTable.Type.String.name()));
properties.preparedStatementTable.values.setValue(Arrays.<Object>asList(4, "momo"));
JDBCRowSourceOrSink sourceOrSink = new JDBCRowSourceOrSink();
sourceOrSink.initialize(null, properties);
ValidationResult result = sourceOrSink.validate(null);
Assert.assertTrue(result.getStatus() == ValidationResult.Result.OK);
TJDBCInputDefinition definition1 = new TJDBCInputDefinition();
TJDBCInputProperties properties1 = DBTestUtils.createCommonJDBCInputProperties(allSetting, definition1);
List<IndexedRecord> records = DBTestUtils.fetchDataByReaderFromTable(tablename, DBTestUtils.createTestSchema(tablename), definition1, properties1);
assertThat(records, hasSize(4));
Assert.assertEquals(new Integer(4), records.get(3).get(0));
Assert.assertEquals("momo", records.get(3).get(1));
}
Aggregations