use of org.talend.components.jdbc.dataset.JDBCDatasetProperties in project components by Talend.
the class JdbcInputTestIT method createCommonJDBCInputProperties.
private JDBCInputProperties createCommonJDBCInputProperties(JDBCInputDefinition definition) {
JDBCDatastoreDefinition datastore_def = new JDBCDatastoreDefinition();
JDBCDatastoreProperties datastore_props = new JDBCDatastoreProperties("datastore");
datastore_props.dbTypes.setValue("DERBY");
datastore_props.afterDbTypes();
datastore_props.jdbcUrl.setValue(allSetting.getJdbcUrl());
datastore_props.userId.setValue(allSetting.getUsername());
datastore_props.password.setValue(allSetting.getPassword());
JDBCDatasetProperties dataset = (JDBCDatasetProperties) datastore_def.createDatasetProperties(datastore_props);
dataset.sql.setValue(DBTestUtils.getSQL(tablename));
dataset.updateSchema();
JDBCInputProperties properties = (JDBCInputProperties) definition.createRuntimeProperties();
properties.setDatasetProperties(dataset);
return properties;
}
use of org.talend.components.jdbc.dataset.JDBCDatasetProperties in project components by Talend.
the class JdbcDatasetRuntimeTest method testBasic.
@Test
public void testBasic() throws Exception {
JDBCDatasetProperties props = createDatasetProperties();
final List<IndexedRecord> consumed = new ArrayList<>();
RuntimeInfo ri = def.getRuntimeInfo(props);
try (SandboxedInstance si = RuntimeUtil.createRuntimeClass(ri, getClass().getClassLoader())) {
DatasetRuntime runtime = (DatasetRuntime) si.getInstance();
runtime.initialize(null, props);
assertThat(runtime, not(nullValue()));
Schema s = runtime.getSchema();
assertThat(s, not(nullValue()));
runtime.getSample(100, new Consumer<IndexedRecord>() {
@Override
public void accept(IndexedRecord ir) {
consumed.add(ir);
}
});
}
assertThat(consumed, hasSize(2));
}
use of org.talend.components.jdbc.dataset.JDBCDatasetProperties 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);
}
use of org.talend.components.jdbc.dataset.JDBCDatasetProperties 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;
}
use of org.talend.components.jdbc.dataset.JDBCDatasetProperties in project components by Talend.
the class JdbcComponentTestIT method initializeJDBCDatasetProperties.
@Test
public void initializeJDBCDatasetProperties() throws java.io.IOException {
// given
SerPropertiesDto propDto = new SerPropertiesDto();
propDto.setProperties(new JDBCDatasetProperties("").init().toSerialized());
propDto.setDependencies(singletonList(new JDBCDatastoreProperties("").init().toSerialized()));
// when
Response response = //
given().content(propDto).contentType(ServiceConstants.JSONIO_CONTENT_TYPE).accept(//
ServiceConstants.UI_SPEC_CONTENT_TYPE).expect().statusCode(200).log().ifError().post(getVersionPrefix() + "/properties/uispec");
// then
ObjectNode jdbcProperties = mapper.readerFor(ObjectNode.class).readValue(response.asInputStream());
assertNotNull(jdbcProperties.get("jsonSchema"));
assertNotNull(jdbcProperties.get("properties"));
assertNotNull(jdbcProperties.get("uiSchema"));
assertEquals("JDBCDataset", jdbcProperties.get("properties").get("@definitionName").textValue());
}
Aggregations