ijuma commented on a change in pull request #9785: URL: https://github.com/apache/kafka/pull/9785#discussion_r554586805
########## File path: log4j-appender/src/test/java/org/apache/kafka/log4jappender/KafkaLog4jAppenderTest.java ########## @@ -130,55 +116,51 @@ public void testLog4jAppends() { for (int i = 1; i <= 5; ++i) { logger.error(getMessage(i)); } - - Assert.assertEquals( - 5, (getMockKafkaLog4jAppender()).getHistory().size()); + assertEquals(getMockKafkaLog4jAppender().getHistory().size(), 5); } - @Test(expected = RuntimeException.class) - public void testLog4jAppendsWithSyncSendAndSimulateProducerFailShouldThrowException() { + @Test + public void testSyncSendAndSimulateProducerFailShouldThrowException() { Properties props = getLog4jConfig(true); props.put("log4j.appender.KAFKA.IgnoreExceptions", "false"); PropertyConfigurator.configure(props); MockKafkaLog4jAppender mockKafkaLog4jAppender = getMockKafkaLog4jAppender(); replaceProducerWithMocked(mockKafkaLog4jAppender, false); - logger.error(getMessage(0)); + assertThrows(RuntimeException.class, () -> logger.error(getMessage(0))); } @Test - public void testLog4jAppendsWithSyncSendWithoutIgnoringExceptionsShouldNotThrowException() { + public void testSyncSendWithoutIgnoringExceptionsShouldNotThrowException() { Properties props = getLog4jConfig(true); props.put("log4j.appender.KAFKA.IgnoreExceptions", "false"); PropertyConfigurator.configure(props); MockKafkaLog4jAppender mockKafkaLog4jAppender = getMockKafkaLog4jAppender(); replaceProducerWithMocked(mockKafkaLog4jAppender, true); - logger.error(getMessage(0)); + assertDoesNotThrow(() -> logger.error(getMessage(0))); Review comment: What is the reason for having `assertDoesNotThrow` here and below? The test will fail if an exception is thrown, so seems like unnecessary noise. ---------------------------------------------------------------- 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