You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "divijvaidya (via GitHub)" <gi...@apache.org> on 2023/06/16 14:46:26 UTC

[GitHub] [kafka] divijvaidya commented on a diff in pull request #12976: Improve TestUtils for temporary properties file

divijvaidya commented on code in PR #12976:
URL: https://github.com/apache/kafka/pull/12976#discussion_r1232345504


##########
core/src/test/scala/unit/kafka/utils/TestUtils.scala:
##########
@@ -156,6 +156,21 @@ object TestUtils extends Logging {
    */
   def tempFile(prefix: String, suffix: String): File = JTestUtils.tempFile(prefix, suffix)
 
+  /**
+   * 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)
+
+  def tempPropertiesFile(properties: Properties): File = {
+    return tempPropertiesFile(properties.asScala)
+  }
+
+  def tempPropertiesFile(properties: Map[String, String]): File = {
+    val content = properties.map{case (k, v) => k + "=" + v}.mkString("\n")

Review Comment:
   please use `System.lineSeparator()` instead of `\n`. It's a much safer way to write newline characters that make the code system independent



-- 
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-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org