提交 4d4428ce 编写于 作者: D ding.lid

添加UT DUBBO-146 Dubbo序列化失败(如传输对象没有实现Serialiable接口),Provider端也没有异常输出,Consumer端超时出错

git-svn-id: http://code.alibabatech.com/svn/dubbo/trunk@751 1a56cb94-b969-4eaa-88fa-be21384802f2
上级 3ad644d9
......@@ -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");
......
/*
* 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();
}
......@@ -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
......@@ -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
......@@ -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
/*
* 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 + "]";
}
}
/*
* 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
<!--
- 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.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd
">
<!-- 当前应用信息配置 -->
<dubbo:application name="demo-provider" />
<!-- 连接注册中心配置 -->
<dubbo:registry address="N/A" />
<!-- 暴露服务协议配置 -->
<dubbo:protocol name="dubbo" port="20813" />
<!-- 暴露服务配置 -->
<dubbo:service interface="com.alibaba.dubbo.config.api.DemoService" ref="demoService" />
<bean id="demoService" class="com.alibaba.dubbo.config.provider.impl.UnserializableBoxDemoServiceImpl" />
</beans>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册