Search in sources :

Example 46 with RuntimeInfo

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

the class TypeConverterDefinitionTest method testRuntimeInfo.

/**
 * Checks the {@link RuntimeInfo} of the definition.
 */
@Test
public void testRuntimeInfo() {
    RuntimeInfo runtimeInfo = def.getRuntimeInfo(ExecutionEngine.BEAM, null, ConnectorTopology.INCOMING_AND_OUTGOING);
    Assert.assertThat(runtimeInfo.getRuntimeClassName(), is("org.talend.components.processing.runtime.typeconverter.TypeConverterFunction"));
// The integration module tests things that aren't available in the RuntimeInfo module until after it is
// installed in the local maven repository.
}
Also used : RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) Test(org.junit.Test)

Example 47 with RuntimeInfo

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

the class PubSubDatasetProperties method beforeSubscription.

public ValidationResult beforeSubscription() {
    PubSubDatasetDefinition definition = new PubSubDatasetDefinition();
    RuntimeInfo runtimeInfo = definition.getRuntimeInfo(this);
    try (SandboxedInstance sandboxedInstance = RuntimeUtil.createRuntimeClass(runtimeInfo, getClass().getClassLoader())) {
        IPubSubDatasetRuntime runtime = (IPubSubDatasetRuntime) sandboxedInstance.getInstance();
        runtime.initialize(null, this);
        List<NamedThing> topics = new ArrayList<>();
        for (String topicName : runtime.listSubscriptions()) {
            topics.add(new SimpleNamedThing(topicName, topicName));
        }
        subscription.setPossibleValues(topics);
        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) IPubSubDatasetRuntime(org.talend.components.pubsub.runtime.IPubSubDatasetRuntime) SimpleNamedThing(org.talend.daikon.SimpleNamedThing) ArrayList(java.util.ArrayList) ComponentException(org.talend.components.api.exception.ComponentException) NamedThing(org.talend.daikon.NamedThing) SimpleNamedThing(org.talend.daikon.SimpleNamedThing) ValidationResult(org.talend.daikon.properties.ValidationResult) ComponentException(org.talend.components.api.exception.ComponentException)

Example 48 with RuntimeInfo

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

the class PubSubDatasetDefinitionTest method testRuntimeInfo.

/**
 * Check {@link PubSubDatasetDefinition#getRuntimeInfo(PubSubDatasetProperties)} returns RuntimeInfo,
 * which runtime class name is "org.talend.components.pubsub.runtime.PubSubDatasetRuntime"
 */
@Test
@Ignore("This can't work unless the runtime jar is already installed in maven!")
public void testRuntimeInfo() {
    RuntimeInfo runtimeInfo = datasetDefinition.getRuntimeInfo(null);
    assertEquals("org.talend.components.pubsub.runtime.PubSubDatasetRuntime", runtimeInfo.getRuntimeClassName());
}
Also used : RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 49 with RuntimeInfo

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

the class S3DatasetProperties method afterRegion.

public void afterRegion() {
    refreshLayout(getForm(Form.MAIN));
    S3DatasetDefinition definition = new S3DatasetDefinition();
    RuntimeInfo runtimeInfo = definition.getRuntimeInfo(this);
    try (SandboxedInstance sandboxedInstance = RuntimeUtil.createRuntimeClass(runtimeInfo, getClass().getClassLoader())) {
        IS3DatasetRuntime runtime = (IS3DatasetRuntime) sandboxedInstance.getInstance();
        runtime.initialize(null, this);
        this.bucket.setPossibleValues(new ArrayList<String>(runtime.listBuckets()));
    } catch (Exception e) {
        TalendRuntimeException.build(ComponentsErrorCode.IO_EXCEPTION, e).throwIt();
    }
}
Also used : SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) IS3DatasetRuntime(org.talend.components.simplefileio.s3.runtime.IS3DatasetRuntime) TalendRuntimeException(org.talend.daikon.exception.TalendRuntimeException)

Example 50 with RuntimeInfo

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

the class ElasticsearchDatasetDefinitionTest method testRuntimeInfo.

/**
 * Check {@link ElasticsearchDatasetDefinition#getRuntimeInfo(ElasticsearchDatasetProperties)} returns RuntimeInfo,
 * which runtime class name is "org.talend.components.elasticsearch.runtime_2_4.ElasticsearchDatasetRuntime"
 */
@Test
@Ignore("This can't work unless the runtime jar is already installed in maven!")
public void testRuntimeInfo() {
    RuntimeInfo runtimeInfo = datasetDefinition.getRuntimeInfo(null);
    assertEquals("org.talend.components.elasticsearch.runtime_2_4.ElasticsearchDatasetRuntime", 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