提交 9768d9a9 编写于 作者: W william.liangf

DUBBO-199 增加参数和返回未实现序列化接口的异常信息测试

git-svn-id: http://code.alibabatech.com/svn/dubbo/trunk@889 1a56cb94-b969-4eaa-88fa-be21384802f2
上级 01e36e96
......@@ -22,14 +22,18 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import junit.framework.Assert;
import org.junit.Test;
import com.alibaba.dubbo.common.ExtensionLoader;
import com.alibaba.dubbo.common.URL;
import com.alibaba.dubbo.rpc.Protocol;
import com.alibaba.dubbo.rpc.ProxyFactory;
import com.alibaba.dubbo.rpc.RpcException;
import com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoService;
import com.alibaba.dubbo.rpc.protocol.dubbo.support.DemoServiceImpl;
import com.alibaba.dubbo.rpc.protocol.dubbo.support.NonSerialized;
import com.alibaba.dubbo.rpc.protocol.dubbo.support.RemoteService;
import com.alibaba.dubbo.rpc.protocol.dubbo.support.RemoteServiceImpl;
import com.alibaba.dubbo.rpc.protocol.dubbo.support.Type;
......@@ -39,7 +43,7 @@ import com.alibaba.dubbo.rpc.service.EchoService;
* <code>ProxiesTest</code>
*/
public class ProtocolsTest
public class DubboProtocolTest
{
private Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
private ProxyFactory proxy = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
......@@ -118,5 +122,33 @@ public class ProtocolsTest
for(int i=0;i<1000;i++)
service.getSize(new String[]{"", "", ""});
System.out.println("take:"+(System.currentTimeMillis()-start));
}
}
@Test
public void testNonSerializedParameter() throws Exception
{
DemoService service = new DemoServiceImpl();
protocol.export(proxy.getInvoker(service, DemoService.class, URL.valueOf("dubbo://127.0.0.1:9050/" + DemoService.class.getName() + "?codec=exchange")));
service = proxy.getProxy(protocol.refer(DemoService.class, URL.valueOf("dubbo://127.0.0.1:9050/" + DemoService.class.getName() + "?codec=exchange")));
try {
service.nonSerializedParameter(new NonSerialized());
Assert.fail();
} catch (RpcException e) {
Assert.assertTrue(e.getMessage().contains("com.alibaba.dubbo.rpc.protocol.dubbo.support.NonSerialized must implement java.io.Serializable"));
}
}
@Test
public void testReturnNonSerialized() throws Exception
{
DemoService service = new DemoServiceImpl();
protocol.export(proxy.getInvoker(service, DemoService.class, URL.valueOf("dubbo://127.0.0.1:9050/" + DemoService.class.getName() + "?codec=exchange")));
service = proxy.getProxy(protocol.refer(DemoService.class, URL.valueOf("dubbo://127.0.0.1:9050/" + DemoService.class.getName() + "?codec=exchange")));
try {
service.returnNonSerialized();
Assert.fail();
} catch (RpcException e) {
Assert.assertTrue(e.getMessage().contains("com.alibaba.dubbo.rpc.protocol.dubbo.support.NonSerialized must implement java.io.Serializable"));
}
}
}
\ No newline at end of file
......@@ -51,5 +51,9 @@ public interface DemoService
String get(CustomArgument arg1);
byte getbyte(byte arg);
void nonSerializedParameter(NonSerialized ns);
NonSerialized returnNonSerialized();
}
\ No newline at end of file
......@@ -99,5 +99,12 @@ public class DemoServiceImpl implements DemoService
public Set<String> keys(Map<String, String> map) {
return map == null ? null : map.keySet();
}
public void nonSerializedParameter(NonSerialized ns) {
}
public NonSerialized returnNonSerialized() {
return new NonSerialized();
}
}
\ No newline at end of file
/*
* Copyright 1999-2012 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.rpc.protocol.dubbo.support;
/**
* NonSerialized
*
* @author william.liangf
*/
public class NonSerialized {
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册