vinothchandar commented on a change in pull request #8737: URL: https://github.com/apache/kafka/pull/8737#discussion_r432166675
########## File path: core/src/test/scala/unit/kafka/admin/TopicCommandWithAdminClientTest.scala ########## @@ -223,8 +224,20 @@ class TopicCommandWithAdminClientTest extends KafkaServerTestHarness with Loggin createAndWaitTopic(createOpts) // try to re-create the topic - intercept[IllegalArgumentException] { + intercept[TopicExistsException] { + topicService.createTopic(createOpts) + } + } + + @Test + def testCreateWhenAlreadyExistsWithIfNotExists(): Unit = { + val createOpts = new TopicCommandOptions(Array("--topic", testTopicName, "--if-not-exists")) + createAndWaitTopic(createOpts) + + try { topicService.createTopic(createOpts) + } catch { Review comment: I think the distinction is between whether you want the test to error or fail. Here I wanted the tests to fail with a contextual error by calling `fail()`. Also makes the test read more explicitly.. i.e it says we only treat the specific caught exception as the expected failure by calling `fail()`, while any other exception will just error out the test.. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org