Search in sources :

Example 76 with RuntimeInfo

use of org.talend.daikon.runtime.RuntimeInfo in project components by Talend.

the class BigQueryInputDefinitionTest method testRuntimeInfo.

@Test
@Ignore("This can't work unless the runtime jar is already installed in maven!")
public void testRuntimeInfo() {
    RuntimeInfo runtimeInfo = inputDefinition.getRuntimeInfo(ExecutionEngine.BEAM, null, null);
    assertEquals("org.talend.components.bigquery.runtime.BigQueryInputRuntime", runtimeInfo.getRuntimeClassName());
}
Also used : RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 77 with RuntimeInfo

use of org.talend.daikon.runtime.RuntimeInfo in project components by Talend.

the class BigQueryDatasetTestIT method testBasic.

@Test
public void testBasic() throws Exception {
    BigQueryDatasetProperties props = createDatasetProperties();
    props.sourceType.setValue(SourceType.QUERY);
    props.query.setValue("SELECT * FROM [bigquery-public-data:samples.shakespeare] LIMIT 1");
    props.useLegacySql.setValue(true);
    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));
}
Also used : SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) IndexedRecord(org.apache.avro.generic.IndexedRecord) RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) DatasetRuntime(org.talend.components.common.dataset.runtime.DatasetRuntime) Schema(org.apache.avro.Schema) ArrayList(java.util.ArrayList) BigQueryDatasetProperties(org.talend.components.bigquery.BigQueryDatasetProperties) Test(org.junit.Test)

Example 78 with RuntimeInfo

use of org.talend.daikon.runtime.RuntimeInfo 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"));
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) DatasetRuntime(org.talend.components.common.dataset.runtime.DatasetRuntime) FileWriter(java.io.FileWriter) Schema(org.apache.avro.Schema) ArrayList(java.util.ArrayList) SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) File(java.io.File) SimpleFileIODatasetProperties(org.talend.components.simplefileio.SimpleFileIODatasetProperties) Test(org.junit.Test)

Example 79 with RuntimeInfo

use of org.talend.daikon.runtime.RuntimeInfo in project components by Talend.

the class SimpleFileIODatasetRuntimeTest 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"));
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) DatasetRuntime(org.talend.components.common.dataset.runtime.DatasetRuntime) FileWriter(java.io.FileWriter) Schema(org.apache.avro.Schema) ArrayList(java.util.ArrayList) SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) File(java.io.File) SimpleFileIODatasetProperties(org.talend.components.simplefileio.SimpleFileIODatasetProperties) Test(org.junit.Test)

Example 80 with RuntimeInfo

use of org.talend.daikon.runtime.RuntimeInfo in project components by Talend.

the class ElasticsearchInputDefinitionTest method testRuntimeInfo.

/**
 * Check {@link ElasticsearchInputDefinition#getRuntimeInfo(ComponentProperties, ConnectorTopology)} returns RuntimeInfo,
 * which runtime class name is "org.talend.components.elasticsearch.runtime_2_4.ElasticsearchInputRuntime"
 */
@Test
@Ignore("This can't work unless the runtime jar is already installed in maven!")
public void testRuntimeInfo() {
    RuntimeInfo runtimeInfo = inputDefinition.getRuntimeInfo(ExecutionEngine.BEAM, null, null);
    assertEquals("org.talend.components.elasticsearch.runtime_2_4.ElasticsearchInputRuntime", runtimeInfo.getRuntimeClassName());
}
Also used : RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

RuntimeInfo (org.talend.daikon.runtime.RuntimeInfo)131 Test (org.junit.Test)120 SandboxedInstance (org.talend.daikon.sandbox.SandboxedInstance)27 Ignore (org.junit.Ignore)21 JarRuntimeInfo (org.talend.components.api.component.runtime.JarRuntimeInfo)17 ArrayList (java.util.ArrayList)13 AllSetting (org.talend.components.jdbc.runtime.setting.AllSetting)11 IndexedRecord (org.apache.avro.generic.IndexedRecord)8 ExecutionEngine (org.talend.components.api.component.runtime.ExecutionEngine)8 DatasetRuntime (org.talend.components.common.dataset.runtime.DatasetRuntime)7 URL (java.net.URL)6 Schema (org.apache.avro.Schema)6 ComponentException (org.talend.components.api.exception.ComponentException)5 ValidationResult (org.talend.daikon.properties.ValidationResult)5 File (java.io.File)3 NamedThing (org.talend.daikon.NamedThing)3 SimpleNamedThing (org.talend.daikon.SimpleNamedThing)3 TalendRuntimeException (org.talend.daikon.exception.TalendRuntimeException)3 FileWriter (java.io.FileWriter)2 GenericRecord (org.apache.avro.generic.GenericRecord)2