use of org.talend.components.simplefileio.SimpleFileIODatasetProperties in project components by Talend.
the class SimpleFileIODatasetRuntimeTest method createDatasetProperties.
/**
* @return the properties for this dataset, fully initialized with the default values.
*/
public static SimpleFileIODatasetProperties createDatasetProperties() {
// Configure the dataset.
SimpleFileIODatasetProperties datasetProps = new SimpleFileIODatasetProperties(null);
datasetProps.init();
datasetProps.setDatastoreProperties(SimpleFileIODatastoreRuntimeTest.createDatastoreProperties());
return datasetProps;
}
use of org.talend.components.simplefileio.SimpleFileIODatasetProperties in project components by Talend.
the class SimpleFileIODatasetRuntimeTest method testGetSchema.
@Test
public void testGetSchema() throws Exception {
writeRandomAvroFile(mini.getFs(), "/user/test/input.avro", getSimpleTestData(0));
String fileSpec = mini.getFs().getUri().resolve("/user/test/input.avro").toString();
// Configure the component.
SimpleFileIODatasetProperties props = createDatasetProperties();
props.format.setValue(SimpleFileIOFormat.AVRO);
props.path.setValue(fileSpec);
// Create the runtime.
SimpleFileIODatasetRuntime runtime = new SimpleFileIODatasetRuntime();
runtime.initialize(null, props);
// Attempt to get a sample using the runtime methods.
Schema actual = runtime.getSchema();
assertThat(actual, notNullValue());
// TODO(rskraba): check the schema with the input file.
}
use of org.talend.components.simplefileio.SimpleFileIODatasetProperties in project components by Talend.
the class SandboxedSimpleFileIODatasetRuntimeTest method createDatasetProperties.
/**
* @return the properties for this dataset, fully initialized with the default values.
*/
public static SimpleFileIODatasetProperties createDatasetProperties() {
// Configure the dataset.
SimpleFileIODatastoreProperties datastoreProps = new SimpleFileIODatastoreProperties(null);
datastoreProps.init();
SimpleFileIODatasetProperties datasetProps = new SimpleFileIODatasetProperties(null);
datasetProps.init();
datasetProps.setDatastoreProperties(datastoreProps);
return datasetProps;
}
use of org.talend.components.simplefileio.SimpleFileIODatasetProperties in project components by Talend.
the class SimpleFileIODatasetRuntimeTest method createDatasetProperties.
/**
* @return the properties for this dataset, fully initialized with the default values.
*/
public static SimpleFileIODatasetProperties createDatasetProperties() {
// Configure the dataset.
SimpleFileIODatastoreProperties datastoreProps = new SimpleFileIODatastoreProperties(null);
datastoreProps.init();
SimpleFileIODatasetProperties datasetProps = new SimpleFileIODatasetProperties(null);
datasetProps.init();
datasetProps.setDatastoreProperties(datastoreProps);
return datasetProps;
}
use of org.talend.components.simplefileio.SimpleFileIODatasetProperties in project components by Talend.
the class SandboxedSimpleFileIODatasetRuntimeTest method testBasic.
@Test
public void testBasic() throws Exception {
File input = folder.newFile("stuff.csv");
try (FileWriter fw = new FileWriter(input)) {
fw.write("1;one");
}
SimpleFileIODatasetProperties props = createDatasetProperties();
props.path.setValue(input.toURI().toString());
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(1));
assertThat(consumed.get(0).get(0), is((Object) "1"));
assertThat(consumed.get(0).get(1), is((Object) "one"));
}
Aggregations