Search in sources :

Example 6 with AllSetting

use of org.talend.components.jdbc.runtime.setting.AllSetting in project components by Talend.

the class TJDBCRowProperties method getRuntimeSetting.

@Override
public AllSetting getRuntimeSetting() {
    AllSetting setting = new AllSetting();
    CommonUtils.setReferenceInfoAndConnectionInfo(setting, referencedComponent, connection);
    setting.setTablename(this.tableSelection.tablename.getValue());
    setting.setSql(this.sql.getValue());
    setting.setDieOnError(this.dieOnError.getValue());
    setting.setCommitEvery(this.commitEvery.getValue());
    setting.setPropagateQueryResultSet(this.propagateQueryResultSet.getValue());
    setting.setUseColumn(this.useColumn.getValue());
    setting.setUsePreparedStatement(this.usePreparedStatement.getValue());
    setting.setIndexs(this.preparedStatementTable.indexs.getValue());
    setting.setTypes(this.preparedStatementTable.types.getValue());
    setting.setValues(this.preparedStatementTable.values.getValue());
    setting.setUseDataSource(this.useDataSource.getValue());
    setting.setDataSource(this.dataSource.getValue());
    setting.setSchema(main.schema.getValue());
    return setting;
}
Also used : AllSetting(org.talend.components.jdbc.runtime.setting.AllSetting)

Example 7 with AllSetting

use of org.talend.components.jdbc.runtime.setting.AllSetting in project components by Talend.

the class JDBCDatastoreTest method testGetSchemaNames.

@Test
public void testGetSchemaNames() throws Exception {
    JDBCDatastoreProperties properties = new JDBCDatastoreProperties("input");
    properties.init();
    List<?> dbTypes = properties.dbTypes.getPossibleValues();
    assertTrue("the list should not be empty", dbTypes != null && !dbTypes.isEmpty());
    assertTrue("The size of list is not right", dbTypes.size() == 3);
    assertTrue("The first element is not right", "MYSQL".equals(dbTypes.get(0)));
    assertTrue("The second element is not right", "DERBY".equals(dbTypes.get(1)));
    assertTrue("The default value is not right", "MYSQL".equals(properties.dbTypes.getValue()));
    AllSetting setting = properties.getRuntimeSetting();
    assertTrue("the driver class is not right : " + setting.getDriverClass(), "org.gjt.mm.mysql.Driver".equals(setting.getDriverClass()));
    assertTrue("the driver paths is not right : " + setting.getDriverPaths(), setting.getDriverPaths() != null && !setting.getDriverPaths().isEmpty() && "mvn:org.talend.libraries/mysql-connector-java-5.1.30-bin/6.0.0/jar".equals(setting.getDriverPaths().get(0)));
    properties.dbTypes.setValue("DERBY");
    properties.afterDbTypes();
    setting = properties.getRuntimeSetting();
    assertTrue("the driver class is not right : " + setting.getDriverClass(), "org.apache.derby.jdbc.ClientDriver".equals(setting.getDriverClass()));
    assertTrue("the driver paths is not right : " + setting.getDriverPaths(), setting.getDriverPaths() != null && !setting.getDriverPaths().isEmpty() && "mvn:org.apache.derby/derby/10.12.1.1".equals(setting.getDriverPaths().get(0)));
}
Also used : AllSetting(org.talend.components.jdbc.runtime.setting.AllSetting) JDBCDatastoreProperties(org.talend.components.jdbc.datastore.JDBCDatastoreProperties) Test(org.junit.Test)

Example 8 with AllSetting

use of org.talend.components.jdbc.runtime.setting.AllSetting in project components by Talend.

the class JDBCInputPropertiesTest method testGetRuntimeSetting.

/**
 * Run the AllSetting getRuntimeSetting() method test.
 *
 * @throws Exception
 *
 * @generatedBy CodePro at 17-6-23 AM11:58
 */
@Test
public void testGetRuntimeSetting() throws Exception {
    JDBCInputProperties fixture = new JDBCInputProperties("");
    JDBCDatasetProperties dataset = new JDBCDatasetProperties("dataset");
    JDBCDatastoreProperties datastore = new JDBCDatastoreProperties("datastore");
    datastore.init();
    dataset.setDatastoreProperties(datastore);
    fixture.setDatasetProperties(dataset);
    AllSetting result = fixture.getRuntimeSetting();
    assertNotNull(result);
}
Also used : AllSetting(org.talend.components.jdbc.runtime.setting.AllSetting) JDBCDatasetProperties(org.talend.components.jdbc.dataset.JDBCDatasetProperties) JDBCDatastoreProperties(org.talend.components.jdbc.datastore.JDBCDatastoreProperties) Test(org.junit.Test)

Example 9 with AllSetting

use of org.talend.components.jdbc.runtime.setting.AllSetting in project components by Talend.

the class JDBCDatasetPropertiesTest method testGetRuntimeSetting.

@Test
public void testGetRuntimeSetting() {
    dataset.setDatastoreProperties(new JDBCDatastoreProperties("datastore"));
    dataset.sourceType.setValue(SourceType.TABLE_NAME);
    AllSetting setting = dataset.getRuntimeSetting();
    Assert.assertNotNull(setting);
}
Also used : AllSetting(org.talend.components.jdbc.runtime.setting.AllSetting) JDBCDatastoreProperties(org.talend.components.jdbc.datastore.JDBCDatastoreProperties) Test(org.junit.Test)

Example 10 with AllSetting

use of org.talend.components.jdbc.runtime.setting.AllSetting in project components by Talend.

the class JDBCOutputDefinitionTest method getRuntimeInfo.

@Test
public void getRuntimeInfo() throws Exception {
    AllSetting allSetting = Mockito.mock(AllSetting.class);
    Mockito.when(allSetting.getDriverClass()).thenReturn("anyDriverClass");
    JDBCOutputProperties anyProperties = Mockito.mock(JDBCOutputProperties.class);
    Mockito.when(anyProperties.getRuntimeSetting()).thenReturn(allSetting);
    RuntimeInfo runtimeInfo = definition.getRuntimeInfo(ExecutionEngine.BEAM, anyProperties, null);
    assertEquals(JDBCOutputDefinition.BEAM_RUNTIME, runtimeInfo.getRuntimeClassName());
}
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