Skip to content

Commit

Permalink
Close all ports after tests finish (apache#2906)
Browse files Browse the repository at this point in the history
  • Loading branch information
OrDTesters authored and khanimteyaz committed Dec 17, 2018
1 parent 4704218 commit f8565a8
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class ExplicitCallbackTest {
@After
public void tearDown() {
destroyService();
ProtocolUtils.closeAll();
}

public void exportService() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,22 @@
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;

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();
Expand Down

0 comments on commit f8565a8

Please sign in to comment.