use of org.talend.components.jdbc.runtime.setting.AllSetting 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.runtime.setting.AllSetting in project components by Talend.
the class JDBCDatasetOracleTestIT method beforeClass.
@BeforeClass
public static void beforeClass() throws Exception {
allSetting = new AllSetting();
// please set your connection parameter
allSetting.setDriverClass("oracle.jdbc.OracleDriver");
allSetting.setJdbcUrl("jdbc:oracle:thin:@host:1521:db");
allSetting.setUsername("");
allSetting.setPassword("");
try (Connection conn = JdbcRuntimeUtils.createConnection(allSetting)) {
DBTestUtils.createTestTable(conn, tablename);
DBTestUtils.loadTestData(conn, tablename);
}
}
use of org.talend.components.jdbc.runtime.setting.AllSetting in project components by Talend.
the class JDBCSourceOrSink method connect.
public Connection connect(RuntimeContainer runtime) throws ClassNotFoundException, SQLException {
AllSetting setting = properties.getRuntimeSetting();
// connection component
Connection conn = JdbcRuntimeUtils.createConnectionOrGetFromSharedConnectionPoolOrDataSource(runtime, setting, work4dataprep);
if (setting.getUseAutoCommit()) {
conn.setAutoCommit(setting.getAutocommit());
}
if (runtime != null) {
// if you check the api, you will find the parameter is set to the wrong location, but it's right now, as we need to
// keep the connection component can work with some old javajet components
runtime.setComponentData(ComponentConstants.CONNECTION_KEY, runtime.getCurrentComponentId(), conn);
runtime.setComponentData(ComponentConstants.URL_KEY, runtime.getCurrentComponentId(), setting.getJdbcUrl());
runtime.setComponentData(ComponentConstants.USERNAME_KEY, runtime.getCurrentComponentId(), setting.getUsername());
}
return conn;
}
use of org.talend.components.jdbc.runtime.setting.AllSetting in project components by Talend.
the class TJDBCRowDefinitionTest method testGetRuntimeInfo.
/**
* Run the RuntimeInfo getRuntimeInfo(ExecutionEngine,ComponentProperties,ConnectorTopology) method test.
*
* @throws Exception
*
* @generatedBy CodePro at 17-6-20 PM3:14
*/
@Test
public void testGetRuntimeInfo() throws Exception {
AllSetting allSetting = Mockito.mock(AllSetting.class);
Mockito.when(allSetting.getDriverClass()).thenReturn("anyDriverClass");
TJDBCRowProperties properties = Mockito.mock(TJDBCRowProperties.class);
Mockito.when(properties.getRuntimeSetting()).thenReturn(allSetting);
TJDBCRowDefinition fixture = new TJDBCRowDefinition();
ExecutionEngine engine = ExecutionEngine.DI;
RuntimeInfo result = fixture.getRuntimeInfo(engine, properties, ConnectorTopology.INCOMING);
assertNotNull(result);
result = fixture.getRuntimeInfo(engine, properties, ConnectorTopology.OUTGOING);
assertNotNull(result);
result = fixture.getRuntimeInfo(engine, properties, ConnectorTopology.NONE);
assertNotNull(result);
result = fixture.getRuntimeInfo(engine, properties, ConnectorTopology.INCOMING_AND_OUTGOING);
assertNotNull(result);
}
use of org.talend.components.jdbc.runtime.setting.AllSetting in project components by Talend.
the class JDBCDatastoreDefinitionTest method testGetRuntimeInfo.
/**
* Run the RuntimeInfo getRuntimeInfo(JDBCDatastoreProperties) method test.
*
* @throws Exception
*
* @generatedBy CodePro at 17-6-23 PM2:14
*/
@Test
public void testGetRuntimeInfo() throws Exception {
AllSetting allSetting = Mockito.mock(AllSetting.class);
Mockito.when(allSetting.getDriverClass()).thenReturn("anyDriverClass");
JDBCDatastoreProperties properties = Mockito.mock(JDBCDatastoreProperties.class);
Mockito.when(properties.getRuntimeSetting()).thenReturn(allSetting);
JDBCDatastoreDefinition fixture = new JDBCDatastoreDefinition();
RuntimeInfo result = fixture.getRuntimeInfo(properties);
assertNotNull(result);
}
Aggregations