Search in sources :

Example 36 with RuntimeInfo

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

the class KafkaDatasetTestIT method testBasic.

@Test
public void testBasic() throws Exception {
    KafkaDatasetProperties props = createDatasetProperties();
    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(0));
}
Also used : SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) KafkaDatasetProperties(org.talend.components.kafka.dataset.KafkaDatasetProperties) 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) Test(org.junit.Test)

Example 37 with RuntimeInfo

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

the class KafkaDatasetProperties method beforeTopic.

public ValidationResult beforeTopic() {
    KafkaDatasetDefinition definition = new KafkaDatasetDefinition();
    RuntimeInfo runtimeInfo = definition.getRuntimeInfo(this);
    try (SandboxedInstance sandboxedInstance = RuntimeUtil.createRuntimeClass(runtimeInfo, getClass().getClassLoader())) {
        IKafkaDatasetRuntime runtime = (IKafkaDatasetRuntime) sandboxedInstance.getInstance();
        runtime.initialize(null, this);
        this.topic.setPossibleValues(new ArrayList(runtime.listTopic()));
        return ValidationResult.OK;
    } catch (Exception e) {
        return new ValidationResult(new ComponentException(e));
    }
}
Also used : SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) ArrayList(java.util.ArrayList) ComponentException(org.talend.components.api.exception.ComponentException) IKafkaDatasetRuntime(org.talend.components.kafka.runtime.IKafkaDatasetRuntime) ValidationResult(org.talend.daikon.properties.ValidationResult) ComponentException(org.talend.components.api.exception.ComponentException)

Example 38 with RuntimeInfo

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

the class JmsDatastoreDefinitionTest method testGetRuntimeInfo.

@Test
public void testGetRuntimeInfo() {
    RuntimeInfo runtimeInfo = datastoreDefinition.getRuntimeInfo(null);
    assertEquals("org.talend.components.jms.runtime_1_1.DatastoreRuntime", runtimeInfo.getRuntimeClassName());
}
Also used : RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) Test(org.junit.Test)

Example 39 with RuntimeInfo

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

the class JmsOutputDefinitionTest method testGetRuntimeInfo.

/**
 * Check {@link JmsOutputDefinition#getRuntimeInfo(ComponentProperties properties, ConnectorTopology connectorTopology)
 * returns RuntimeInfo,
 * which runtime class name is "org.talend.components.jms.runtime_1_1.JmsSource"
 */
@Test
public void testGetRuntimeInfo() {
    RuntimeInfo runtimeInfo = outputDefinition.getRuntimeInfo(ExecutionEngine.BEAM, null, null);
    assertEquals("org.talend.components.jms.runtime_1_1.JmsSource", runtimeInfo.getRuntimeClassName());
}
Also used : RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) Test(org.junit.Test)

Example 40 with RuntimeInfo

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

the class WindowDefinitionTest method testRuntimeInfo.

/**
 * Checks the {@link RuntimeInfo} of the definition.
 */
@Test
@Ignore("This can't work unless the runtime jar is already installed in maven!")
public void testRuntimeInfo() {
    RuntimeInfo runtimeInfo = definition.getRuntimeInfo(null, null, null);
    assertEquals("org.talend.components.processing.runtime.window.WindowRuntime", 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