use of org.talend.components.jdbc.tjdbcconnection.TJDBCConnectionProperties in project components by Talend.
the class JDBCConnectionTestIT method testEliminateSpaceURL.
@Test
public void testEliminateSpaceURL() {
TJDBCConnectionDefinition definition = new TJDBCConnectionDefinition();
TJDBCConnectionProperties properties = DBTestUtils.createCommonJDBCConnectionProperties(allSetting, definition);
properties.connection.jdbcUrl.setValue(" a_value_with_space_around_it. ");
AllSetting setting = properties.getRuntimeSetting();
assertTrue("a_value_with_space_around_it.".equals(setting.getJdbcUrl()));
}
use of org.talend.components.jdbc.tjdbcconnection.TJDBCConnectionProperties in project components by Talend.
the class JDBCConnectionTestIT method testConnectionWithEmptyJDBCURL.
@Test
public void testConnectionWithEmptyJDBCURL() {
TJDBCConnectionDefinition definition = new TJDBCConnectionDefinition();
TJDBCConnectionProperties properties = (TJDBCConnectionProperties) definition.createRuntimeProperties();
properties.connection.jdbcUrl.setValue("");
properties.connection.driverClass.setValue(allSetting.getDriverClass());
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("JDBC URL"));
}
use of org.talend.components.jdbc.tjdbcconnection.TJDBCConnectionProperties in project components by Talend.
the class JDBCConnectionTestIT method testNotAutoCommit.
@Test
public void testNotAutoCommit() {
TJDBCConnectionDefinition definition = new TJDBCConnectionDefinition();
TJDBCConnectionProperties properties = DBTestUtils.createCommonJDBCConnectionProperties(allSetting, definition);
properties.useAutoCommit.setValue(true);
properties.autocommit.setValue(false);
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.tjdbcconnection.TJDBCConnectionProperties 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.tjdbcconnection.TJDBCConnectionProperties 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());
}
Aggregations