From 9dc3b5f5fc375eb0e84db5366566b8e891d87ee9 Mon Sep 17 00:00:00 2001 From: vongosling Date: Tue, 12 Jun 2018 14:02:58 +0800 Subject: [PATCH] Bugfix for the unstable test --- .../rocketmq/client/log/ClientLoggerTest.java | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/client/src/test/java/org/apache/rocketmq/client/log/ClientLoggerTest.java b/client/src/test/java/org/apache/rocketmq/client/log/ClientLoggerTest.java index 4888186b..cf66bc6e 100644 --- a/client/src/test/java/org/apache/rocketmq/client/log/ClientLoggerTest.java +++ b/client/src/test/java/org/apache/rocketmq/client/log/ClientLoggerTest.java @@ -17,18 +17,16 @@ package org.apache.rocketmq.client.log; +import java.io.File; +import java.io.IOException; import org.apache.rocketmq.common.MixAll; import org.apache.rocketmq.common.UtilAll; import org.apache.rocketmq.logging.InternalLogger; import org.apache.rocketmq.logging.InternalLoggerFactory; -import org.junit.After; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; -import java.io.File; -import java.io.IOException; - - public class ClientLoggerTest { public static final String CLIENT_LOG_ROOT = "rocketmq.client.logRoot"; @@ -46,13 +44,10 @@ public class ClientLoggerTest { for (int i = 0; i < 10; i++) { logger.info("testClientlog test {}", i); - rocketmqCommon.info("common message {}", i, new RuntimeException()); - rocketmqRemoting.info("remoting message {}", i, new RuntimeException()); - } - try { - Thread.sleep(10); - } catch (InterruptedException ignore) { + rocketmqCommon.info("common message {}", i); + rocketmqRemoting.info("remoting message {}", i); } + String content = MixAll.file2String(LOG_DIR + "/rocketmq_client.log"); Assert.assertTrue(content.contains("testClientlog")); Assert.assertTrue(content.contains("RocketmqClient")); @@ -61,7 +56,7 @@ public class ClientLoggerTest { Assert.assertTrue(content.contains("RocketmqRemoting")); } - @After + @Before public void cleanFiles() { UtilAll.deleteFile(new File(LOG_DIR)); } -- GitLab