use of org.talend.components.jdbc.runtime.writer.JDBCSPWriter in project components by Talend.
the class JDBCSPTestIT method test_basic_as_output_and_no_input.
@SuppressWarnings("rawtypes")
@Test
public void test_basic_as_output_and_no_input() throws Exception {
TJDBCSPDefinition definition = new TJDBCSPDefinition();
TJDBCSPProperties properties = DBTestUtils.createCommonJDBCSPProperties(allSetting, definition);
properties.spName.setValue("SYSCS_UTIL.SYSCS_DISABLE_LOG_ARCHIVE_MODE");
properties.main.schema.setValue(DBTestUtils.createSPSchema1(tablename));
properties.spParameterTable.parameterTypes.setValue(Arrays.asList(SPParameterTable.ParameterType.IN.name()));
properties.spParameterTable.schemaColumns.setValue(Arrays.asList("PARAMETER"));
JDBCSPSink sink = new JDBCSPSink();
sink.initialize(null, properties);
ValidationResult result = sink.validate(null);
Assert.assertTrue(result.getStatus() == ValidationResult.Result.OK);
WriteOperation operation = sink.createWriteOperation();
JDBCSPWriter writer = (JDBCSPWriter) operation.createWriter(null);
try {
writer.open("wid");
IndexedRecord r1 = new GenericData.Record(properties.main.schema.getValue());
r1.put(0, 0);
writer.write(r1);
} finally {
writer.close();
}
}
use of org.talend.components.jdbc.runtime.writer.JDBCSPWriter in project components by Talend.
the class JDBCSPTestIT method test_basic_as_output_and_input.
@SuppressWarnings("rawtypes")
@Test
public void test_basic_as_output_and_input() throws Exception {
TJDBCSPDefinition definition = new TJDBCSPDefinition();
TJDBCSPProperties properties = DBTestUtils.createCommonJDBCSPProperties(allSetting, definition);
properties.spName.setValue("SYSCS_UTIL.SYSCS_DISABLE_LOG_ARCHIVE_MODE");
Schema schema = DBTestUtils.createSPSchema3(tablename);
properties.main.schema.setValue(schema);
properties.schemaFlow.schema.setValue(schema);
properties.spParameterTable.parameterTypes.setValue(Arrays.asList(SPParameterTable.ParameterType.IN.name()));
properties.spParameterTable.schemaColumns.setValue(Arrays.asList("PARAMETER1"));
JDBCSPSink sink = new JDBCSPSink();
sink.initialize(null, properties);
ValidationResult result = sink.validate(null);
Assert.assertTrue(result.getStatus() == ValidationResult.Result.OK);
WriteOperation operation = sink.createWriteOperation();
JDBCSPWriter writer = (JDBCSPWriter) operation.createWriter(null);
try {
writer.open("wid");
IndexedRecord r1 = new GenericData.Record(properties.main.schema.getValue());
r1.put(0, 0);
r1.put(1, "wangwei");
writer.write(r1);
List<IndexedRecord> writeResult = writer.getSuccessfulWrites();
Assert.assertEquals(1, writeResult.size());
IndexedRecord record = writeResult.get(0);
Assert.assertEquals(Integer.valueOf(0), record.get(0));
Assert.assertEquals("wangwei", record.get(1));
writer.cleanWrites();
} finally {
writer.close();
}
}
Aggregations