提交 03880d77 编写于 作者: W Willem Jiang

ROCKETMQ-3 Clean up and perfect the unit test with thanks to zander

上级 b5afe91d
...@@ -63,9 +63,8 @@ public class SendMessageTest extends BrokerTestHarness{ ...@@ -63,9 +63,8 @@ public class SendMessageTest extends BrokerTestHarness{
} }
@Test @Test
public void testSendSingle() throws Exception { public void testSendSingle() throws Exception{
Message msg = new Message(topic, "TAG1 TAG2", "100200300", "body".getBytes()); Message msg = new Message(topic, "TAG1 TAG2", "100200300", "body".getBytes());
try {
SendMessageRequestHeader requestHeader = new SendMessageRequestHeader(); SendMessageRequestHeader requestHeader = new SendMessageRequestHeader();
requestHeader.setProducerGroup("abc"); requestHeader.setProducerGroup("abc");
requestHeader.setTopic(msg.getTopic()); requestHeader.setTopic(msg.getTopic());
...@@ -79,9 +78,6 @@ public class SendMessageTest extends BrokerTestHarness{ ...@@ -79,9 +78,6 @@ public class SendMessageTest extends BrokerTestHarness{
SendResult result = client.sendMessage(brokerAddr, BROKER_NAME, msg, requestHeader, 1000 * 5, SendResult result = client.sendMessage(brokerAddr, BROKER_NAME, msg, requestHeader, 1000 * 5,
CommunicationMode.SYNC, new SendMessageContext(), null); CommunicationMode.SYNC, new SendMessageContext(), null);
assertTrue(result.getSendStatus() == SendStatus.SEND_OK); assertEquals(result.getSendStatus(), SendStatus.SEND_OK);
} catch (Exception e) {
e.printStackTrace();
}
} }
} }
...@@ -25,7 +25,7 @@ import com.alibaba.rocketmq.common.MixAll; ...@@ -25,7 +25,7 @@ import com.alibaba.rocketmq.common.MixAll;
import com.alibaba.rocketmq.common.TopicConfig; import com.alibaba.rocketmq.common.TopicConfig;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.*;
/** /**
...@@ -39,7 +39,7 @@ public class TopicConfigManagerTest extends BrokerTestHarness { ...@@ -39,7 +39,7 @@ public class TopicConfigManagerTest extends BrokerTestHarness {
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
String topic = "UNITTEST-" + i; String topic = "UNITTEST-" + i;
TopicConfig topicConfig = topicConfigManager.createTopicInSendMessageMethod(topic, MixAll.DEFAULT_TOPIC, null, 4, 0); TopicConfig topicConfig = topicConfigManager.createTopicInSendMessageMethod(topic, MixAll.DEFAULT_TOPIC, null, 4, 0);
assertTrue(topicConfig != null); assertNotNull(topicConfig);
} }
topicConfigManager.persist(); topicConfigManager.persist();
...@@ -48,15 +48,15 @@ public class TopicConfigManagerTest extends BrokerTestHarness { ...@@ -48,15 +48,15 @@ public class TopicConfigManagerTest extends BrokerTestHarness {
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
String topic = "UNITTEST-" + i; String topic = "UNITTEST-" + i;
TopicConfig topicConfig = topicConfigManager.selectTopicConfig(topic); TopicConfig topicConfig = topicConfigManager.selectTopicConfig(topic);
assertTrue(topicConfig == null); assertNull(topicConfig);
} }
topicConfigManager.load(); topicConfigManager.load();
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
String topic = "UNITTEST-" + i; String topic = "UNITTEST-" + i;
TopicConfig topicConfig = topicConfigManager.selectTopicConfig(topic); TopicConfig topicConfig = topicConfigManager.selectTopicConfig(topic);
assertTrue(topicConfig != null); assertNotNull(topicConfig);
assertTrue(topicConfig.getTopicSysFlag() == 0); assertEquals(topicConfig.getTopicSysFlag(), 0);
assertTrue(topicConfig.getReadQueueNums() == 4); assertEquals(topicConfig.getReadQueueNums(), 4);
} }
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册