use of org.talend.components.jdbc.runtime.JDBCSourceOrSink in project components by Talend.
the class JDBCConnectionTestIT method testConnectionWithEmptyDriver.
@Test
public void testConnectionWithEmptyDriver() {
TJDBCConnectionDefinition definition = new TJDBCConnectionDefinition();
TJDBCConnectionProperties properties = (TJDBCConnectionProperties) definition.createRuntimeProperties();
properties.connection.jdbcUrl.setValue(allSetting.getJdbcUrl());
properties.connection.driverClass.setValue(null);
properties.connection.userPassword.userId.setValue(allSetting.getUsername());
properties.connection.userPassword.password.setValue(allSetting.getPassword());
JDBCSourceOrSink sourceOrSink = new JDBCSourceOrSink();
sourceOrSink.initialize(null, properties);
ValidationResult result = sourceOrSink.validate(null);
assertTrue(result.getStatus() == ValidationResult.Result.ERROR);
assertTrue(result.getMessage() != null && result.getMessage().contains("Driver Class"));
}
use of org.talend.components.jdbc.runtime.JDBCSourceOrSink in project components by Talend.
the class JDBCConnectionTestIT method testConnectionWithWrongURL.
@Test
public void testConnectionWithWrongURL() {
TJDBCConnectionDefinition definition = new TJDBCConnectionDefinition();
TJDBCConnectionProperties properties = (TJDBCConnectionProperties) definition.createRuntimeProperties();
properties.connection.driverClass.setValue(allSetting.getDriverClass());
properties.connection.jdbcUrl.setValue("wrongUrl");
properties.connection.userPassword.userId.setValue(allSetting.getUsername());
properties.connection.userPassword.password.setValue(allSetting.getPassword());
JDBCSourceOrSink sourceOrSink = new JDBCSourceOrSink();
sourceOrSink.initialize(null, properties);
ValidationResult result = sourceOrSink.validate(null);
assertTrue(result.getStatus() == ValidationResult.Result.ERROR);
assertTrue(result.getMessage() != null && !result.getMessage().isEmpty());
}
use of org.talend.components.jdbc.runtime.JDBCSourceOrSink in project components by Talend.
the class JDBCConnectionTestIT method testAutoCommit.
@Test
public void testAutoCommit() {
TJDBCConnectionDefinition definition = new TJDBCConnectionDefinition();
TJDBCConnectionProperties properties = DBTestUtils.createCommonJDBCConnectionProperties(allSetting, definition);
properties.useAutoCommit.setValue(true);
properties.autocommit.setValue(true);
JDBCSourceOrSink sourceOrSink = new JDBCSourceOrSink();
sourceOrSink.initialize(null, properties);
ValidationResult result = sourceOrSink.validate(null);
assertTrue(result.getStatus() == ValidationResult.Result.OK);
try (Connection conn = sourceOrSink.getConnection(null)) {
assertTrue(conn.getAutoCommit());
assertTrue(!conn.isClosed());
} catch (ClassNotFoundException | SQLException e) {
Assert.fail(e.getMessage());
}
}
use of org.talend.components.jdbc.runtime.JDBCSourceOrSink in project components by Talend.
the class JDBCDatasetTestIT method testGetSchemaFromTable.
@Test
public void testGetSchemaFromTable() throws IOException {
JDBCDatasetProperties dataset = createDatasetProperties(false);
JDBCDatasetRuntime runtime = new JDBCDatasetRuntime();
runtime.initialize(null, dataset);
JDBCSourceOrSink jss = new JDBCSourceOrSink();
jss.initialize(null, dataset);
Schema schema = jss.getEndpointSchema(null, tablename);
Assert.assertNotNull(schema);
DBTestUtils.testMetadata(schema.getFields(), true);
jss.getEndpointSchema(null, tablename_all_type);
// TODO assert the result
}
use of org.talend.components.jdbc.runtime.JDBCSourceOrSink in project components by Talend.
the class JDBCDatasetRuntime method getSchema.
@Override
public Schema getSchema() {
JDBCSourceOrSink jss = new JDBCSourceOrSink();
jss.initialize(container, dataset);
return jss.getSchemaFromQuery(container, dataset.getRuntimeSetting().getSql());
}
Aggregations