zigarn commented on code in PR #12175: URL: https://github.com/apache/kafka/pull/12175#discussion_r951140387
########## core/src/test/scala/unit/kafka/tools/ConsoleConsumerTest.scala: ########## @@ -488,6 +488,31 @@ class ConsoleConsumerTest { assertTrue(formatter.keyDeserializer.get.asInstanceOf[MockDeserializer].isKey) } + @Test + def testCustomConfigShouldBePassedToConfigureMethod(): Unit = { + val propsFile = TestUtils.tempFile() + val propsStream = Files.newOutputStream(propsFile.toPath) + propsStream.write("key.deserializer.my-props=abc\n".getBytes()) + propsStream.write("print.key=false".getBytes()) + propsStream.close() + + val args = Array( + "--bootstrap-server", "localhost:9092", + "--topic", "test", + "--property", "print.key=true", + "--property", "key.deserializer=org.apache.kafka.test.MockDeserializer", + "--formatter-config", propsFile.getAbsolutePath + ) + val config = new ConsoleConsumer.ConsumerConfig(args) + assertTrue(config.formatter.isInstanceOf[DefaultMessageFormatter]) + assertTrue(config.formatterArgs.containsKey("key.deserializer.my-props")) Review Comment: From my point of view, checking a key exists and checking it's value is the expected one are 2 different tests. Also, if the key doesn't exists and we remove the first check, the second one may raise an exception in case of missing key which is less explicit. Basically, this test is just a copy of the previous one, so I kept the same checks. -- 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. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org