You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2021/08/10 13:02:50 UTC

[GitHub] [rocketmq-externals] StyleTang commented on a change in pull request #777: [ISSUE #673]Add unit tests to improve code coverage

StyleTang commented on a change in pull request #777:
URL: https://github.com/apache/rocketmq-externals/pull/777#discussion_r685991036



##########
File path: rocketmq-console/src/test/java/org/apache/rocketmq/console/controller/ProducerControllerTest.java
##########
@@ -42,9 +52,33 @@
     @Spy
     private ProducerServiceImpl producerService;
 
+    @Override protected MockMvc createMockMvc() {

Review comment:
       Code format.

##########
File path: rocketmq-console/pom.xml
##########
@@ -188,6 +188,11 @@
             <artifactId>lombok</artifactId>
             <version>${lombok.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-inline</artifactId>
+            <version>3.3.3</version>

Review comment:
       It is better to put the mockito version into properties and add test scope.
   e.g.
   ```xml
       <properties>
           <org.mockito.version>3.3.3</org.mockito.version>
       </properties>
   
       <dependency>
           <groupId>org.mockito</groupId>
           <artifactId>mockito-inline</artifactId>
           <version>${org.mockito.version}</version>
           <scope>test</scope>
       </dependency>
   ```

##########
File path: rocketmq-console/src/test/java/org/apache/rocketmq/console/config/RMQConfigureTest.java
##########
@@ -0,0 +1,49 @@
+package org.apache.rocketmq.console.config;
+
+import java.io.File;
+import org.apache.rocketmq.common.topic.TopicValidator;
+import org.junit.Assert;
+import org.junit.Test;
+import org.springframework.boot.web.server.ErrorPage;
+import org.springframework.boot.web.server.ErrorPageRegistrar;
+import org.springframework.boot.web.server.ErrorPageRegistry;
+
+public class RMQConfigureTest {
+
+    private RMQConfigure rmqConfigure = new RMQConfigure();
+
+    @Test
+    public void testSet() {
+        rmqConfigure.setAccessKey("rocketmq");
+        rmqConfigure.setSecretKey("12345678");
+        rmqConfigure.setDataPath("/tmp/rocketmq-console/data/test");
+        rmqConfigure.setEnableDashBoardCollect("true");
+        rmqConfigure.setIsVIPChannel("true");
+        rmqConfigure.setUseTLS(true);
+        rmqConfigure.setLoginRequired(true);
+        rmqConfigure.setMsgTrackTopicName(null);
+        rmqConfigure.setNamesrvAddr("127.0.0.1:9876");
+    }
+
+    @Test
+    public void testGet() {
+        testSet();
+        Assert.assertEquals(rmqConfigure.getAccessKey(), "rocketmq");
+        Assert.assertEquals(rmqConfigure.getSecretKey(), "12345678");
+        Assert.assertTrue(rmqConfigure.isACLEnabled());
+        Assert.assertTrue(rmqConfigure.isUseTLS());
+        Assert.assertEquals(rmqConfigure.getConsoleCollectData(), "/tmp/rocketmq-console/data/test" + File.separator + "dashboard");
+        Assert.assertEquals(rmqConfigure.getRocketMqConsoleDataPath(), "/tmp/rocketmq-console/data/test");
+        Assert.assertEquals(rmqConfigure.getIsVIPChannel(), "true");
+        Assert.assertTrue(rmqConfigure.isEnableDashBoardCollect());
+        Assert.assertTrue(rmqConfigure.isLoginRequired());
+        Assert.assertEquals(rmqConfigure.getMsgTrackTopicNameOrDefault(), TopicValidator.RMQ_SYS_TRACE_TOPIC);
+        Assert.assertEquals(rmqConfigure.getNamesrvAddr(), "127.0.0.1:9876");
+        ErrorPageRegistrar registrar = rmqConfigure.errorPageRegistrar();
+        registrar.registerErrorPages(new ErrorPageRegistry() {
+            @Override public void addErrorPages(ErrorPage... errorPages) {

Review comment:
       Code format.
   Should be new line after @Override




-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org