use of org.talend.components.jdbc.dataset.JDBCDatasetProperties in project components by Talend.
the class JDBCDatasetOracleTestIT method createDatasetProperties.
private JDBCDatasetProperties createDatasetProperties() {
JDBCDatastoreDefinition def = new JDBCDatastoreDefinition();
JDBCDatastoreProperties datastore = new JDBCDatastoreProperties("datastore");
datastore.dbTypes.setValue("ORACLE");
datastore.jdbcUrl.setValue(allSetting.getJdbcUrl());
datastore.userId.setValue(allSetting.getUsername());
datastore.password.setValue(allSetting.getPassword());
JDBCDatasetProperties dataset = (JDBCDatasetProperties) def.createDatasetProperties(datastore);
dataset.sql.setValue(DBTestUtils.getSQL(tablename));
return dataset;
}
use of org.talend.components.jdbc.dataset.JDBCDatasetProperties in project components by Talend.
the class JdbcDatasetTestIT method testGetSampleWithValidDesignSchema.
@Test
public void testGetSampleWithValidDesignSchema() {
JDBCDatasetProperties dataset = createDatasetProperties(true);
getSampleAction(dataset);
}
use of org.talend.components.jdbc.dataset.JDBCDatasetProperties in project components by Talend.
the class JdbcDatasetTestIT method testGetSchema.
@Test
public void testGetSchema() {
JDBCDatasetProperties dataset = createDatasetProperties(false);
JDBCDatasetRuntime runtime = new JDBCDatasetRuntime();
runtime.initialize(null, dataset);
Schema schema = runtime.getSchema();
Assert.assertNotNull(schema);
DBTestUtils.testMetadata(schema.getFields(), true);
}
use of org.talend.components.jdbc.dataset.JDBCDatasetProperties in project components by Talend.
the class JdbcDatasetTestIT method testGetSampleWithoutDesignSchema.
@Test
public void testGetSampleWithoutDesignSchema() {
JDBCDatasetProperties dataset = createDatasetProperties(false);
getSampleAction(dataset);
}
use of org.talend.components.jdbc.dataset.JDBCDatasetProperties in project components by Talend.
the class JDBCBeamRuntimeTest method testPipeline.
@Test
public void testPipeline() throws Exception {
JDBCDatastoreProperties jdbcDatastoreProperties;
jdbcDatastoreProperties = new JDBCDatastoreProperties("datastore");
jdbcDatastoreProperties.init();
jdbcDatastoreProperties.dbTypes.setValue("DERBY");
jdbcDatastoreProperties.jdbcUrl.setValue(JDBC_URL);
JDBCDatasetProperties inputDatasetProperties = new JDBCDatasetProperties("inputDataset");
inputDatasetProperties.init();
inputDatasetProperties.setDatastoreProperties(jdbcDatastoreProperties);
inputDatasetProperties.sql.setValue("select * from " + TABLE_IN);
// Schema inputSchema =
// SchemaBuilder.record("DYNAMIC").fields().name("ID").type(SchemaBuilder.builder().stringType())
// .noDefault().name("NAME").type(SchemaBuilder.builder().stringType()).noDefault().endRecord();
// inputDatasetProperties.main.schema.setValue(inputSchema);
JDBCInputProperties inputProperties = new JDBCInputProperties("input");
inputProperties.init();
inputProperties.setDatasetProperties(inputDatasetProperties);
JDBCDatasetProperties outputDatasetProperties = new JDBCDatasetProperties("outputDataset");
outputDatasetProperties.init();
outputDatasetProperties.setDatastoreProperties(jdbcDatastoreProperties);
outputDatasetProperties.sourceType.setValue(JDBCDatasetProperties.SourceType.TABLE_NAME);
outputDatasetProperties.tableName.setValue(TABLE_OUT);
Schema outputSchema = SchemaBuilder.record("DYNAMIC").fields().name("ID").prop(SchemaConstants.TALEND_COLUMN_DB_COLUMN_NAME, "ID").type(SchemaBuilder.builder().intType()).noDefault().name("NAME").prop(SchemaConstants.TALEND_COLUMN_DB_COLUMN_NAME, "NAME").type(SchemaBuilder.builder().stringType()).noDefault().endRecord();
outputDatasetProperties.main.schema.setValue(outputSchema);
JDBCOutputProperties outputProperties = new JDBCOutputProperties("output");
outputProperties.init();
outputProperties.setDatasetProperties(outputDatasetProperties);
outputProperties.dataAction.setValue(JDBCOutputProperties.DataAction.INSERT);
JDBCInputPTransformRuntime inputRuntime = new JDBCInputPTransformRuntime();
inputRuntime.initialize(null, inputProperties);
JDBCOutputPTransformRuntime outputRuntime = new JDBCOutputPTransformRuntime();
outputRuntime.initialize(null, outputProperties);
pipeline.apply(inputRuntime).apply(outputRuntime);
PipelineResult pipelineResult = pipeline.run();
Map<Integer, String> results = new HashMap<>();
try (Connection connection = dataSource.getConnection()) {
try (Statement statement = connection.createStatement()) {
try (ResultSet resultSet = statement.executeQuery("select * from " + TABLE_OUT)) {
while (resultSet.next()) {
results.put(resultSet.getInt(1), resultSet.getString(2));
}
}
}
}
assertEquals(assertRows, results);
}
Aggregations