chia7712 commented on a change in pull request #9785:
URL: https://github.com/apache/kafka/pull/9785#discussion_r554589317



##########
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:
       I considered it is a kind of highlight. However, it is unnecessary in 
this test case as it is the final line. @g1geordie WDYT? Should we file a PR to 
remove this 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


Reply via email to