zhuxiaoshang commented on a change in pull request #14530:
URL: https://github.com/apache/flink/pull/14530#discussion_r554588155



##########
File path: 
flink-connectors/flink-connector-kafka/src/test/java/org/apache/flink/streaming/connectors/kafka/table/KafkaOptionsTest.java
##########
@@ -173,6 +178,69 @@ public void testInvalidValueFormatProjection() {
         }
     }
 
+    @Test
+    public void testCompleteAvroConfluentSubject() {
+        final String avro = "avro-confluent";
+        final String debezium = "debezium-avro-confluent";
+
+        final Map<String, String> options = new HashMap<>();
+        options.put("connector", "kafka");
+        options.put("properties.bootstrap.servers", "localhost:9092");
+        options.put("topic", "myTopic");
+        options.put("format", avro);
+
+        options.put("key.format", avro);
+
+        String[] subject1 = getSubject(options, avro, false);
+        assertThat(subject1[0], equalTo("myTopic-value"));
+        assertThat(subject1[1], equalTo("myTopic-key"));
+
+        options.put("format", debezium);
+        options.put("key.format", debezium);
+
+        String[] subject2 = getSubject(options, debezium, false);
+        assertThat(subject2[0], equalTo("myTopic-value"));
+        assertThat(subject2[1], equalTo("myTopic-key"));
+
+        options.remove("format");
+        options.put("value.format", debezium);
+        options.put("value." + debezium + ".schema-registry.subject", 
"valueSubject");
+
+        String[] subject3 = getSubject(options, debezium, true);
+        assertThat(subject3[0], equalTo("valueSubject"));
+        assertThat(subject3[1], equalTo("myTopic-key"));
+
+        options.remove("key.format");
+
+        String[] subject4 = getSubject(options, debezium, true);
+        assertThat(subject4[0], equalTo("valueSubject"));
+        assertThat(subject4[1], equalTo(null));
+    }
+
+    private String[] getSubject(Map<String, String> options, String format, 
boolean isValuePrefix) {

Review comment:
       Is encoder? I have create the sink and encoder,but don't know how to 
validate subject of the encoder,what should i do next?
   ` @Test
       public void testTableSinkWithSchemaRegistrySubject() {
           final Map<String, String> modifiedOptions =
                   getModifiedOptions(
                           getBasicSinkOptions(),
                           options -> {
                               options.put("format", "avro-confluent");
                               options.put(
                                       "avro-confluent.schema-registry.url", 
"http://localhost:8081";);
                           });
           KafkaDynamicSink actualSink = (KafkaDynamicSink) 
createTableSink(SCHEMA, modifiedOptions);
           SerializationSchema<RowData> encoder =
                   actualSink.valueEncodingFormat.createRuntimeEncoder(
                           new SinkRuntimeProviderContext(false), 
SCHEMA_DATA_TYPE);
           assertThat(encoder, 
instanceOf(AvroRowDataSerializationSchema.class));
       }`




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to