[ 
https://issues.apache.org/jira/browse/ROCKETMQ-3?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15772498#comment-15772498
 ] 

ASF GitHub Bot commented on ROCKETMQ-3:
---------------------------------------

Github user vongosling commented on a diff in the pull request:

    https://github.com/apache/incubator-rocketmq/pull/7#discussion_r93749892
  
    --- Diff: 
rocketmq-broker/src/test/java/com/alibaba/rocketmq/broker/topic/TopicConfigManagerTest.java
 ---
    @@ -20,52 +20,43 @@
      */
     package com.alibaba.rocketmq.broker.topic;
     
    -import com.alibaba.rocketmq.broker.BrokerController;
    -import com.alibaba.rocketmq.common.BrokerConfig;
    +import com.alibaba.rocketmq.broker.BrokerTestHarness;
     import com.alibaba.rocketmq.common.MixAll;
     import com.alibaba.rocketmq.common.TopicConfig;
    -import com.alibaba.rocketmq.remoting.netty.NettyClientConfig;
    -import com.alibaba.rocketmq.remoting.netty.NettyServerConfig;
    -import com.alibaba.rocketmq.store.config.MessageStoreConfig;
     import org.junit.Test;
     
     import static org.junit.Assert.assertTrue;
     
     
     /**
    - * @author shijia.wxr
    + * @author zander
      */
    -public class TopicConfigManagerTest {
    +public class TopicConfigManagerTest extends BrokerTestHarness {
         @Test
    -    public void test_flushTopicConfig() throws Exception {
    -        BrokerController brokerController = new BrokerController(//
    -                new BrokerConfig(), //
    -                new NettyServerConfig(), //
    -                new NettyClientConfig(), //
    -                new MessageStoreConfig());
    -        boolean initResult = brokerController.initialize();
    -        System.out.println("initialize " + initResult);
    -        brokerController.start();
    -
    +    public void testFlushTopicConfig() throws Exception {
             TopicConfigManager topicConfigManager = new 
TopicConfigManager(brokerController);
     
    -        TopicConfig topicConfig =
    -                
topicConfigManager.createTopicInSendMessageMethod("TestTopic_SEND", 
MixAll.DEFAULT_TOPIC,
    -                        null, 4, 0);
    -        assertTrue(topicConfig != null);
    -
    -        System.out.println(topicConfig);
    -
             for (int i = 0; i < 10; i++) {
                 String topic = "UNITTEST-" + i;
    -            topicConfig =
    -                    topicConfigManager
    -                            .createTopicInSendMessageMethod(topic, 
MixAll.DEFAULT_TOPIC, null, 4, 0);
    +            TopicConfig topicConfig = 
topicConfigManager.createTopicInSendMessageMethod(topic, MixAll.DEFAULT_TOPIC, 
null, 4, 0);
                 assertTrue(topicConfig != null);
             }
    -
             topicConfigManager.persist();
     
    -        brokerController.shutdown();
    +        topicConfigManager.getTopicConfigTable().clear();
    +
    +        for (int i = 0; i < 10; i++) {
    +            String topic = "UNITTEST-" + i;
    +            TopicConfig topicConfig = 
topicConfigManager.selectTopicConfig(topic);
    +            assertTrue(topicConfig == null);
    +        }
    +        topicConfigManager.load();
    +        for (int i = 0; i < 10; i++) {
    +            String topic = "UNITTEST-" + i;
    +            TopicConfig topicConfig = 
topicConfigManager.selectTopicConfig(topic);
    +            assertTrue(topicConfig != null);
    +            assertTrue(topicConfig.getTopicSysFlag() == 0);
    --- End diff --
    
    It is highly recommended to use AssertJ framework for more details 
assertion. because Junit hamcrest assert framework is not complete. 


> Clean up the unit test of rocketmq
> ----------------------------------
>
>                 Key: ROCKETMQ-3
>                 URL: https://issues.apache.org/jira/browse/ROCKETMQ-3
>             Project: Apache RocketMQ
>          Issue Type: Task
>            Reporter: Willem Jiang
>
> There are lots of System.out.println and the try...catch exception code in 
> the test of rocketmq-store module. It's better to avoid the usage of 
> System.out.println and just through out the exception to fail the test. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to