Search in sources :

Example 1 with DataGeneratorSource

use of org.apache.flink.streaming.api.functions.source.datagen.DataGeneratorSource in project flink by apache.

the class DataGenTableSourceFactoryTest method runGenerator.

private List<RowData> runGenerator(ResolvedSchema schema, DescriptorProperties descriptor) throws Exception {
    DynamicTableSource source = createTableSource(schema, descriptor.asMap());
    assertTrue(source instanceof DataGenTableSource);
    DataGenTableSource dataGenTableSource = (DataGenTableSource) source;
    DataGeneratorSource<RowData> gen = dataGenTableSource.createSource();
    // test java serialization.
    gen = InstantiationUtil.clone(gen);
    StreamSource<RowData, DataGeneratorSource<RowData>> src = new StreamSource<>(gen);
    AbstractStreamOperatorTestHarness<RowData> testHarness = new AbstractStreamOperatorTestHarness<>(src, 1, 1, 0);
    testHarness.open();
    TestContext ctx = new TestContext();
    gen.run(ctx);
    return ctx.results;
}
Also used : GenericRowData(org.apache.flink.table.data.GenericRowData) RowData(org.apache.flink.table.data.RowData) DataGeneratorSource(org.apache.flink.streaming.api.functions.source.datagen.DataGeneratorSource) StreamSource(org.apache.flink.streaming.api.operators.StreamSource) DynamicTableSource(org.apache.flink.table.connector.source.DynamicTableSource) DataGenTableSource(org.apache.flink.connector.datagen.table.DataGenTableSource) AbstractStreamOperatorTestHarness(org.apache.flink.streaming.util.AbstractStreamOperatorTestHarness)

Aggregations

DataGenTableSource (org.apache.flink.connector.datagen.table.DataGenTableSource)1 DataGeneratorSource (org.apache.flink.streaming.api.functions.source.datagen.DataGeneratorSource)1 StreamSource (org.apache.flink.streaming.api.operators.StreamSource)1 AbstractStreamOperatorTestHarness (org.apache.flink.streaming.util.AbstractStreamOperatorTestHarness)1 DynamicTableSource (org.apache.flink.table.connector.source.DynamicTableSource)1 GenericRowData (org.apache.flink.table.data.GenericRowData)1 RowData (org.apache.flink.table.data.RowData)1