Search in sources :

Example 1 with KafkaDatasetProperties

use of org.talend.components.kafka.dataset.KafkaDatasetProperties in project components by Talend.

the class KafkaTestConstants method createDataset.

public static KafkaDatasetProperties createDataset(KafkaDatastoreProperties datastore) {
    KafkaDatasetProperties dataset = new KafkaDatasetProperties("dataset");
    dataset.init();
    dataset.setDatastoreProperties(datastore);
    return dataset;
}
Also used : KafkaDatasetProperties(org.talend.components.kafka.dataset.KafkaDatasetProperties)

Example 2 with KafkaDatasetProperties

use of org.talend.components.kafka.dataset.KafkaDatasetProperties 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 3 with KafkaDatasetProperties

use of org.talend.components.kafka.dataset.KafkaDatasetProperties in project components by Talend.

the class KafkaDatasetOtherDelimTestIT method listTopicForProperties.

@Test
public void listTopicForProperties() throws Exception {
    KafkaDatasetProperties datasetProperties = createDataset(createDatastore());
    datasetProperties.beforeTopic();
    List<String> possibleTopics = (List<String>) datasetProperties.topic.getPossibleValues();
    assertThat(possibleTopics, hasItems(TOPIC_IN, TOPIC_OUT));
}
Also used : KafkaDatasetProperties(org.talend.components.kafka.dataset.KafkaDatasetProperties) Test(org.junit.Test)

Example 4 with KafkaDatasetProperties

use of org.talend.components.kafka.dataset.KafkaDatasetProperties in project components by Talend.

the class KafkaCsvBeamRuntimeTestIT method init.

@Before
public void init() {
    datastoreProperties = new KafkaDatastoreProperties("datastore");
    datastoreProperties.init();
    datastoreProperties.brokers.setValue(BOOTSTRAP_HOST);
    inputDatasetProperties = new KafkaDatasetProperties("inputDataset");
    inputDatasetProperties.init();
    inputDatasetProperties.setDatastoreProperties(datastoreProperties);
    inputDatasetProperties.topic.setValue(TOPIC_IN);
    inputDatasetProperties.valueFormat.setValue(KafkaDatasetProperties.ValueFormat.CSV);
    // no schema defined
    outputDatasetProperties = new KafkaDatasetProperties("outputDataset");
    outputDatasetProperties.init();
    outputDatasetProperties.setDatastoreProperties(datastoreProperties);
    outputDatasetProperties.topic.setValue(TOPIC_OUT);
    outputDatasetProperties.valueFormat.setValue(KafkaDatasetProperties.ValueFormat.CSV);
// no schema defined
}
Also used : KafkaDatastoreProperties(org.talend.components.kafka.datastore.KafkaDatastoreProperties) KafkaDatasetProperties(org.talend.components.kafka.dataset.KafkaDatasetProperties) Before(org.junit.Before)

Example 5 with KafkaDatasetProperties

use of org.talend.components.kafka.dataset.KafkaDatasetProperties in project components by Talend.

the class KafkaDatasetTestIT method listTopicForProperties.

@Test
public void listTopicForProperties() throws Exception {
    KafkaDatasetProperties datasetProperties = createDataset(createDatastore());
    datasetProperties.beforeTopic();
    List<String> possibleTopics = (List<String>) datasetProperties.topic.getPossibleValues();
    assertThat(possibleTopics, hasItems(TOPIC_IN, TOPIC_OUT));
}
Also used : KafkaDatasetProperties(org.talend.components.kafka.dataset.KafkaDatasetProperties) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Aggregations

KafkaDatasetProperties (org.talend.components.kafka.dataset.KafkaDatasetProperties)9 Test (org.junit.Test)3 KafkaDatastoreProperties (org.talend.components.kafka.datastore.KafkaDatastoreProperties)3 ArrayList (java.util.ArrayList)2 Before (org.junit.Before)2 List (java.util.List)1 Schema (org.apache.avro.Schema)1 IndexedRecord (org.apache.avro.generic.IndexedRecord)1 DatasetRuntime (org.talend.components.common.dataset.runtime.DatasetRuntime)1 RuntimeInfo (org.talend.daikon.runtime.RuntimeInfo)1 SandboxedInstance (org.talend.daikon.sandbox.SandboxedInstance)1