From b1620294a4551ebb7bb70291075024c1be43c952 Mon Sep 17 00:00:00 2001 From: "Colin P. Mccabe" Date: Fri, 19 Jan 2018 11:43:49 -0800 Subject: [PATCH] MINOR Fix AsyncProducerTest bug that hits when logging is turned up AsyncProducerTest gets an error about an incorrect mock when the logging level is turned up. Instead of using a mock, just create a real SyncProducerConfig object, since the object is simple to create. --- .../test/scala/unit/kafka/producer/AsyncProducerTest.scala | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/src/test/scala/unit/kafka/producer/AsyncProducerTest.scala b/core/src/test/scala/unit/kafka/producer/AsyncProducerTest.scala index 74f3ad1efea3e..370a1ad12b327 100755 --- a/core/src/test/scala/unit/kafka/producer/AsyncProducerTest.scala +++ b/core/src/test/scala/unit/kafka/producer/AsyncProducerTest.scala @@ -404,8 +404,11 @@ class AsyncProducerTest { Map((TopicAndPartition("topic1", 0), ProducerResponseStatus(Errors.NONE, 0L)))) val mockSyncProducer = EasyMock.createMock(classOf[SyncProducer]) // don't care about config mock - val mockConfig = EasyMock.createNiceMock(classOf[SyncProducerConfig]) - EasyMock.expect(mockSyncProducer.config).andReturn(mockConfig).anyTimes() + val myProps = new Properties() + myProps.put("host", "localhost") + myProps.put("port", "9092") + val myConfig = new SyncProducerConfig(myProps) + EasyMock.expect(mockSyncProducer.config).andReturn(myConfig).anyTimes() EasyMock.expect(mockSyncProducer.send(request1)).andThrow(new RuntimeException) // simulate SocketTimeoutException EasyMock.expect(mockSyncProducer.send(request2)).andReturn(response1) EasyMock.expect(mockSyncProducer.send(request3)).andReturn(response2)