diff --git a/dubbo-config/src/test/java/com/alibaba/dubbo/config/ConfigTest.java b/dubbo-config/src/test/java/com/alibaba/dubbo/config/ConfigTest.java index 815b99e53da76cc8b615b6b5cff86874e1534e26..2d4da77c429bbbd891abf0dadf18e6865b0bf503 100644 --- a/dubbo-config/src/test/java/com/alibaba/dubbo/config/ConfigTest.java +++ b/dubbo-config/src/test/java/com/alibaba/dubbo/config/ConfigTest.java @@ -20,6 +20,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.*; import static org.junit.matchers.JUnitMatchers.*; +import static org.hamcrest.core.IsNot.*; import java.util.List; @@ -330,7 +331,7 @@ public class ConfigTest { // BUG: DUBBO-846 2.0.9中,服务方法上的retry="false"设置失效 @Test - public void test_retry_effective() throws Exception { + public void test_retrySettingFail() throws Exception { ClassPathXmlApplicationContext providerContext = new ClassPathXmlApplicationContext( ConfigTest.class.getPackage().getName().replace('.', '/') + "/demo-provider-long-waiting.xml"); providerContext.start(); @@ -359,6 +360,34 @@ public class ConfigTest { providerContext.close(); } } + + // BUG: DUBBO-146 Dubbo序列化失败(如传输对象没有实现Serialiable接口),Provider端也没有异常输出,Consumer端超时出错 + @Test + public void test_returnSerializationFail() throws Exception { + ClassPathXmlApplicationContext providerContext = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/demo-provider-UnserializableBox.xml"); + providerContext.start(); + try { + ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/init-reference.xml"); + ctx.start(); + try { + DemoService demoService = (DemoService)ctx.getBean("demoService"); + try { + demoService.getBox(); + fail(); + } catch (RpcException expected) { + assertThat(expected.getMessage(), containsString("must implement java.io.Serializable")); + assertThat(expected.getMessage(), not(containsString("timeout"))); + } + } finally { + ctx.stop(); + ctx.close(); + } + } finally { + providerContext.stop(); + providerContext.close(); + } + } + @Test public void testSystemPropertyOverrideProtocol() throws Exception { System.setProperty("dubbo.protocol.port", "20812"); diff --git a/dubbo-config/src/test/java/com/alibaba/dubbo/config/api/Box.java b/dubbo-config/src/test/java/com/alibaba/dubbo/config/api/Box.java new file mode 100644 index 0000000000000000000000000000000000000000..a5a154989dd74717d0e6a9d61900a8b7e74890a9 --- /dev/null +++ b/dubbo-config/src/test/java/com/alibaba/dubbo/config/api/Box.java @@ -0,0 +1,23 @@ +/* + * Copyright 1999-2011 Alibaba Group. + * + * Licensed 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 com.alibaba.dubbo.config.api; + +/** + * @author ding.lid + */ +public interface Box { + String getName(); +} diff --git a/dubbo-config/src/test/java/com/alibaba/dubbo/config/api/DemoService.java b/dubbo-config/src/test/java/com/alibaba/dubbo/config/api/DemoService.java index 6768ea2ae9bee84feaccc790e06f1782f2ce364e..a536ee8fd0d1f1195aea499eae7e5b5aefed6764 100644 --- a/dubbo-config/src/test/java/com/alibaba/dubbo/config/api/DemoService.java +++ b/dubbo-config/src/test/java/com/alibaba/dubbo/config/api/DemoService.java @@ -22,5 +22,7 @@ package com.alibaba.dubbo.config.api; * @author william.liangf */ public interface DemoService { - String sayName(String name); + String sayName(String name); + + Box getBox(); } \ No newline at end of file diff --git a/dubbo-config/src/test/java/com/alibaba/dubbo/config/provider/impl/DemoServiceImpl.java b/dubbo-config/src/test/java/com/alibaba/dubbo/config/provider/impl/DemoServiceImpl.java index 9fc9b28b02f64433f5bbbe872cece81ed6a48b09..233b124de52cca005aeef16f9da058c084d7b901 100644 --- a/dubbo-config/src/test/java/com/alibaba/dubbo/config/provider/impl/DemoServiceImpl.java +++ b/dubbo-config/src/test/java/com/alibaba/dubbo/config/provider/impl/DemoServiceImpl.java @@ -15,6 +15,7 @@ */ package com.alibaba.dubbo.config.provider.impl; +import com.alibaba.dubbo.config.api.Box; import com.alibaba.dubbo.config.api.DemoService; /** @@ -27,5 +28,9 @@ public class DemoServiceImpl implements DemoService { public String sayName(String name) { return "say:" + name; } + + public Box getBox() { + return null; + } } \ No newline at end of file diff --git a/dubbo-config/src/test/java/com/alibaba/dubbo/config/provider/impl/DemoServiceImpl_LongWaiting.java b/dubbo-config/src/test/java/com/alibaba/dubbo/config/provider/impl/DemoServiceImpl_LongWaiting.java index 5b4b91dbae29ff7f0390374d927d879d2ce99788..c9d17462f14c01c15892e96565472989162532a2 100644 --- a/dubbo-config/src/test/java/com/alibaba/dubbo/config/provider/impl/DemoServiceImpl_LongWaiting.java +++ b/dubbo-config/src/test/java/com/alibaba/dubbo/config/provider/impl/DemoServiceImpl_LongWaiting.java @@ -15,6 +15,7 @@ */ package com.alibaba.dubbo.config.provider.impl; +import com.alibaba.dubbo.config.api.Box; import com.alibaba.dubbo.config.api.DemoService; /** @@ -32,4 +33,8 @@ public class DemoServiceImpl_LongWaiting implements DemoService { return "say:" + name; } + public Box getBox() { + return null; + } + } \ No newline at end of file diff --git a/dubbo-config/src/test/java/com/alibaba/dubbo/config/provider/impl/UnserializableBox.java b/dubbo-config/src/test/java/com/alibaba/dubbo/config/provider/impl/UnserializableBox.java new file mode 100644 index 0000000000000000000000000000000000000000..c2d6a527949a08f6d145f02646d3cb8a25ebce2c --- /dev/null +++ b/dubbo-config/src/test/java/com/alibaba/dubbo/config/provider/impl/UnserializableBox.java @@ -0,0 +1,49 @@ +/* + * Copyright 1999-2011 Alibaba Group. + * + * Licensed 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 com.alibaba.dubbo.config.provider.impl; + +import com.alibaba.dubbo.config.api.Box; + +/** + * @author ding.lid + */ +public class UnserializableBox implements Box { + private static final long serialVersionUID = -4141012025649711421L; + + private int count = 3; + private String name = "Jerry"; + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public String toString() { + return "Box [count=" + count + ", name=" + name + "]"; + } +} diff --git a/dubbo-config/src/test/java/com/alibaba/dubbo/config/provider/impl/UnserializableBoxDemoServiceImpl.java b/dubbo-config/src/test/java/com/alibaba/dubbo/config/provider/impl/UnserializableBoxDemoServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..65fe298462f0b19d66a6d5c926295edf192c9734 --- /dev/null +++ b/dubbo-config/src/test/java/com/alibaba/dubbo/config/provider/impl/UnserializableBoxDemoServiceImpl.java @@ -0,0 +1,36 @@ +/* + * Copyright 1999-2011 Alibaba Group. + * + * Licensed 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 com.alibaba.dubbo.config.provider.impl; + +import com.alibaba.dubbo.config.api.Box; +import com.alibaba.dubbo.config.api.DemoService; + +/** + * DemoServiceImpl + * + * @author william.liangf + */ +public class UnserializableBoxDemoServiceImpl implements DemoService { + + public String sayName(String name) { + return "say:" + name; + } + + public Box getBox() { + return new UnserializableBox(); + } + +} \ No newline at end of file diff --git a/dubbo-config/src/test/resources/com/alibaba/dubbo/config/demo-provider-UnserializableBox.xml b/dubbo-config/src/test/resources/com/alibaba/dubbo/config/demo-provider-UnserializableBox.xml new file mode 100644 index 0000000000000000000000000000000000000000..bd2d1dfb8de6475a3a33eb959d300b2e7667a54c --- /dev/null +++ b/dubbo-config/src/test/resources/com/alibaba/dubbo/config/demo-provider-UnserializableBox.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file