rocketmq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vongosl...@apache.org
Subject [rocketmq] branch develop updated: [ISSUE #353]Optimzation For Unit Test (#356)
Date Thu, 05 Jul 2018 12:01:52 GMT
This is an automated email from the ASF dual-hosted git repository.

vongosling pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git


The following commit(s) were added to refs/heads/develop by this push:
     new 94f3b5a  [ISSUE #353]Optimzation For Unit Test (#356)
94f3b5a is described below

commit 94f3b5a41b1af7054f59343c033d4df622af95ae
Author: what-a-good-jungle <353187194@qq.com>
AuthorDate: Thu Jul 5 20:01:49 2018 +0800

    [ISSUE #353]Optimzation For Unit Test (#356)
---
 .../java/org/apache/rocketmq/filter/ParserTest.java  | 15 +++++++++------
 pom.xml                                              |  4 +++-
 .../apache/rocketmq/store/DefaultMessageStore.java   |  2 +-
 .../org/apache/rocketmq/store/ConsumeQueueTest.java  |  2 --
 .../test/client/rmq/RMQAsyncSendProducer.java        | 20 +++++++++++---------
 .../rocketmq/test/client/rmq/RMQNormalProducer.java  |  6 +++---
 .../test/clientinterface/AbstractMQProducer.java     |  4 ++--
 .../rocketmq/test/clientinterface/MQProducer.java    |  4 ++--
 .../{SendResult.java => ResultWrapper.java}          |  2 +-
 9 files changed, 32 insertions(+), 27 deletions(-)

diff --git a/filter/src/test/java/org/apache/rocketmq/filter/ParserTest.java b/filter/src/test/java/org/apache/rocketmq/filter/ParserTest.java
index 36ef271..115632f 100644
--- a/filter/src/test/java/org/apache/rocketmq/filter/ParserTest.java
+++ b/filter/src/test/java/org/apache/rocketmq/filter/ParserTest.java
@@ -84,14 +84,17 @@ public class ParserTest {
     @Test
     public void testParse_floatOverFlow() {
         try {
-            String str = "1";
-            for (int i = 0; i < 2048; i++) {
-                str += "111111111111111111111111111111111111111111111111111";
+            StringBuffer sb = new StringBuffer(210000);
+            sb.append("1");
+            for (int i = 0; i < 2048; i ++) {
+                sb.append("111111111111111111111111111111111111111111111111111");
             }
-            str += ".";
-            for (int i = 0; i < 2048; i++) {
-                str += "111111111111111111111111111111111111111111111111111";
+            sb.append(".");
+            for (int i = 0; i < 2048; i ++) {
+                sb.append("111111111111111111111111111111111111111111111111111");
             }
+            String str = sb.toString();
+
 
             SelectorParser.parse("a > " + str);
 
diff --git a/pom.xml b/pom.xml
index 6fe4f73..72cd349 100644
--- a/pom.xml
+++ b/pom.xml
@@ -157,7 +157,7 @@
                 </executions>
                 <configuration>
                     <rules>
-                        <banCircularDependencies />
+                        <banCircularDependencies/>
                     </rules>
                     <fail>true</fail>
                 </configuration>
@@ -315,6 +315,7 @@
                 <artifactId>maven-surefire-plugin</artifactId>
                 <version>2.19.1</version>
                 <configuration>
+                    <skipAfterFailureCount>1</skipAfterFailureCount>
                     <forkCount>1</forkCount>
                     <reuseForks>true</reuseForks>
                 </configuration>
@@ -333,6 +334,7 @@
                 <artifactId>maven-failsafe-plugin</artifactId>
                 <version>2.19.1</version>
                 <configuration>
+                    <skipAfterFailureCount>1</skipAfterFailureCount>
                     <excludes>
                         <exclude>**/NormalMsgDelayIT.java</exclude>
                     </excludes>
diff --git a/store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java b/store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java
index 4fc7412..1ade7c2 100644
--- a/store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java
+++ b/store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java
@@ -247,7 +247,7 @@ public class DefaultMessageStore implements MessageStore {
 
             try {
 
-                Thread.sleep(1000 * 3);
+                Thread.sleep(1000);
             } catch (InterruptedException e) {
                 log.error("shutdown Exception, ", e);
             }
diff --git a/store/src/test/java/org/apache/rocketmq/store/ConsumeQueueTest.java b/store/src/test/java/org/apache/rocketmq/store/ConsumeQueueTest.java
index b7d38f8..7e01b85 100644
--- a/store/src/test/java/org/apache/rocketmq/store/ConsumeQueueTest.java
+++ b/store/src/test/java/org/apache/rocketmq/store/ConsumeQueueTest.java
@@ -212,8 +212,6 @@ public class ConsumeQueueTest {
         try {
             try {
                 putMsg(master);
-                // wait build consume queue
-                Thread.sleep(1000);
             } catch (Exception e) {
                 e.printStackTrace();
                 assertThat(Boolean.FALSE).isTrue();
diff --git a/test/src/main/java/org/apache/rocketmq/test/client/rmq/RMQAsyncSendProducer.java
b/test/src/main/java/org/apache/rocketmq/test/client/rmq/RMQAsyncSendProducer.java
index 2f8af68..9907cac 100644
--- a/test/src/main/java/org/apache/rocketmq/test/client/rmq/RMQAsyncSendProducer.java
+++ b/test/src/main/java/org/apache/rocketmq/test/client/rmq/RMQAsyncSendProducer.java
@@ -26,10 +26,11 @@ import org.apache.rocketmq.client.exception.MQClientException;
 import org.apache.rocketmq.client.producer.DefaultMQProducer;
 import org.apache.rocketmq.client.producer.MessageQueueSelector;
 import org.apache.rocketmq.client.producer.SendCallback;
+import org.apache.rocketmq.client.producer.SendResult;
 import org.apache.rocketmq.common.message.Message;
 import org.apache.rocketmq.common.message.MessageQueue;
 import org.apache.rocketmq.test.clientinterface.AbstractMQProducer;
-import org.apache.rocketmq.test.sendresult.SendResult;
+import org.apache.rocketmq.test.sendresult.ResultWrapper;
 import org.apache.rocketmq.test.util.RandomUtil;
 import org.apache.rocketmq.test.util.TestUtil;
 
@@ -39,20 +40,19 @@ public class RMQAsyncSendProducer extends AbstractMQProducer {
     private String nsAddr = null;
     private DefaultMQProducer producer = null;
     private SendCallback sendCallback = null;
-    private List<org.apache.rocketmq.client.producer.SendResult> successSendResult
= Collections
-        .synchronizedList(new ArrayList<org.apache.rocketmq.client.producer.SendResult>());
-    private AtomicInteger exceptionMsgCount = new AtomicInteger(
-        0);
+    private List<SendResult> successSendResult = Collections.synchronizedList(new ArrayList<SendResult>());
+    private AtomicInteger exceptionMsgCount = new AtomicInteger(0);
     private int msgSize = 0;
 
     public RMQAsyncSendProducer(String nsAddr, String topic) {
         super(topic);
         this.nsAddr = nsAddr;
         sendCallback = new SendCallback() {
-            public void onSuccess(org.apache.rocketmq.client.producer.SendResult sendResult)
{
+            @Override
+            public void onSuccess(SendResult sendResult) {
                 successSendResult.add(sendResult);
             }
-
+            @Override
             public void onException(Throwable throwable) {
                 exceptionMsgCount.getAndIncrement();
             }
@@ -66,7 +66,7 @@ public class RMQAsyncSendProducer extends AbstractMQProducer {
         return successSendResult.size();
     }
 
-    public List<org.apache.rocketmq.client.producer.SendResult> getSuccessSendResult()
{
+    public List<SendResult> getSuccessSendResult() {
         return successSendResult;
     }
 
@@ -94,10 +94,12 @@ public class RMQAsyncSendProducer extends AbstractMQProducer {
         }
     }
 
-    public SendResult send(Object msg, Object arg) {
+    @Override
+    public ResultWrapper send(Object msg, Object arg) {
         return null;
     }
 
+    @Override
     public void shutdown() {
         producer.shutdown();
     }
diff --git a/test/src/main/java/org/apache/rocketmq/test/client/rmq/RMQNormalProducer.java
b/test/src/main/java/org/apache/rocketmq/test/client/rmq/RMQNormalProducer.java
index 4294933..6bbec6c 100644
--- a/test/src/main/java/org/apache/rocketmq/test/client/rmq/RMQNormalProducer.java
+++ b/test/src/main/java/org/apache/rocketmq/test/client/rmq/RMQNormalProducer.java
@@ -26,7 +26,7 @@ import org.apache.rocketmq.client.producer.SendStatus;
 import org.apache.rocketmq.common.message.Message;
 import org.apache.rocketmq.common.message.MessageQueue;
 import org.apache.rocketmq.test.clientinterface.AbstractMQProducer;
-import org.apache.rocketmq.test.sendresult.SendResult;
+import org.apache.rocketmq.test.sendresult.ResultWrapper;
 
 public class RMQNormalProducer extends AbstractMQProducer {
     private static Logger logger = Logger.getLogger(RMQNormalProducer.class);
@@ -91,7 +91,7 @@ public class RMQNormalProducer extends AbstractMQProducer {
         }
     }
 
-    public SendResult send(Object msg, Object orderKey) {
+    public ResultWrapper send(Object msg, Object orderKey) {
         org.apache.rocketmq.client.producer.SendResult metaqResult = null;
         Message message = (Message) msg;
         try {
@@ -132,7 +132,7 @@ public class RMQNormalProducer extends AbstractMQProducer {
         }
     }
 
-    public SendResult sendMQ(Message msg, MessageQueue mq) {
+    public ResultWrapper sendMQ(Message msg, MessageQueue mq) {
         org.apache.rocketmq.client.producer.SendResult metaqResult = null;
         try {
             long start = System.currentTimeMillis();
diff --git a/test/src/main/java/org/apache/rocketmq/test/clientinterface/AbstractMQProducer.java
b/test/src/main/java/org/apache/rocketmq/test/clientinterface/AbstractMQProducer.java
index 8201e63..df6abfc 100644
--- a/test/src/main/java/org/apache/rocketmq/test/clientinterface/AbstractMQProducer.java
+++ b/test/src/main/java/org/apache/rocketmq/test/clientinterface/AbstractMQProducer.java
@@ -21,14 +21,14 @@ import java.util.Date;
 import java.util.List;
 import org.apache.rocketmq.common.message.MessageQueue;
 import org.apache.rocketmq.test.client.rmq.RMQNormalProducer;
-import org.apache.rocketmq.test.sendresult.SendResult;
+import org.apache.rocketmq.test.sendresult.ResultWrapper;
 import org.apache.rocketmq.test.util.RandomUtil;
 import org.apache.rocketmq.test.util.TestUtil;
 
 public abstract class AbstractMQProducer extends MQCollector implements MQProducer {
     protected String topic = null;
 
-    protected SendResult sendResult = new SendResult();
+    protected ResultWrapper sendResult = new ResultWrapper();
     protected boolean startSuccess = false;
     protected String producerGroupName = null;
     protected String producerInstanceName = null;
diff --git a/test/src/main/java/org/apache/rocketmq/test/clientinterface/MQProducer.java b/test/src/main/java/org/apache/rocketmq/test/clientinterface/MQProducer.java
index 795457d..e9ed0d3 100644
--- a/test/src/main/java/org/apache/rocketmq/test/clientinterface/MQProducer.java
+++ b/test/src/main/java/org/apache/rocketmq/test/clientinterface/MQProducer.java
@@ -17,10 +17,10 @@
 
 package org.apache.rocketmq.test.clientinterface;
 
-import org.apache.rocketmq.test.sendresult.SendResult;
+import org.apache.rocketmq.test.sendresult.ResultWrapper;
 
 public interface MQProducer {
-    SendResult send(Object msg, Object arg);
+    ResultWrapper send(Object msg, Object arg);
 
     void setDebug();
 
diff --git a/test/src/main/java/org/apache/rocketmq/test/sendresult/SendResult.java b/test/src/main/java/org/apache/rocketmq/test/sendresult/ResultWrapper.java
similarity index 98%
rename from test/src/main/java/org/apache/rocketmq/test/sendresult/SendResult.java
rename to test/src/main/java/org/apache/rocketmq/test/sendresult/ResultWrapper.java
index d53ee7d..9fe3146 100644
--- a/test/src/main/java/org/apache/rocketmq/test/sendresult/SendResult.java
+++ b/test/src/main/java/org/apache/rocketmq/test/sendresult/ResultWrapper.java
@@ -17,7 +17,7 @@
 
 package org.apache.rocketmq.test.sendresult;
 
-public class SendResult {
+public class ResultWrapper {
     private boolean sendResult = false;
     private String msgId = null;
     private Exception sendException = null;


Mime
View raw message