Search in sources :

Example 1 with RuntimableRuntime

use of org.talend.components.api.component.runtime.RuntimableRuntime in project components by Talend.

the class SandboxedFixedFlowInputRuntimeTest method testBasic.

@Test
public void testBasic() throws Exception {
    // The two records to use as values.
    GenericRecord r1 = new GenericData.Record(SampleSchemas.recordSimple());
    r1.put("id", 1);
    r1.put("name", "one");
    GenericRecord r2 = new GenericData.Record(SampleSchemas.recordSimple());
    r2.put("id", 2);
    r2.put("name", "two");
    final FixedFlowInputProperties props = createComponentProperties();
    props.schemaFlow.schema.setValue(SampleSchemas.recordSimple());
    props.values.setValue(r1.toString());
    props.nbRows.setValue(2);
    RuntimeInfo ri = def.getRuntimeInfo(ExecutionEngine.BEAM, props, ConnectorTopology.OUTGOING);
    try (SandboxedInstance si = RuntimeUtil.createRuntimeClass(ri, getClass().getClassLoader())) {
        RuntimableRuntime<FixedFlowInputProperties> runtime = (RuntimableRuntime<FixedFlowInputProperties>) si.getInstance();
        runtime.initialize(null, props);
    // The functionality of the runtime is tested in its own module.
    }
}
Also used : SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) RuntimableRuntime(org.talend.components.api.component.runtime.RuntimableRuntime) RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) FixedFlowInputProperties(org.talend.components.localio.fixedflowinput.FixedFlowInputProperties) GenericRecord(org.apache.avro.generic.GenericRecord) IndexedRecord(org.apache.avro.generic.IndexedRecord) GenericRecord(org.apache.avro.generic.GenericRecord) Test(org.junit.Test)

Example 2 with RuntimableRuntime

use of org.talend.components.api.component.runtime.RuntimableRuntime in project components by Talend.

the class SandboxedRowGeneratorRuntimeTest method testBasic.

@Test
public void testBasic() throws Exception {
    final RowGeneratorProperties props = createComponentProperties();
    props.schemaFlow.schema.setValue(SampleSchemas.recordSimple());
    props.nbRows.setValue(95L);
    props.nbPartitions.setValue(10);
    RuntimeInfo ri = def.getRuntimeInfo(ExecutionEngine.BEAM, props, ConnectorTopology.OUTGOING);
    try (SandboxedInstance si = RuntimeUtil.createRuntimeClass(ri, getClass().getClassLoader())) {
        RuntimableRuntime<RowGeneratorProperties> runtime = (RuntimableRuntime<RowGeneratorProperties>) si.getInstance();
        runtime.initialize(null, props);
    }
}
Also used : SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) RuntimableRuntime(org.talend.components.api.component.runtime.RuntimableRuntime) RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) RowGeneratorProperties(org.talend.components.localio.rowgenerator.RowGeneratorProperties) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 RuntimableRuntime (org.talend.components.api.component.runtime.RuntimableRuntime)2 RuntimeInfo (org.talend.daikon.runtime.RuntimeInfo)2 SandboxedInstance (org.talend.daikon.sandbox.SandboxedInstance)2 GenericRecord (org.apache.avro.generic.GenericRecord)1 IndexedRecord (org.apache.avro.generic.IndexedRecord)1 FixedFlowInputProperties (org.talend.components.localio.fixedflowinput.FixedFlowInputProperties)1 RowGeneratorProperties (org.talend.components.localio.rowgenerator.RowGeneratorProperties)1