kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From srihar...@apache.org
Subject kafka git commit: MINOR: Move `ConsoleProducerTest` to the unit test directory
Date Mon, 06 Jun 2016 02:34:59 GMT
Repository: kafka
Updated Branches:
  refs/heads/trunk b60af34d4 -> 2c7fae0a4


MINOR: Move `ConsoleProducerTest` to the unit test directory

Included a couple of clean-ups: removed unused variable and the instantiated `KafkaProducer`
is now closed.

Author: Ismael Juma <ismael@juma.me.uk>

Reviewers: Guozhang Wang <wangguoz@gmail.com>, Sriharsha Chintalapani <harsha@hortonworks.com>

Closes #1470 from ijuma/move-console-producer-test-to-unit-folder


Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/2c7fae0a
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/2c7fae0a
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/2c7fae0a

Branch: refs/heads/trunk
Commit: 2c7fae0a4a2b59133e53eb02a533cf8ffd0f864c
Parents: b60af34
Author: Ismael Juma <ismael@juma.me.uk>
Authored: Sun Jun 5 19:34:54 2016 -0700
Committer: Sriharsha Chintalapani <harsha@hortonworks.com>
Committed: Sun Jun 5 19:34:54 2016 -0700

----------------------------------------------------------------------
 .../scala/kafka/tools/ConsoleProducerTest.scala | 79 --------------------
 .../unit/kafka/tools/ConsoleProducerTest.scala  | 78 +++++++++++++++++++
 2 files changed, 78 insertions(+), 79 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/2c7fae0a/core/src/test/scala/kafka/tools/ConsoleProducerTest.scala
----------------------------------------------------------------------
diff --git a/core/src/test/scala/kafka/tools/ConsoleProducerTest.scala b/core/src/test/scala/kafka/tools/ConsoleProducerTest.scala
deleted file mode 100644
index 4ddc7fe..0000000
--- a/core/src/test/scala/kafka/tools/ConsoleProducerTest.scala
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package kafka.tools
-
-import kafka.producer
-import kafka.tools.ConsoleProducer.LineMessageReader
-import org.apache.kafka.clients.producer.KafkaProducer
-import org.junit.Assert
-import org.junit.Test
-
-
-class ConsoleProducerTest {
-
-  val validArgs: Array[String] = Array(
-    "--broker-list",
-    "localhost:1001,localhost:1002",
-    "--topic",
-    "t3",
-    "--property",
-    "parse.key=true",
-    "--property",
-    "key.separator=#"
-  )
-
-  val invalidArgs: Array[String] = Array(
-    "--t", // not a valid argument
-    "t3"
-  )
-
-  @Test
-  def testValidConfigsNewProducer() {
-    val config = new ConsoleProducer.ProducerConfig(validArgs)
-    // New ProducerConfig constructor is package private, so we can't call it directly
-    // Creating new Producer to validate instead
-    new KafkaProducer[Array[Byte],Array[Byte]](ConsoleProducer.getNewProducerProps(config))
-  }
-
-  @Test
-  @deprecated("This test has been deprecated and it will be removed in a future release.",
"0.10.0.0")
-  def testValidConfigsOldProducer() {
-    val config = new ConsoleProducer.ProducerConfig(validArgs)
-    new producer.ProducerConfig(ConsoleProducer.getOldProducerProps(config))
-  }
-
-  @Test
-  def testInvalidConfigs() {
-    try {
-      val config = new ConsoleProducer.ProducerConfig(invalidArgs)
-      Assert.fail("Should have thrown an UnrecognizedOptionException")
-    } catch {
-      case e: joptsimple.OptionException => // expected exception
-    }
-  }
-
-  @Test
-  def testParseKeyProp(): Unit = {
-    val config = new ConsoleProducer.ProducerConfig(validArgs)
-    val reader = Class.forName(config.readerClass).newInstance().asInstanceOf[LineMessageReader];
-    reader.init(System.in,ConsoleProducer.getReaderProps(config))
-    assert(reader.keySeparator == "#")
-    assert(reader.parseKey == true)
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/kafka/blob/2c7fae0a/core/src/test/scala/unit/kafka/tools/ConsoleProducerTest.scala
----------------------------------------------------------------------
diff --git a/core/src/test/scala/unit/kafka/tools/ConsoleProducerTest.scala b/core/src/test/scala/unit/kafka/tools/ConsoleProducerTest.scala
new file mode 100644
index 0000000..37d334b
--- /dev/null
+++ b/core/src/test/scala/unit/kafka/tools/ConsoleProducerTest.scala
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package kafka.tools
+
+import kafka.producer.ProducerConfig
+import ConsoleProducer.LineMessageReader
+import org.apache.kafka.clients.producer.KafkaProducer
+import org.junit.{Assert, Test}
+
+class ConsoleProducerTest {
+
+  val validArgs: Array[String] = Array(
+    "--broker-list",
+    "localhost:1001,localhost:1002",
+    "--topic",
+    "t3",
+    "--property",
+    "parse.key=true",
+    "--property",
+    "key.separator=#"
+  )
+
+  val invalidArgs: Array[String] = Array(
+    "--t", // not a valid argument
+    "t3"
+  )
+
+  @Test
+  def testValidConfigsNewProducer() {
+    val config = new ConsoleProducer.ProducerConfig(validArgs)
+    // New ProducerConfig constructor is package private, so we can't call it directly
+    // Creating new Producer to validate instead
+    val producer = new KafkaProducer(ConsoleProducer.getNewProducerProps(config))
+    producer.close()
+  }
+
+  @Test
+  @deprecated("This test has been deprecated and it will be removed in a future release.",
"0.10.0.0")
+  def testValidConfigsOldProducer() {
+    val config = new ConsoleProducer.ProducerConfig(validArgs)
+    new ProducerConfig(ConsoleProducer.getOldProducerProps(config))
+  }
+
+  @Test
+  def testInvalidConfigs() {
+    try {
+      new ConsoleProducer.ProducerConfig(invalidArgs)
+      Assert.fail("Should have thrown an UnrecognizedOptionException")
+    } catch {
+      case e: joptsimple.OptionException => // expected exception
+    }
+  }
+
+  @Test
+  def testParseKeyProp(): Unit = {
+    val config = new ConsoleProducer.ProducerConfig(validArgs)
+    val reader = Class.forName(config.readerClass).newInstance().asInstanceOf[LineMessageReader];
+    reader.init(System.in,ConsoleProducer.getReaderProps(config))
+    assert(reader.keySeparator == "#")
+    assert(reader.parseKey == true)
+  }
+
+}


Mime
View raw message