wu-sheng commented on a change in pull request #3640: Provide agent plugin 
netty-socketio
URL: https://github.com/apache/skywalking/pull/3640#discussion_r336788639
 
 

 ##########
 File path: 
apm-sniffer/apm-sdk-plugin/netty-socketio-plugin/src/test/java/org/apache/skywalking/apm/plugin/netty/socketio/NettySocketIOTest.java
 ##########
 @@ -0,0 +1,154 @@
+/*
+ * 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.skywalking.apm.plugin.netty.socketio;
+
+import com.corundumstudio.socketio.SocketIOClient;
+import com.corundumstudio.socketio.handler.ClientHead;
+import com.corundumstudio.socketio.namespace.Namespace;
+import com.corundumstudio.socketio.protocol.Packet;
+import com.corundumstudio.socketio.transport.NamespaceClient;
+import org.apache.skywalking.apm.agent.core.context.trace.TraceSegment;
+import 
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.apache.skywalking.apm.agent.test.tools.AgentServiceRule;
+import org.apache.skywalking.apm.agent.test.tools.SegmentStorage;
+import org.apache.skywalking.apm.agent.test.tools.SegmentStoragePoint;
+import org.apache.skywalking.apm.agent.test.tools.TracingSegmentRunner;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.powermock.modules.junit4.PowerMockRunnerDelegate;
+import org.powermock.reflect.Whitebox;
+
+import java.lang.reflect.Method;
+import java.net.InetSocketAddress;
+import java.util.List;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.powermock.api.mockito.PowerMockito.when;
+
+/**
+ * @author MrPro
+ */
+@RunWith(PowerMockRunner.class)
+@PowerMockRunnerDelegate(TracingSegmentRunner.class)
+public class NettySocketIOTest {
+
+    @SegmentStoragePoint
+    private SegmentStorage segmentStorage;
+
+    @Rule
+    public AgentServiceRule serviceRule = new AgentServiceRule();
+
+    private NettySocketIOConnectionInterceptor connectionInterceptor;
+    private NettySocketIOOnEventInterceptor onEventInterceptor;
+    private NettySocketIORoomInterceptor roomInterceptor;
+    private NettySocketIOConstructorInterceptor constructorInterceptor;
+
+    @Mock
+    private SocketIOClient socketIOClient;
+    @Mock
+    private Packet sendPacket;
+    @Mock
+    private ClientHead clientHead;
+    @Mock
+    private Namespace namespace;
+
+    private Method connectOnConnectMethod;
+    private Method connectOnDisConnectMethod;
+    private Method roomLeaveMethod;
+    private Method roomJoinMethod;
+
+    private NettySocketIOClientInfo socketIOClientInfo = new 
NettySocketIOClientInfo(null, null, "127.0.0.1:9092");
+
+    private EnhancedInstance enhancedInstance = new EnhancedInstance() {
+        @Override
+        public Object getSkyWalkingDynamicField() {
+            return socketIOClientInfo;
+        }
+
+        @Override
+        public void setSkyWalkingDynamicField(Object value) {
+
+        }
+    };
+
+    @Before
+    public void setUp() {
+        InetSocketAddress addr = new InetSocketAddress("127.0.0.1", 9092);
 
 Review comment:
   Binding to a static port in the test is dangerous, right? 
   We should bind for `0` to represent a random port, am I right?
   @kezhenxu94 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to