Skip to content

Commit

Permalink
MINOR: Move ConsoleProducerTest to the unit test directory
Browse files Browse the repository at this point in the history
Included a couple of clean-ups: removed unused variable and the instantiated `KafkaProducer` is now closed.

Author: Ismael Juma <[email protected]>

Reviewers: Guozhang Wang <[email protected]>, Sriharsha Chintalapani <[email protected]>

Closes apache#1470 from ijuma/move-console-producer-test-to-unit-folder
  • Loading branch information
ijuma authored and Sriharsha Chintalapani committed Jun 6, 2016
1 parent b60af34 commit 2c7fae0
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@

package kafka.tools

import kafka.producer
import kafka.tools.ConsoleProducer.LineMessageReader
import kafka.producer.ProducerConfig
import ConsoleProducer.LineMessageReader
import org.apache.kafka.clients.producer.KafkaProducer
import org.junit.Assert
import org.junit.Test

import org.junit.{Assert, Test}

class ConsoleProducerTest {

Expand All @@ -47,20 +45,21 @@ class ConsoleProducerTest {
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))
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 producer.ProducerConfig(ConsoleProducer.getOldProducerProps(config))
new ProducerConfig(ConsoleProducer.getOldProducerProps(config))
}

@Test
def testInvalidConfigs() {
try {
val config = new ConsoleProducer.ProducerConfig(invalidArgs)
new ConsoleProducer.ProducerConfig(invalidArgs)
Assert.fail("Should have thrown an UnrecognizedOptionException")
} catch {
case e: joptsimple.OptionException => // expected exception
Expand Down

0 comments on commit 2c7fae0

Please sign in to comment.