Search in sources :

Example 6 with EncodingFormatMock

use of org.apache.flink.table.factories.TestFormatFactory.EncodingFormatMock in project flink by apache.

the class FactoryUtilTest method testDiscoveryForSeparateSourceSinkFactory.

@Test
public void testDiscoveryForSeparateSourceSinkFactory() {
    final Map<String, String> options = createAllOptions();
    // the "test" source and sink factory is not in one factory class
    // see TestDynamicTableSinkFactory and TestDynamicTableSourceFactory
    options.put("connector", "test");
    final DynamicTableSource actualSource = createTableSource(SCHEMA, options);
    final DynamicTableSource expectedSource = new DynamicTableSourceMock("MyTarget", null, new DecodingFormatMock(",", false), new DecodingFormatMock("|", true));
    assertThat(actualSource).isEqualTo(expectedSource);
    final DynamicTableSink actualSink = createTableSink(SCHEMA, options);
    final DynamicTableSink expectedSink = new DynamicTableSinkMock("MyTarget", 1000L, new EncodingFormatMock(","), new EncodingFormatMock("|"));
    assertThat(actualSink).isEqualTo(expectedSink);
}
Also used : EncodingFormatMock(org.apache.flink.table.factories.TestFormatFactory.EncodingFormatMock) DecodingFormatMock(org.apache.flink.table.factories.TestFormatFactory.DecodingFormatMock) DynamicTableSink(org.apache.flink.table.connector.sink.DynamicTableSink) DynamicTableSourceMock(org.apache.flink.table.factories.TestDynamicTableFactory.DynamicTableSourceMock) DynamicTableSource(org.apache.flink.table.connector.source.DynamicTableSource) DynamicTableSinkMock(org.apache.flink.table.factories.TestDynamicTableFactory.DynamicTableSinkMock) Test(org.junit.jupiter.api.Test)

Example 7 with EncodingFormatMock

use of org.apache.flink.table.factories.TestFormatFactory.EncodingFormatMock in project flink by apache.

the class FactoryUtilTest method testAlternativeValueFormat.

@Test
public void testAlternativeValueFormat() {
    final Map<String, String> options = createAllOptions();
    options.remove("value.format");
    options.remove("value.test-format.delimiter");
    options.remove("value.test-format.fail-on-missing");
    options.put("format", "test-format");
    options.put("test-format.delimiter", ";");
    options.put("test-format.fail-on-missing", "true");
    final DynamicTableSource actualSource = createTableSource(SCHEMA, options);
    final DynamicTableSource expectedSource = new DynamicTableSourceMock("MyTarget", null, new DecodingFormatMock(",", false), new DecodingFormatMock(";", true));
    assertThat(actualSource).isEqualTo(expectedSource);
    final DynamicTableSink actualSink = createTableSink(SCHEMA, options);
    final DynamicTableSink expectedSink = new DynamicTableSinkMock("MyTarget", 1000L, new EncodingFormatMock(","), new EncodingFormatMock(";"));
    assertThat(actualSink).isEqualTo(expectedSink);
}
Also used : EncodingFormatMock(org.apache.flink.table.factories.TestFormatFactory.EncodingFormatMock) DecodingFormatMock(org.apache.flink.table.factories.TestFormatFactory.DecodingFormatMock) DynamicTableSink(org.apache.flink.table.connector.sink.DynamicTableSink) DynamicTableSourceMock(org.apache.flink.table.factories.TestDynamicTableFactory.DynamicTableSourceMock) DynamicTableSource(org.apache.flink.table.connector.source.DynamicTableSource) DynamicTableSinkMock(org.apache.flink.table.factories.TestDynamicTableFactory.DynamicTableSinkMock) Test(org.junit.jupiter.api.Test)

Example 8 with EncodingFormatMock

use of org.apache.flink.table.factories.TestFormatFactory.EncodingFormatMock in project flink by apache.

the class FactoryUtilTest method testOptionalFormat.

@Test
public void testOptionalFormat() {
    final Map<String, String> options = createAllOptions();
    options.remove("key.format");
    options.remove("key.test-format.delimiter");
    final DynamicTableSource actualSource = createTableSource(SCHEMA, options);
    final DynamicTableSource expectedSource = new DynamicTableSourceMock("MyTarget", null, null, new DecodingFormatMock("|", true));
    assertThat(actualSource).isEqualTo(expectedSource);
    final DynamicTableSink actualSink = createTableSink(SCHEMA, options);
    final DynamicTableSink expectedSink = new DynamicTableSinkMock("MyTarget", 1000L, null, new EncodingFormatMock("|"));
    assertThat(actualSink).isEqualTo(expectedSink);
}
Also used : EncodingFormatMock(org.apache.flink.table.factories.TestFormatFactory.EncodingFormatMock) DecodingFormatMock(org.apache.flink.table.factories.TestFormatFactory.DecodingFormatMock) DynamicTableSink(org.apache.flink.table.connector.sink.DynamicTableSink) DynamicTableSourceMock(org.apache.flink.table.factories.TestDynamicTableFactory.DynamicTableSourceMock) DynamicTableSource(org.apache.flink.table.connector.source.DynamicTableSource) DynamicTableSinkMock(org.apache.flink.table.factories.TestDynamicTableFactory.DynamicTableSinkMock) Test(org.junit.jupiter.api.Test)

Aggregations

DynamicTableSink (org.apache.flink.table.connector.sink.DynamicTableSink)8 EncodingFormatMock (org.apache.flink.table.factories.TestFormatFactory.EncodingFormatMock)8 Test (org.junit.jupiter.api.Test)8 DynamicTableSource (org.apache.flink.table.connector.source.DynamicTableSource)4 DynamicTableSinkMock (org.apache.flink.table.factories.TestDynamicTableFactory.DynamicTableSinkMock)4 DynamicTableSourceMock (org.apache.flink.table.factories.TestDynamicTableFactory.DynamicTableSourceMock)4 DecodingFormatMock (org.apache.flink.table.factories.TestFormatFactory.DecodingFormatMock)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 SerializationSchema (org.apache.flink.api.common.serialization.SerializationSchema)3 AvroRowDataSerializationSchema (org.apache.flink.formats.avro.AvroRowDataSerializationSchema)3 ConfluentRegistryAvroSerializationSchema (org.apache.flink.formats.avro.registry.confluent.ConfluentRegistryAvroSerializationSchema)3 DebeziumAvroSerializationSchema (org.apache.flink.formats.avro.registry.confluent.debezium.DebeziumAvroSerializationSchema)3 SinkRuntimeProviderContext (org.apache.flink.table.runtime.connector.sink.SinkRuntimeProviderContext)3 SinkV2Provider (org.apache.flink.table.connector.sink.SinkV2Provider)2 RowData (org.apache.flink.table.data.RowData)1