diff --git a/.travis.yml b/.travis.yml index acf5d489187..2b617a3e853 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,10 @@ jdk: - oraclejdk9 - oraclejdk8 +cache: + directories: + - $HOME/.m2 + install: true script: diff --git a/dubbo-common/src/test/java/org/apache/dubbo/common/utils/UrlUtilsTest.java b/dubbo-common/src/test/java/org/apache/dubbo/common/utils/UrlUtilsTest.java index 7141c96bc0c..3fc14c3a594 100644 --- a/dubbo-common/src/test/java/org/apache/dubbo/common/utils/UrlUtilsTest.java +++ b/dubbo-common/src/test/java/org/apache/dubbo/common/utils/UrlUtilsTest.java @@ -98,9 +98,9 @@ public void testParseFromParameter() { @Test public void testParseUrl2() { - String address = "127.0.0.1"; - String backupAddress1 = "127.0.0.2"; - String backupAddress2 = "127.0.0.3"; + String address = "192.168.0.1"; + String backupAddress1 = "192.168.0.2"; + String backupAddress2 = "192.168.0.3"; Map parameters = new HashMap(); parameters.put("username", "root"); @@ -108,25 +108,25 @@ public void testParseUrl2() { parameters.put("port", "10000"); parameters.put("protocol", "dubbo"); URL url = UrlUtils.parseURL(address + "," + backupAddress1 + "," + backupAddress2, parameters); - assertEquals(localAddress + ":10000", url.getAddress()); + assertEquals("192.168.0.1:10000", url.getAddress()); assertEquals("root", url.getUsername()); assertEquals("alibaba", url.getPassword()); assertEquals(10000, url.getPort()); assertEquals("dubbo", url.getProtocol()); - assertEquals("127.0.0.2" + "," + "127.0.0.3", url.getParameter("backup")); + assertEquals("192.168.0.2" + "," + "192.168.0.3", url.getParameter("backup")); } @Test public void testParseUrls() { - String addresses = "127.0.0.1|127.0.0.2|127.0.0.3"; + String addresses = "192.168.0.1|192.168.0.2|192.168.0.3"; Map parameters = new HashMap(); parameters.put("username", "root"); parameters.put("password", "alibaba"); parameters.put("port", "10000"); parameters.put("protocol", "dubbo"); List urls = UrlUtils.parseURLs(addresses, parameters); - assertEquals(localAddress + ":10000", urls.get(0).getAddress()); - assertEquals("127.0.0.2" + ":10000", urls.get(1).getAddress()); + assertEquals("192.168.0.1" + ":10000", urls.get(0).getAddress()); + assertEquals("192.168.0.2" + ":10000", urls.get(1).getAddress()); } @Test @@ -330,7 +330,7 @@ public void testIsItemMatch() throws Exception { @Test public void testIsServiceKeyMatch() throws Exception { - URL url = URL.valueOf("test://127.0.0.0"); + URL url = URL.valueOf("test://127.0.0.1"); URL pattern = url.addParameter(Constants.GROUP_KEY, "test") .addParameter(Constants.INTERFACE_KEY, "test") .addParameter(Constants.VERSION_KEY, "test"); diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/GenericServiceTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/GenericServiceTest.java index 6e746dbf435..f996f4109e9 100644 --- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/GenericServiceTest.java +++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/GenericServiceTest.java @@ -74,7 +74,7 @@ public void testGenericServiceException() { ReferenceConfig reference = new ReferenceConfig(); reference.setApplication(new ApplicationConfig("generic-consumer")); reference.setInterface(DemoService.class); - reference.setUrl("dubbo://127.0.0.1:29581?generic=true"); + reference.setUrl("dubbo://127.0.0.1:29581?generic=true&timeout=3000"); DemoService demoService = reference.get(); try { // say name @@ -113,7 +113,7 @@ public void testGenericReferenceException() { ReferenceConfig reference = new ReferenceConfig(); reference.setApplication(new ApplicationConfig("generic-consumer")); reference.setInterface(DemoService.class); - reference.setUrl("dubbo://127.0.0.1:29581?scope=remote"); + reference.setUrl("dubbo://127.0.0.1:29581?scope=remote&timeout=3000"); reference.setGeneric(true); GenericService genericService = reference.get(); try { @@ -147,7 +147,7 @@ public void testGenericSerializationJava() throws Exception { ReferenceConfig reference = new ReferenceConfig(); reference.setApplication(new ApplicationConfig("generic-consumer")); reference.setInterface(DemoService.class); - reference.setUrl("dubbo://127.0.0.1:29581?scope=remote"); + reference.setUrl("dubbo://127.0.0.1:29581?scope=remote&timeout=3000"); reference.setGeneric(Constants.GENERIC_SERIALIZATION_NATIVE_JAVA); GenericService genericService = reference.get(); try { @@ -216,7 +216,7 @@ public void testGenericInvokeWithBeanSerialization() throws Exception { reference = new ReferenceConfig(); reference.setApplication(new ApplicationConfig("bean-consumer")); reference.setInterface(DemoService.class); - reference.setUrl("dubbo://127.0.0.1:29581?scope=remote"); + reference.setUrl("dubbo://127.0.0.1:29581?scope=remote&timeout=3000"); reference.setGeneric(Constants.GENERIC_SERIALIZATION_BEAN); GenericService genericService = reference.get(); User user = new User(); @@ -270,7 +270,7 @@ public void testGenericImplementationWithBeanSerialization() throws Exception { ref = new ReferenceConfig(); ref.setApplication(new ApplicationConfig("bean-consumer")); ref.setInterface(DemoService.class); - ref.setUrl("dubbo://127.0.0.1:29581?scope=remote&generic=bean"); + ref.setUrl("dubbo://127.0.0.1:29581?scope=remote&generic=bean&timeout=3000"); DemoService demoService = ref.get(); User user = new User(); user.setName("zhangsan"); diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/cache/CacheTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/cache/CacheTest.java index 0cdcabdd714..d69eeb86771 100644 --- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/cache/CacheTest.java +++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/cache/CacheTest.java @@ -46,7 +46,7 @@ private void testCache(String type) throws Exception { ServiceConfig service = new ServiceConfig(); service.setApplication(new ApplicationConfig("cache-provider")); service.setRegistry(new RegistryConfig("N/A")); - service.setProtocol(new ProtocolConfig("dubbo", 29582)); + service.setProtocol(new ProtocolConfig("injvm")); service.setInterface(CacheService.class.getName()); service.setRef(new CacheServiceImpl()); service.export(); @@ -54,7 +54,7 @@ private void testCache(String type) throws Exception { ReferenceConfig reference = new ReferenceConfig(); reference.setApplication(new ApplicationConfig("cache-consumer")); reference.setInterface(CacheService.class); - reference.setUrl("dubbo://127.0.0.1:29582?scope=remote&cache=true"); + reference.setUrl("injvm://127.0.0.1?scope=remote&cache=true"); MethodConfig method = new MethodConfig(); method.setName("findCache"); diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/ConfigTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/ConfigTest.java index 5698277bdd8..d9ac2f2f544 100644 --- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/ConfigTest.java +++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/ConfigTest.java @@ -96,7 +96,7 @@ public void testServiceClass() { ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/service-class.xml"); ctx.start(); try { - DemoService demoService = refer("dubbo://127.0.0.1:20887"); + DemoService demoService = refer("dubbo://127.0.0.1:30887"); String hello = demoService.sayName("hello"); assertEquals("welcome:hello", hello); } finally { diff --git a/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/support/AbstractRegistryTest.java b/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/support/AbstractRegistryTest.java index b1debab2859..16ffd8579d9 100644 --- a/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/support/AbstractRegistryTest.java +++ b/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/support/AbstractRegistryTest.java @@ -47,9 +47,9 @@ public class AbstractRegistryTest { @Before public void init() { - URL url = URL.valueOf("dubbo://" + NetUtils.getLocalAddress().getHostName() + ":2233"); - testUrl = URL.valueOf("http://1.2.3.4:9090/registry?check=false&file=N/A&interface=com.test"); - mockUrl = new URL("dubbo", "127.0.0.0", 2200); + URL url = URL.valueOf("dubbo://192.168.0.2:2233"); + testUrl = URL.valueOf("http://192.168.0.3:9090/registry?check=false&file=N/A&interface=com.test"); + mockUrl = new URL("dubbo", "192.168.0.1", 2200); parametersConsumer.put("application", "demo-consumer"); parametersConsumer.put("category", "consumer"); @@ -115,7 +115,7 @@ public void testRegisterIfURLNULL() throws Exception { @Test public void testUnregister() throws Exception { //test one unregister - URL url = new URL("dubbo", "127.0.0.0", 2200); + URL url = new URL("dubbo", "192.168.0.1", 2200); abstractRegistry.getRegistered().add(url); abstractRegistry.unregister(url); Assert.assertThat(false, Matchers.equalTo(abstractRegistry.getRegistered().contains(url))); @@ -145,7 +145,7 @@ public void testSubscribeAndUnsubscribe() throws Exception { //test subscribe final AtomicReference notified = new AtomicReference(false); NotifyListener listener = urls -> notified.set(Boolean.TRUE); - URL url = new URL("dubbo", "127.0.0.0", 2200); + URL url = new URL("dubbo", "192.168.0.1", 2200); abstractRegistry.subscribe(url, listener); Set subscribeListeners = abstractRegistry.getSubscribed().get(url); Assert.assertThat(true, Matchers.equalTo(subscribeListeners.contains(listener))); @@ -159,7 +159,7 @@ public void testSubscribeAndUnsubscribe() throws Exception { public void testSubscribeIfUrlNull() throws Exception { final AtomicReference notified = new AtomicReference(false); NotifyListener listener = urls -> notified.set(Boolean.TRUE); - URL url = new URL("dubbo", "127.0.0.0", 2200); + URL url = new URL("dubbo", "192.168.0.1", 2200); abstractRegistry.subscribe(null, listener); Assert.fail("subscribe url == null"); } @@ -168,7 +168,7 @@ public void testSubscribeIfUrlNull() throws Exception { public void testSubscribeIfListenerNull() throws Exception { final AtomicReference notified = new AtomicReference(false); NotifyListener listener = urls -> notified.set(Boolean.TRUE); - URL url = new URL("dubbo", "127.0.0.0", 2200); + URL url = new URL("dubbo", "192.168.0.1", 2200); abstractRegistry.subscribe(url, null); Assert.fail("listener url == null"); } @@ -184,7 +184,7 @@ public void testUnsubscribeIfUrlNull() throws Exception { @Test(expected = IllegalArgumentException.class) public void testUnsubscribeIfNotifyNull() throws Exception { final AtomicReference notified = new AtomicReference(false); - URL url = new URL("dubbo", "127.0.0.0", 2200); + URL url = new URL("dubbo", "192.168.0.1", 2200); abstractRegistry.unsubscribe(url, null); Assert.fail("unsubscribe listener == null"); } @@ -293,13 +293,13 @@ public void testRecover2() throws Exception { public void testNotify() throws Exception { final AtomicReference notified = new AtomicReference(false); NotifyListener listner1 = urls -> notified.set(Boolean.TRUE); - URL url1 = new URL("dubbo", "127.0.0.0", 2200, parametersConsumer); + URL url1 = new URL("dubbo", "192.168.0.1", 2200, parametersConsumer); abstractRegistry.subscribe(url1, listner1); NotifyListener listner2 = urls -> notified.set(Boolean.TRUE); - URL url2 = new URL("dubbo", "127.0.0.1", 2201, parametersConsumer); + URL url2 = new URL("dubbo", "192.168.0.2", 2201, parametersConsumer); abstractRegistry.subscribe(url2, listner2); NotifyListener listner3 = urls -> notified.set(Boolean.TRUE); - URL url3 = new URL("dubbo", "127.0.0.2", 2202, parametersConsumer); + URL url3 = new URL("dubbo", "192.168.0.3", 2202, parametersConsumer); abstractRegistry.subscribe(url3, listner3); List urls = new ArrayList<>(); urls.add(url1); @@ -319,13 +319,13 @@ public void testNotify() throws Exception { public void testNotifyList() throws Exception { final AtomicReference notified = new AtomicReference(false); NotifyListener listner1 = urls -> notified.set(Boolean.TRUE); - URL url1 = new URL("dubbo", "127.0.0.0", 2200, parametersConsumer); + URL url1 = new URL("dubbo", "192.168.0.1", 2200, parametersConsumer); abstractRegistry.subscribe(url1, listner1); NotifyListener listner2 = urls -> notified.set(Boolean.TRUE); - URL url2 = new URL("dubbo", "127.0.0.1", 2201, parametersConsumer); + URL url2 = new URL("dubbo", "192.168.0.2", 2201, parametersConsumer); abstractRegistry.subscribe(url2, listner2); NotifyListener listner3 = urls -> notified.set(Boolean.TRUE); - URL url3 = new URL("dubbo", "127.0.0.2", 2202, parametersConsumer); + URL url3 = new URL("dubbo", "192.168.0.3", 2202, parametersConsumer); abstractRegistry.subscribe(url3, listner3); List urls = new ArrayList<>(); urls.add(url1); @@ -342,13 +342,13 @@ public void testNotifyList() throws Exception { public void testNotifyIfURLNull() throws Exception { final AtomicReference notified = new AtomicReference(false); NotifyListener listner1 = urls -> notified.set(Boolean.TRUE); - URL url1 = new URL("dubbo", "127.0.0.0", 2200, parametersConsumer); + URL url1 = new URL("dubbo", "192.168.0.1", 2200, parametersConsumer); abstractRegistry.subscribe(url1, listner1); NotifyListener listner2 = urls -> notified.set(Boolean.TRUE); - URL url2 = new URL("dubbo", "127.0.0.1", 2201, parametersConsumer); + URL url2 = new URL("dubbo", "192.168.0.2", 2201, parametersConsumer); abstractRegistry.subscribe(url2, listner2); NotifyListener listner3 = urls -> notified.set(Boolean.TRUE); - URL url3 = new URL("dubbo", "127.0.0.2", 2202, parametersConsumer); + URL url3 = new URL("dubbo", "192.168.0.3", 2202, parametersConsumer); abstractRegistry.subscribe(url3, listner3); List urls = new ArrayList<>(); urls.add(url1); @@ -362,13 +362,13 @@ public void testNotifyIfURLNull() throws Exception { public void testNotifyIfNotifyNull() { final AtomicReference notified = new AtomicReference(false); NotifyListener listner1 = urls -> notified.set(Boolean.TRUE); - URL url1 = new URL("dubbo", "127.0.0.0", 2200, parametersConsumer); + URL url1 = new URL("dubbo", "192.168.0.1", 2200, parametersConsumer); abstractRegistry.subscribe(url1, listner1); NotifyListener listner2 = urls -> notified.set(Boolean.TRUE); - URL url2 = new URL("dubbo", "127.0.0.1", 2201, parametersConsumer); + URL url2 = new URL("dubbo", "192.168.0.2", 2201, parametersConsumer); abstractRegistry.subscribe(url2, listner2); NotifyListener listner3 = urls -> notified.set(Boolean.TRUE); - URL url3 = new URL("dubbo", "127.0.0.2", 2202, parametersConsumer); + URL url3 = new URL("dubbo", "192.168.0.3", 2202, parametersConsumer); abstractRegistry.subscribe(url3, listner3); List urls = new ArrayList<>(); urls.add(url1); @@ -507,9 +507,9 @@ public void allTest() throws Exception { private List getList() { List list = new ArrayList<>(); - URL url1 = new URL("dubbo", "127.0.0.0", 1000); - URL url2 = new URL("dubbo", "127.0.0.1", 1001); - URL url3 = new URL("dubbo", "127.0.0.2", 1002); + URL url1 = new URL("dubbo", "192.168.0.1", 1000); + URL url2 = new URL("dubbo", "192.168.0.2", 1001); + URL url3 = new URL("dubbo", "192.168.0.3", 1002); list.add(url1); list.add(url2); list.add(url3); diff --git a/dubbo-remoting/dubbo-remoting-netty/src/test/java/org/apache/dubbo/remoting/transport/netty/ClientReconnectTest.java b/dubbo-remoting/dubbo-remoting-netty/src/test/java/org/apache/dubbo/remoting/transport/netty/ClientReconnectTest.java index b29b20c70f5..1444f9bb6f3 100644 --- a/dubbo-remoting/dubbo-remoting-netty/src/test/java/org/apache/dubbo/remoting/transport/netty/ClientReconnectTest.java +++ b/dubbo-remoting/dubbo-remoting-netty/src/test/java/org/apache/dubbo/remoting/transport/netty/ClientReconnectTest.java @@ -80,7 +80,7 @@ public void testReconnect() throws RemotingException, InterruptedException { public void testReconnectWarnLog() throws RemotingException, InterruptedException { int port = NetUtils.getAvailablePort(); DubboAppender.doStart(); - String url = "exchange://127.0.0.2:" + port + "/client.reconnect.test?check=false&client=netty3&" + String url = "exchange://127.0.0.1:" + port + "/client.reconnect.test?check=false&client=netty3&" + Constants.RECONNECT_KEY + "=" + 1; //1ms reconnect, ensure that there is enough frequency to reconnect try { Exchangers.connect(url); diff --git a/dubbo-remoting/dubbo-remoting-netty/src/test/java/org/apache/dubbo/remoting/transport/netty/NettyClientToServerTest.java b/dubbo-remoting/dubbo-remoting-netty/src/test/java/org/apache/dubbo/remoting/transport/netty/NettyClientToServerTest.java index 56a98822769..a2cff1dcc2b 100644 --- a/dubbo-remoting/dubbo-remoting-netty/src/test/java/org/apache/dubbo/remoting/transport/netty/NettyClientToServerTest.java +++ b/dubbo-remoting/dubbo-remoting-netty/src/test/java/org/apache/dubbo/remoting/transport/netty/NettyClientToServerTest.java @@ -33,7 +33,7 @@ protected ExchangeServer newServer(int port, Replier receiver) throws Remotin } protected ExchangeChannel newClient(int port) throws RemotingException { - return Exchangers.connect(URL.valueOf("exchange://localhost:" + port + "?client=netty3")); + return Exchangers.connect(URL.valueOf("exchange://localhost:" + port + "?client=netty3&timeout=3000")); } } \ No newline at end of file diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/telnet/PortTelnetHandlerTest.java b/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/telnet/PortTelnetHandlerTest.java index 611008e49ed..ff6ec433c30 100644 --- a/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/telnet/PortTelnetHandlerTest.java +++ b/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/telnet/PortTelnetHandlerTest.java @@ -27,7 +27,9 @@ import org.apache.dubbo.rpc.protocol.dubbo.support.ProtocolUtils; import org.junit.After; +import org.junit.AfterClass; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; import static org.junit.Assert.assertEquals; @@ -41,11 +43,11 @@ public class PortTelnetHandlerTest { private static TelnetHandler port = new PortTelnetHandler(); - private Invoker mockInvoker; + private static Invoker mockInvoker; @SuppressWarnings("unchecked") - @Before - public void before() { + @BeforeClass + public static void before() { mockInvoker = mock(Invoker.class); given(mockInvoker.getInterface()).willReturn(DemoService.class); given(mockInvoker.getUrl()).willReturn(URL.valueOf("dubbo://127.0.0.1:20887/demo")); @@ -53,8 +55,8 @@ public void before() { DubboProtocol.getDubboProtocol().export(mockInvoker); } - @After - public void after() { + @AfterClass + public static void after() { ProtocolUtils.closeAll(); } diff --git a/dubbo-rpc/dubbo-rpc-webservice/src/test/java/org/apache/dubbo/rpc/protocol/webservice/WebserviceProtocolTest.java b/dubbo-rpc/dubbo-rpc-webservice/src/test/java/org/apache/dubbo/rpc/protocol/webservice/WebserviceProtocolTest.java index e668bcbd630..576302642c8 100644 --- a/dubbo-rpc/dubbo-rpc-webservice/src/test/java/org/apache/dubbo/rpc/protocol/webservice/WebserviceProtocolTest.java +++ b/dubbo-rpc/dubbo-rpc-webservice/src/test/java/org/apache/dubbo/rpc/protocol/webservice/WebserviceProtocolTest.java @@ -37,7 +37,7 @@ public class WebserviceProtocolTest { public void testDemoProtocol() throws Exception { DemoService service = new DemoServiceImpl(); protocol.export(proxy.getInvoker(service, DemoService.class, URL.valueOf("webservice://127.0.0.1:9019/" + DemoService.class.getName() + "?codec=exchange"))); - service = proxy.getProxy(protocol.refer(DemoService.class, URL.valueOf("webservice://127.0.0.1:9019/" + DemoService.class.getName() + "?codec=exchange"))); + service = proxy.getProxy(protocol.refer(DemoService.class, URL.valueOf("webservice://127.0.0.1:9019/" + DemoService.class.getName() + "?codec=exchange&timeout=3000"))); assertEquals(service.getSize(new String[]{"", "", ""}), 3); } @@ -45,7 +45,7 @@ public void testDemoProtocol() throws Exception { public void testWebserviceProtocol() throws Exception { DemoService service = new DemoServiceImpl(); protocol.export(proxy.getInvoker(service, DemoService.class, URL.valueOf("webservice://127.0.0.1:9019/" + DemoService.class.getName()))); - service = proxy.getProxy(protocol.refer(DemoService.class, URL.valueOf("webservice://127.0.0.1:9019/" + DemoService.class.getName()))); + service = proxy.getProxy(protocol.refer(DemoService.class, URL.valueOf("webservice://127.0.0.1:9019/" + DemoService.class.getName() + "?timeout=3000"))); assertEquals(service.create(1,"kk").getName(), "kk"); assertEquals(service.getSize(null), -1); assertEquals(service.getSize(new String[]{"", "", ""}), 3);