Search in sources :

Example 6 with JDBCDatastoreProperties

use of org.talend.components.jdbc.datastore.JDBCDatastoreProperties 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 7 with JDBCDatastoreProperties

use of org.talend.components.jdbc.datastore.JDBCDatastoreProperties 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 8 with JDBCDatastoreProperties

use of org.talend.components.jdbc.datastore.JDBCDatastoreProperties 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 9 with JDBCDatastoreProperties

use of org.talend.components.jdbc.datastore.JDBCDatastoreProperties in project components by Talend.

the class JDBCInputProperties method getRuntimeSetting.

@Override
public AllSetting getRuntimeSetting() {
    AllSetting setting = new AllSetting();
    JDBCDatasetProperties datasetProperties = this.getDatasetProperties();
    JDBCDatastoreProperties datastoreProperties = datasetProperties.getDatastoreProperties();
    setting.setDriverPaths(datastoreProperties.getCurrentDriverPaths());
    setting.setDriverClass(datastoreProperties.getCurrentDriverClass());
    setting.setJdbcUrl(datastoreProperties.jdbcUrl.getValue());
    setting.setUsername(datastoreProperties.userId.getValue());
    setting.setPassword(datastoreProperties.password.getValue());
    setting.setSql(datasetProperties.sql.getValue());
    setting.setSchema(datasetProperties.main.schema.getValue());
    return setting;
}
Also used : AllSetting(org.talend.components.jdbc.runtime.setting.AllSetting) JDBCDatasetProperties(org.talend.components.jdbc.dataset.JDBCDatasetProperties) JDBCDatastoreProperties(org.talend.components.jdbc.datastore.JDBCDatastoreProperties)

Example 10 with JDBCDatastoreProperties

use of org.talend.components.jdbc.datastore.JDBCDatastoreProperties in project components by Talend.

the class JDBCDatasetProperties method getRuntimeSetting.

@Override
public AllSetting getRuntimeSetting() {
    JDBCDatastoreProperties datastoreProperties = this.getDatastoreProperties();
    setting.setDriverPaths(datastoreProperties.getCurrentDriverPaths());
    setting.setDriverClass(datastoreProperties.getCurrentDriverClass());
    setting.setJdbcUrl(datastoreProperties.jdbcUrl.getValue());
    setting.setUsername(datastoreProperties.userId.getValue());
    setting.setPassword(datastoreProperties.password.getValue());
    setting.setSchema(main.schema.getValue());
    setting.setSql(getSql());
    if (sourceType.getValue() == SourceType.TABLE_NAME) {
        setting.setTablename(tableName.getValue());
    }
    return setting;
}
Also used : JDBCDatastoreProperties(org.talend.components.jdbc.datastore.JDBCDatastoreProperties)

Aggregations

JDBCDatastoreProperties (org.talend.components.jdbc.datastore.JDBCDatastoreProperties)16 JDBCDatasetProperties (org.talend.components.jdbc.dataset.JDBCDatasetProperties)12 Test (org.junit.Test)7 AllSetting (org.talend.components.jdbc.runtime.setting.AllSetting)6 JDBCDatastoreDefinition (org.talend.components.jdbc.datastore.JDBCDatastoreDefinition)5 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 Response (com.jayway.restassured.response.Response)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 SerPropertiesDto (org.talend.components.service.rest.dto.SerPropertiesDto)2 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 Statement (java.sql.Statement)1 HashMap (java.util.HashMap)1 Schema (org.apache.avro.Schema)1 PipelineResult (org.apache.beam.sdk.PipelineResult)1 JDBCInputProperties (org.talend.components.jdbc.dataprep.JDBCInputProperties)1 JDBCOutputProperties (org.talend.components.jdbc.datastream.JDBCOutputProperties)1