DongyuanPan commented on code in PR #120:
URL: https://github.com/apache/rocketmq-mqtt/pull/120#discussion_r926201418


##########
mqtt-cs/src/test/java/org/apache/rocketmq/mqtt/cs/test/channel/TestDefaultChannelManager.java:
##########
@@ -79,62 +70,66 @@ public void After() {
     }
 
     @Test
-    public void testAddChannel() {
-        ChannelInfo.setClientId(channel, clientId);
-        ChannelInfo.setChannelLifeCycle(channel, 1000L);
-        defaultChannelManager.addChannel(channel);
-
-        // waiting the execution of the 'doPing' TimerTask
-        try {
-            Thread.sleep(2000);
-        } catch (InterruptedException ignored) {}
-
-        // verify 'doPing' and 'closeConnect'
-        verify(sessionLoop).unloadSession(Mockito.eq(clientId), anyString());
-        verify(retryDriver).unloadSession(Mockito.any());
-    }
-
-    @Test
-    public void testKeepLive() throws InterruptedException {
-        ChannelInfo.setClientId(channel, clientId);
-        defaultChannelManager.addChannel(channel);
-        ChannelInfo.setKeepLive(channel, 1);
-        Thread.sleep(1000);
-        Assert.assertFalse(0 == defaultChannelManager.totalConn());
-        Thread.sleep(4000);
-        Assert.assertTrue(0 == defaultChannelManager.totalConn());
-    }
-
-    @Test
-    public void testCloseConnectNullClientId() {
-        defaultChannelManager.closeConnect(channel, ChannelCloseFrom.CLIENT, 
"ForTest");
-        verify(sessionLoop).unloadSession(Mockito.isNull(), anyString());
-    }
-
-    @Test
-    public void testCloseConnect() {
-        ChannelInfo.setClientId(channel, clientId);
-        defaultChannelManager.closeConnect(channel, ChannelCloseFrom.SERVER, 
"ForTest");
-        verify(sessionLoop).unloadSession(Mockito.eq(clientId), anyString());
-        verify(retryDriver).unloadSession(Mockito.any());
-    }
-
-    @Test
-    public void testCloseConnectNoFrom() throws IllegalAccessException {
-        defaultChannelManager.closeConnect(channelId, "ForTest");
-        Object channelMap = 
FieldUtils.readDeclaredField(defaultChannelManager, "channelMap", true);
-        Assert.assertEquals(0, ((Map<String, Channel>) channelMap).size());
+    public void trivialTest() {
     }
 
-    @Test
-    public void testGetChannelById() {
-        Assert.assertNull(defaultChannelManager.getChannelById(channelId));
-    }
-
-    @Test
-    public void testTotalConn() {
-        Assert.assertEquals(0, defaultChannelManager.totalConn());
-        defaultChannelManager.addChannel(channel);
-        Assert.assertEquals(1, defaultChannelManager.totalConn());
-    }
+//    @Test

Review Comment:
   Why disable this code



##########
meta/src/test/java/org/apache/rocketmq/mqtt/meta/util/KVTest.java:
##########
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.rocketmq.mqtt.meta.util;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.junit.MockitoJUnitRunner;
+
+
+@RunWith(MockitoJUnitRunner.class)
+public class KVTest {
+
+
+    @Test
+    public void kvTest(){
+
+    }
+}

Review Comment:
   This file is useless, delete it



##########
meta/src/main/java/org/apache/rocketmq/mqtt/meta/util/IpUtil.java:
##########
@@ -78,6 +78,23 @@ private static String getLocalAddress() throws Exception {
         return normalizeHostAddress(localHost);
     }
 
+    public static String getLocalPort() throws Exception {

Review Comment:
   Do you want to get the port this machine is listening on? This can be 
obtained directly in the configuration file



##########
.gitignore:
##########
@@ -1,3 +1,5 @@
 .idea
 *.iml
 target/
+/mqtt-example/src/main/java/org/apache/rocketmq/mqtt/example/MqttConsumer.java

Review Comment:
   This needs to be cleaned up. 
   
/mqtt-example/src/main/java/org/apache/rocketmq/mqtt/example/MqttConsumer.java
   
/mqtt-example/src/main/java/org/apache/rocketmq/mqtt/example/MqttProducer.java



##########
.gitignore:
##########
@@ -1,3 +1,5 @@
 .idea
 *.iml
 target/
+/mqtt-example/src/main/java/org/apache/rocketmq/mqtt/example/MqttConsumer.java
+/mqtt-example/src/main/java/org/apache/rocketmq/mqtt/example/MqttProducer.java

Review Comment:
   don't add this code to .gitignore



##########
mqtt-cs/src/main/java/org/apache/rocketmq/mqtt/cs/starter/MqttServer.java:
##########
@@ -76,55 +76,55 @@ public void init() throws Exception {
     private void start() {
         int port = connectConf.getMqttPort();
         serverBootstrap
-            .group(new 
NioEventLoopGroup(connectConf.getNettySelectThreadNum()), new 
NioEventLoopGroup(connectConf.getNettyWorkerThreadNum()))
-            .channel(NioServerSocketChannel.class)
-            .option(ChannelOption.SO_BACKLOG, 8 * 1024)
-            .childOption(ChannelOption.ALLOCATOR, 
PooledByteBufAllocator.DEFAULT)
-            .childOption(ChannelOption.WRITE_BUFFER_WATER_MARK,new 
WriteBufferWaterMark(connectConf.getLowWater(), connectConf.getHighWater()))
-            .childOption(ChannelOption.TCP_NODELAY, true)
-            .localAddress(new InetSocketAddress(port))
-            .childHandler(new ChannelInitializer<SocketChannel>() {
-                @Override
-                public void initChannel(SocketChannel ch) throws Exception {
-                    ChannelPipeline pipeline = ch.pipeline();
-                    pipeline.addLast("connectHandler", connectHandler);
-                    pipeline.addLast("decoder", new 
MqttDecoder(connectConf.getMaxPacketSizeInByte()));
-                    pipeline.addLast("encoder", MqttEncoder.INSTANCE);
-                    pipeline.addLast("dispatcher", mqttPacketDispatcher);
-                }
-            });
+                .group(new 
NioEventLoopGroup(connectConf.getNettySelectThreadNum()), new 
NioEventLoopGroup(connectConf.getNettyWorkerThreadNum()))
+                .channel(NioServerSocketChannel.class)
+                .option(ChannelOption.SO_BACKLOG, 8 * 1024)
+                .childOption(ChannelOption.ALLOCATOR, 
PooledByteBufAllocator.DEFAULT)
+                .childOption(ChannelOption.WRITE_BUFFER_WATER_MARK,new 
WriteBufferWaterMark(connectConf.getLowWater(), connectConf.getHighWater()))
+                .childOption(ChannelOption.TCP_NODELAY, true)
+                .localAddress(new InetSocketAddress(port))
+                .childHandler(new ChannelInitializer<SocketChannel>() {
+                    @Override
+                    public void initChannel(SocketChannel ch) throws Exception 
{
+                        ChannelPipeline pipeline = ch.pipeline();
+                        pipeline.addLast("connectHandler", connectHandler);
+                        pipeline.addLast("decoder", new 
MqttDecoder(connectConf.getMaxPacketSizeInByte()));
+                        pipeline.addLast("encoder", MqttEncoder.INSTANCE);
+                        pipeline.addLast("dispatcher", mqttPacketDispatcher);
+                    }
+                });
         serverBootstrap.bind();
         logger.warn("start mqtt server , port:{}", port);
     }
 
     private void startWs() {
         int port = connectConf.getMqttWsPort();
         wsServerBootstrap
-            .group(new 
NioEventLoopGroup(connectConf.getNettySelectThreadNum()), new 
NioEventLoopGroup(connectConf.getNettyWorkerThreadNum()))
-            .channel(NioServerSocketChannel.class)
-            .option(ChannelOption.SO_BACKLOG, 8 * 1024)
-            .option(ChannelOption.SO_KEEPALIVE, true)
-            .childOption(ChannelOption.ALLOCATOR, 
PooledByteBufAllocator.DEFAULT)
-            .childOption(ChannelOption.WRITE_BUFFER_WATER_MARK,new 
WriteBufferWaterMark(connectConf.getLowWater(), connectConf.getHighWater()))
-            .childOption(ChannelOption.TCP_NODELAY, true)
-            .localAddress(new InetSocketAddress(port))
-            .childHandler(new ChannelInitializer<SocketChannel>() {
-                @Override
-                public void initChannel(SocketChannel ch) throws Exception {
-                    ChannelPipeline pipeline = ch.pipeline();
-                    pipeline.addLast("connectHandler", connectHandler);
-                    pipeline.addLast("http-codec", new HttpServerCodec(1024, 
32 * 1024, connectConf.getMaxPacketSizeInByte() * 2, true));
-                    pipeline.addLast("aggregator", new 
HttpObjectAggregator(connectConf.getMaxPacketSizeInByte() * 2));
-                    pipeline.addLast("http-chunked", new 
ChunkedWriteHandler());
-                    pipeline.addLast("websocket-handler", 
webSocketServerHandler);
-                    pipeline.addLast("websocket-encoder", new 
WebSocketEncoder());
-                    pipeline.addLast("decoder", new 
MqttDecoder(connectConf.getMaxPacketSizeInByte()));
-                    pipeline.addLast("encoder", MqttEncoder.INSTANCE);
-                    pipeline.addLast("dispatcher", mqttPacketDispatcher);
-                }
-            });
+                .group(new 
NioEventLoopGroup(connectConf.getNettySelectThreadNum()), new 
NioEventLoopGroup(connectConf.getNettyWorkerThreadNum()))
+                .channel(NioServerSocketChannel.class)
+                .option(ChannelOption.SO_BACKLOG, 8 * 1024)
+                .option(ChannelOption.SO_KEEPALIVE, true)
+                .childOption(ChannelOption.ALLOCATOR, 
PooledByteBufAllocator.DEFAULT)
+                .childOption(ChannelOption.WRITE_BUFFER_WATER_MARK,new 
WriteBufferWaterMark(connectConf.getLowWater(), connectConf.getHighWater()))
+                .childOption(ChannelOption.TCP_NODELAY, true)
+                .localAddress(new InetSocketAddress(port))
+                .childHandler(new ChannelInitializer<SocketChannel>() {
+                    @Override
+                    public void initChannel(SocketChannel ch) throws Exception 
{
+                        ChannelPipeline pipeline = ch.pipeline();
+                        pipeline.addLast("connectHandler", connectHandler);
+                        pipeline.addLast("http-codec", new 
HttpServerCodec(1024, 32 * 1024, connectConf.getMaxPacketSizeInByte() * 2, 
true));
+                        pipeline.addLast("aggregator", new 
HttpObjectAggregator(connectConf.getMaxPacketSizeInByte() * 2));
+                        pipeline.addLast("http-chunked", new 
ChunkedWriteHandler());
+                        pipeline.addLast("websocket-handler", 
webSocketServerHandler);
+                        pipeline.addLast("websocket-encoder", new 
WebSocketEncoder());
+                        pipeline.addLast("decoder", new 
MqttDecoder(connectConf.getMaxPacketSizeInByte()));
+                        pipeline.addLast("encoder", MqttEncoder.INSTANCE);
+                        pipeline.addLast("dispatcher", mqttPacketDispatcher);
+                    }
+                });

Review Comment:
   don‘t format this file, it conforms to the code style



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to