use of org.talend.components.jdbc.runtime.JDBCSPSource in project components by Talend.
the class JDBCSPTestIT method test_basic_as_input.
@SuppressWarnings("rawtypes")
@Test
public void test_basic_as_input() throws Exception {
TJDBCSPDefinition definition = new TJDBCSPDefinition();
TJDBCSPProperties properties = DBTestUtils.createCommonJDBCSPProperties(allSetting, definition);
properties.isFunction.setValue(true);
properties.returnResultIn.setValue("PARAMETER");
properties.spName.setValue("SYSCS_UTIL.SYSCS_GET_DATABASE_NAME");
Schema schema = DBTestUtils.createSPSchema2(tablename);
properties.main.schema.setValue(schema);
properties.schemaFlow.schema.setValue(schema);
JDBCSPSource source = new JDBCSPSource();
source.initialize(null, properties);
ValidationResult result = source.validate(null);
Assert.assertTrue(result.getStatus() == ValidationResult.Result.OK);
Reader reader = source.createReader(null);
try {
reader.start();
IndexedRecord row = (IndexedRecord) reader.getCurrent();
String v1 = (String) row.get(0);
Assert.assertEquals("memory:myDB", v1);
// only output one row when it works as a input component
Assert.assertFalse(reader.advance());
reader.close();
} finally {
reader.close();
}
}
Aggregations