From f8565a8120f54ce9a4d8abd29c900b4b3a0dab98 Mon Sep 17 00:00:00 2001 From: OrDTesters <44483852+OrDTesters@users.noreply.github.com> Date: Thu, 6 Dec 2018 19:58:07 -0600 Subject: [PATCH] Close all ports after tests finish (#2906) --- .../dubbo/rpc/protocol/dubbo/DubboInvokerAvilableTest.java | 6 ++++++ .../dubbo/rpc/protocol/dubbo/DubboLazyConnectTest.java | 6 ++++++ .../dubbo/rpc/protocol/dubbo/ExplicitCallbackTest.java | 1 + .../apache/dubbo/rpc/protocol/dubbo/MultiThreadTest.java | 7 +++++++ .../org/apache/dubbo/rpc/protocol/dubbo/RpcFilterTest.java | 7 +++++++ 5 files changed, 27 insertions(+) diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/DubboInvokerAvilableTest.java b/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/DubboInvokerAvilableTest.java index ced3d067751..14ab1242f6b 100644 --- a/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/DubboInvokerAvilableTest.java +++ b/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/DubboInvokerAvilableTest.java @@ -26,6 +26,7 @@ import org.apache.dubbo.rpc.Exporter; import org.apache.dubbo.rpc.ProxyFactory; import org.apache.dubbo.rpc.protocol.dubbo.support.ProtocolUtils; +import org.junit.AfterClass; import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; @@ -51,6 +52,11 @@ public static void setUpBeforeClass() throws Exception { public void setUp() throws Exception { } + @AfterClass + public static void tearDownAfterClass() { + ProtocolUtils.closeAll(); + } + @Test public void test_Normal_available() { URL url = URL.valueOf("dubbo://127.0.0.1:20883/org.apache.dubbo.rpc.protocol.dubbo.IDemoService"); diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/DubboLazyConnectTest.java b/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/DubboLazyConnectTest.java index 4efad6f9af2..31a4421e76f 100644 --- a/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/DubboLazyConnectTest.java +++ b/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/DubboLazyConnectTest.java @@ -22,6 +22,7 @@ import org.apache.dubbo.common.utils.NetUtils; import org.apache.dubbo.rpc.RpcException; import org.apache.dubbo.rpc.protocol.dubbo.support.ProtocolUtils; +import org.junit.AfterClass; import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; @@ -40,6 +41,11 @@ public static void setUpBeforeClass() throws Exception { public void setUp() throws Exception { } + @AfterClass + public static void tearDownAfterClass() { + ProtocolUtils.closeAll(); + } + @Test(expected = RpcException.class) public void testSticky1() { URL url = URL.valueOf("dubbo://127.0.0.1:9090/org.apache.dubbo.rpc.protocol.dubbo.IDemoService"); diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/ExplicitCallbackTest.java b/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/ExplicitCallbackTest.java index 3c8aecdd39f..e7a2b2a8837 100644 --- a/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/ExplicitCallbackTest.java +++ b/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/ExplicitCallbackTest.java @@ -49,6 +49,7 @@ public class ExplicitCallbackTest { @After public void tearDown() { destroyService(); + ProtocolUtils.closeAll(); } public void exportService() { diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/MultiThreadTest.java b/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/MultiThreadTest.java index ce43473025b..04c3645824a 100644 --- a/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/MultiThreadTest.java +++ b/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/MultiThreadTest.java @@ -23,6 +23,8 @@ import org.apache.dubbo.rpc.ProxyFactory; import org.apache.dubbo.rpc.protocol.dubbo.support.DemoService; import org.apache.dubbo.rpc.protocol.dubbo.support.DemoServiceImpl; +import org.apache.dubbo.rpc.protocol.dubbo.support.ProtocolUtils; +import org.junit.After; import org.junit.Assert; import org.junit.Test; @@ -36,6 +38,11 @@ public class MultiThreadTest { private Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension(); private ProxyFactory proxy = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension(); + @After + public void after() { + ProtocolUtils.closeAll(); + } + @Test public void testDubboMultiThreadInvoke() throws Exception { Exporter rpcExporter = protocol.export(proxy.getInvoker(new DemoServiceImpl(), DemoService.class, URL.valueOf("dubbo://127.0.0.1:20259/TestService"))); diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/RpcFilterTest.java b/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/RpcFilterTest.java index f9cca922c11..43297a9d6ba 100644 --- a/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/RpcFilterTest.java +++ b/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/RpcFilterTest.java @@ -22,8 +22,10 @@ import org.apache.dubbo.rpc.ProxyFactory; import org.apache.dubbo.rpc.protocol.dubbo.support.DemoService; import org.apache.dubbo.rpc.protocol.dubbo.support.DemoServiceImpl; +import org.apache.dubbo.rpc.protocol.dubbo.support.ProtocolUtils; import org.apache.dubbo.rpc.service.EchoService; +import org.junit.After; import org.junit.Assert; import org.junit.Test; @@ -31,6 +33,11 @@ public class RpcFilterTest { private Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension(); private ProxyFactory proxy = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension(); + @After + public void after() { + ProtocolUtils.closeAll(); + } + @Test public void testRpcFilter() throws Exception { DemoService service = new DemoServiceImpl();