Search in sources :

Example 1 with AllSetting

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()));
}
Also used : TJDBCConnectionProperties(org.talend.components.jdbc.tjdbcconnection.TJDBCConnectionProperties) AllSetting(org.talend.components.jdbc.runtime.setting.AllSetting) TJDBCConnectionDefinition(org.talend.components.jdbc.tjdbcconnection.TJDBCConnectionDefinition) Test(org.junit.Test)

Example 2 with AllSetting

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);
    }
}
Also used : AllSetting(org.talend.components.jdbc.runtime.setting.AllSetting) Connection(java.sql.Connection) BeforeClass(org.junit.BeforeClass)

Example 3 with AllSetting

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;
}
Also used : AllSetting(org.talend.components.jdbc.runtime.setting.AllSetting) Connection(java.sql.Connection)

Example 4 with AllSetting

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);
}
Also used : ExecutionEngine(org.talend.components.api.component.runtime.ExecutionEngine) AllSetting(org.talend.components.jdbc.runtime.setting.AllSetting) RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) Test(org.junit.Test)

Example 5 with AllSetting

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);
}
Also used : AllSetting(org.talend.components.jdbc.runtime.setting.AllSetting) RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) Test(org.junit.Test)

Aggregations

AllSetting (org.talend.components.jdbc.runtime.setting.AllSetting)56 Test (org.junit.Test)38 RuntimeInfo (org.talend.daikon.runtime.RuntimeInfo)11 ExecutionEngine (org.talend.components.api.component.runtime.ExecutionEngine)7 JDBCDatastoreProperties (org.talend.components.jdbc.datastore.JDBCDatastoreProperties)6 JDBCDatasetProperties (org.talend.components.jdbc.dataset.JDBCDatasetProperties)4 Connection (java.sql.Connection)3 InputStream (java.io.InputStream)1 URL (java.net.URL)1 URLClassLoader (java.net.URLClassLoader)1 PreparedStatement (java.sql.PreparedStatement)1 SQLException (java.sql.SQLException)1 Statement (java.sql.Statement)1 ArrayList (java.util.ArrayList)1 JarEntry (java.util.jar.JarEntry)1 JarInputStream (java.util.jar.JarInputStream)1 BeforeClass (org.junit.BeforeClass)1 JDBCAvroRegistryString (org.talend.components.jdbc.avro.JDBCAvroRegistryString)1 JDBCConnectionModule (org.talend.components.jdbc.module.JDBCConnectionModule)1 TJDBCConnectionDefinition (org.talend.components.jdbc.tjdbcconnection.TJDBCConnectionDefinition)1