Skip to content

Commit 2881738

Browse files
authored
add cache for travis, fix ut for stable (#2501)
1 parent a0c1bef commit 2881738

File tree

9 files changed

+32
-33
lines changed

9 files changed

+32
-33
lines changed

.travis.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ jdk:
88

99
cache:
1010
directories:
11-
- '$HOME/.m2/repository'
11+
- $HOME/.m2
1212

13-
install:
14-
- ./mvnw clean install -DskipTests=true -Dcheckstyle.skip=false -Drat.skip=false -Dmaven.javadoc.skip=true
13+
install: true
1514

1615
script:
17-
- travis_wait 30 ./mvnw test
16+
- travis_wait 30 ./mvnw clean install -DskipTests=false -Dcheckstyle.skip=false -Drat.skip=false -Dmaven.javadoc.skip=true
1817

1918
after_success:
20-
- bash <(curl -s https://codecov.io/bash)
19+
- bash <(curl -s https://codecov.io/bash)

dubbo-common/src/test/java/com/alibaba/dubbo/common/utils/UrlUtilsTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,35 +90,35 @@ public void testParseFromParameter() {
9090

9191
@Test
9292
public void testParseUrl2() {
93-
String address = "127.0.0.1";
94-
String backupAddress1 = "127.0.0.2";
95-
String backupAddress2 = "127.0.0.3";
93+
String address = "192.168.0.1";
94+
String backupAddress1 = "192.168.0.2";
95+
String backupAddress2 = "192.168.0.3";
9696

9797
Map<String, String> parameters = new HashMap<String, String>();
9898
parameters.put("username", "root");
9999
parameters.put("password", "alibaba");
100100
parameters.put("port", "10000");
101101
parameters.put("protocol", "dubbo");
102102
URL url = UrlUtils.parseURL(address + "," + backupAddress1 + "," + backupAddress2, parameters);
103-
assertEquals(localAddress + ":10000", url.getAddress());
103+
assertEquals("192.168.0.1:10000", url.getAddress());
104104
assertEquals("root", url.getUsername());
105105
assertEquals("alibaba", url.getPassword());
106106
assertEquals(10000, url.getPort());
107107
assertEquals("dubbo", url.getProtocol());
108-
assertEquals("127.0.0.2" + "," + "127.0.0.3", url.getParameter("backup"));
108+
assertEquals("192.168.0.2" + "," + "192.168.0.3", url.getParameter("backup"));
109109
}
110110

111111
@Test
112112
public void testParseUrls() {
113-
String addresses = "127.0.0.1|127.0.0.2|127.0.0.3";
113+
String addresses = "192.168.0.1|192.168.0.2|192.168.0.3";
114114
Map<String, String> parameters = new HashMap<String, String>();
115115
parameters.put("username", "root");
116116
parameters.put("password", "alibaba");
117117
parameters.put("port", "10000");
118118
parameters.put("protocol", "dubbo");
119119
List<URL> urls = UrlUtils.parseURLs(addresses, parameters);
120-
assertEquals(localAddress + ":10000", urls.get(0).getAddress());
121-
assertEquals("127.0.0.2" + ":10000", urls.get(1).getAddress());
120+
assertEquals("192.168.0.1" + ":10000", urls.get(0).getAddress());
121+
assertEquals("192.168.0.2" + ":10000", urls.get(1).getAddress());
122122
}
123123

124124
@Test
@@ -322,7 +322,7 @@ public void testIsItemMatch() throws Exception {
322322

323323
@Test
324324
public void testIsServiceKeyMatch() throws Exception {
325-
URL url = URL.valueOf("test://127.0.0.0");
325+
URL url = URL.valueOf("test://127.0.0.1");
326326
URL pattern = url.addParameter(Constants.GROUP_KEY, "test")
327327
.addParameter(Constants.INTERFACE_KEY, "test")
328328
.addParameter(Constants.VERSION_KEY, "test");

dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/GenericServiceTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public void testGenericServiceException() {
7474
ReferenceConfig<DemoService> reference = new ReferenceConfig<DemoService>();
7575
reference.setApplication(new ApplicationConfig("generic-consumer"));
7676
reference.setInterface(DemoService.class);
77-
reference.setUrl("dubbo://127.0.0.1:29581?generic=true");
77+
reference.setUrl("dubbo://127.0.0.1:29581?generic=true&timeout=3000");
7878
DemoService demoService = reference.get();
7979
try {
8080
// say name
@@ -113,7 +113,7 @@ public void testGenericReferenceException() {
113113
ReferenceConfig<GenericService> reference = new ReferenceConfig<GenericService>();
114114
reference.setApplication(new ApplicationConfig("generic-consumer"));
115115
reference.setInterface(DemoService.class);
116-
reference.setUrl("dubbo://127.0.0.1:29581?scope=remote");
116+
reference.setUrl("dubbo://127.0.0.1:29581?scope=remote&timeout=3000");
117117
reference.setGeneric(true);
118118
GenericService genericService = reference.get();
119119
try {
@@ -147,7 +147,7 @@ public void testGenericSerializationJava() throws Exception {
147147
ReferenceConfig<GenericService> reference = new ReferenceConfig<GenericService>();
148148
reference.setApplication(new ApplicationConfig("generic-consumer"));
149149
reference.setInterface(DemoService.class);
150-
reference.setUrl("dubbo://127.0.0.1:29581?scope=remote");
150+
reference.setUrl("dubbo://127.0.0.1:29581?scope=remote&timeout=3000");
151151
reference.setGeneric(Constants.GENERIC_SERIALIZATION_NATIVE_JAVA);
152152
GenericService genericService = reference.get();
153153
try {
@@ -216,7 +216,7 @@ public void testGenericInvokeWithBeanSerialization() throws Exception {
216216
reference = new ReferenceConfig<GenericService>();
217217
reference.setApplication(new ApplicationConfig("bean-consumer"));
218218
reference.setInterface(DemoService.class);
219-
reference.setUrl("dubbo://127.0.0.1:29581?scope=remote");
219+
reference.setUrl("dubbo://127.0.0.1:29581?scope=remote&timeout=3000");
220220
reference.setGeneric(Constants.GENERIC_SERIALIZATION_BEAN);
221221
GenericService genericService = reference.get();
222222
User user = new User();
@@ -270,7 +270,7 @@ public void testGenericImplementationWithBeanSerialization() throws Exception {
270270
ref = new ReferenceConfig<DemoService>();
271271
ref.setApplication(new ApplicationConfig("bean-consumer"));
272272
ref.setInterface(DemoService.class);
273-
ref.setUrl("dubbo://127.0.0.1:29581?scope=remote&generic=bean");
273+
ref.setUrl("dubbo://127.0.0.1:29581?scope=remote&generic=bean&timeout=3000");
274274
DemoService demoService = ref.get();
275275
User user = new User();
276276
user.setName("zhangsan");

dubbo-config/dubbo-config-api/src/test/java/com/alibaba/dubbo/config/cache/CacheTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ private void testCache(String type) throws Exception {
4646
ServiceConfig<CacheService> service = new ServiceConfig<CacheService>();
4747
service.setApplication(new ApplicationConfig("cache-provider"));
4848
service.setRegistry(new RegistryConfig("N/A"));
49-
service.setProtocol(new ProtocolConfig("dubbo", 29582));
49+
service.setProtocol(new ProtocolConfig("injvm"));
5050
service.setInterface(CacheService.class.getName());
5151
service.setRef(new CacheServiceImpl());
5252
service.export();
5353
try {
5454
ReferenceConfig<CacheService> reference = new ReferenceConfig<CacheService>();
5555
reference.setApplication(new ApplicationConfig("cache-consumer"));
5656
reference.setInterface(CacheService.class);
57-
reference.setUrl("dubbo://127.0.0.1:29582?scope=remote&cache=true");
57+
reference.setUrl("injvm://127.0.0.1?scope=remote&cache=true");
5858

5959
MethodConfig method = new MethodConfig();
6060
method.setName("findCache");

dubbo-config/dubbo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/ConfigTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public void testServiceClass() {
9696
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/service-class.xml");
9797
ctx.start();
9898
try {
99-
DemoService demoService = refer("dubbo://127.0.0.1:20887");
99+
DemoService demoService = refer("dubbo://127.0.0.1:30887");
100100
String hello = demoService.sayName("hello");
101101
assertEquals("welcome:hello", hello);
102102
} finally {

dubbo-remoting/dubbo-remoting-netty/src/test/java/com/alibaba/dubbo/remoting/transport/netty/NettyClientToServerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected ExchangeServer newServer(int port, Replier<?> receiver) throws Remotin
3333
}
3434

3535
protected ExchangeChannel newClient(int port) throws RemotingException {
36-
return Exchangers.connect(URL.valueOf("exchange://localhost:" + port + "?client=netty"));
36+
return Exchangers.connect(URL.valueOf("exchange://localhost:" + port + "?client=netty&timeout=3000"));
3737
}
3838

3939
}

dubbo-remoting/dubbo-remoting-netty4/src/test/java/com/alibaba/dubbo/remoting/transport/netty4/ClientReconnectTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void testReconnect() throws RemotingException, InterruptedException {
7272

7373

7474
public Client startClient(int port, int reconnectPeriod) throws RemotingException {
75-
final String url = "exchange://127.0.0.1:" + port + "/client.reconnect.test?client=netty4&check=false&" + Constants.RECONNECT_KEY + "=" + reconnectPeriod;
75+
final String url = "exchange://127.0.0.1:" + port + "/client.reconnect.test?timeout=3000&client=netty4&check=false&" + Constants.RECONNECT_KEY + "=" + reconnectPeriod;
7676
return Exchangers.connect(url);
7777
}
7878

dubbo-rpc/dubbo-rpc-dubbo/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/PortTelnetHandlerTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
import com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService;
2727
import com.alibaba.dubbo.rpc.protocol.dubbo.support.ProtocolUtils;
2828

29-
import org.junit.After;
30-
import org.junit.Before;
29+
import org.junit.AfterClass;
30+
import org.junit.BeforeClass;
3131
import org.junit.Test;
3232

3333
import static org.junit.Assert.assertEquals;
@@ -41,20 +41,20 @@
4141
public class PortTelnetHandlerTest {
4242

4343
private static TelnetHandler port = new PortTelnetHandler();
44-
private Invoker<DemoService> mockInvoker;
44+
private static Invoker<DemoService> mockInvoker;
4545

4646
@SuppressWarnings("unchecked")
47-
@Before
48-
public void before() {
47+
@BeforeClass
48+
public static void before() {
4949
mockInvoker = mock(Invoker.class);
5050
given(mockInvoker.getInterface()).willReturn(DemoService.class);
5151
given(mockInvoker.getUrl()).willReturn(URL.valueOf("dubbo://127.0.0.1:20887/demo"));
5252

5353
DubboProtocol.getDubboProtocol().export(mockInvoker);
5454
}
5555

56-
@After
57-
public void after() {
56+
@AfterClass
57+
public static void after() {
5858
ProtocolUtils.closeAll();
5959
}
6060

dubbo-rpc/dubbo-rpc-webservice/src/test/java/com/alibaba/dubbo/rpc/protocol/webservice/WebserviceProtocolTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ public class WebserviceProtocolTest {
3737
public void testDemoProtocol() throws Exception {
3838
DemoService service = new DemoServiceImpl();
3939
protocol.export(proxy.getInvoker(service, DemoService.class, URL.valueOf("webservice://127.0.0.1:9019/" + DemoService.class.getName() + "?codec=exchange")));
40-
service = proxy.getProxy(protocol.refer(DemoService.class, URL.valueOf("webservice://127.0.0.1:9019/" + DemoService.class.getName() + "?codec=exchange")));
40+
service = proxy.getProxy(protocol.refer(DemoService.class, URL.valueOf("webservice://127.0.0.1:9019/" + DemoService.class.getName() + "?codec=exchange&timeout=3000")));
4141
assertEquals(service.getSize(new String[]{"", "", ""}), 3);
4242
}
4343

4444
@Test
4545
public void testWebserviceProtocol() throws Exception {
4646
DemoService service = new DemoServiceImpl();
4747
protocol.export(proxy.getInvoker(service, DemoService.class, URL.valueOf("webservice://127.0.0.1:9019/" + DemoService.class.getName())));
48-
service = proxy.getProxy(protocol.refer(DemoService.class, URL.valueOf("webservice://127.0.0.1:9019/" + DemoService.class.getName())));
48+
service = proxy.getProxy(protocol.refer(DemoService.class, URL.valueOf("webservice://127.0.0.1:9019/" + DemoService.class.getName() + "?timeout=3000")));
4949
assertEquals(service.create(1,"kk").getName(), "kk");
5050
assertEquals(service.getSize(null), -1);
5151
assertEquals(service.getSize(new String[]{"", "", ""}), 3);

0 commit comments

Comments
 (0)