zigarn commented on code in PR #12175: URL: https://github.com/apache/kafka/pull/12175#discussion_r951187834
########## 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() Review Comment: What about doing that? ```diff diff --git i/core/src/test/scala/unit/kafka/tools/ConsoleProducerTest.scala w/core/src/test/scala/unit/kafka/tools/ConsoleProducerTest.scala index 8a594f92a3..f589347703 100644 --- i/core/src/test/scala/unit/kafka/tools/ConsoleProducerTest.scala +++ w/core/src/test/scala/unit/kafka/tools/ConsoleProducerTest.scala @@ -17,7 +17,6 @@ package kafka.tools -import java.nio.file.Files import kafka.tools.ConsoleProducer.LineMessageReader import kafka.utils.{Exit, TestUtils} import org.apache.kafka.clients.producer.ProducerConfig @@ -143,12 +142,7 @@ class ConsoleProducerTest { @Test def testParseReaderConfigFile(): Unit = { - val propsFile = TestUtils.tempFile() - val propsStream = Files.newOutputStream(propsFile.toPath) - propsStream.write("parse.key=true\n".getBytes()) - propsStream.write("key.separator=|".getBytes()) - propsStream.close() - + val propsFile = TestUtils.tempFile("parse.key=true\nkey.separator=|") val args = Array( "--bootstrap-server", "localhost:9092", "--topic", "test", diff --git i/core/src/test/scala/unit/kafka/utils/TestUtils.scala w/core/src/test/scala/unit/kafka/utils/TestUtils.scala index 1e0d5981da..43976b5635 100755 --- i/core/src/test/scala/unit/kafka/utils/TestUtils.scala +++ w/core/src/test/scala/unit/kafka/utils/TestUtils.scala @@ -149,6 +149,12 @@ object TestUtils extends Logging { */ def tempFile(): File = JTestUtils.tempFile() + /** + * Create a file with the given contents in the default temporary-file directory, + * using `kafka` as the prefix and `tmp` as the suffix to generate its name. + */ + def tempFile(contents: String): File = JTestUtils.tempFile(contents) + /** * Create a temporary file and return an open file channel for this file */ ``` -- 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