use of com.weibo.api.motan.rpc.DefaultRequest in project motan by weibocom.
the class UnSerializableClass method testNettyDecodeException.
@Test
public void testNettyDecodeException() throws Exception {
NettyServer nettyServer;
nettyServer = new NettyServer(url, new MessageHandler() {
@Override
public Object handle(Channel channel, Object message) {
Request request = (Request) message;
DefaultResponse response = new DefaultResponse();
response.setRequestId(request.getRequestId());
response.setValue("error");
return response;
}
});
nettyServer.open();
NettyClient nettyClient = new NettyClient(url);
nettyClient.open();
DefaultRequest request = new DefaultRequest();
request.setRequestId(RequestIdGenerator.getRequestId());
request.setInterfaceName(url.getPath());
request.setMethodName("hello");
request.setParamtersDesc("void");
try {
nettyClient.request(request);
Assert.assertTrue(false);
} catch (Exception e) {
Assert.assertTrue(e.getMessage().contains("response dataType not support"));
} finally {
nettyClient.close();
nettyServer.close();
}
}
use of com.weibo.api.motan.rpc.DefaultRequest in project motan by weibocom.
the class DefaultRpcCodec method decodeRequest.
private Object decodeRequest(byte[] body, long requestId, Serialization serialization) throws IOException, ClassNotFoundException {
ByteArrayInputStream inputStream = new ByteArrayInputStream(body);
ObjectInput input = createInput(inputStream);
String interfaceName = input.readUTF();
String methodName = input.readUTF();
String paramtersDesc = input.readUTF();
DefaultRequest rpcRequest = new DefaultRequest();
rpcRequest.setRequestId(requestId);
rpcRequest.setInterfaceName(interfaceName);
rpcRequest.setMethodName(methodName);
rpcRequest.setParamtersDesc(paramtersDesc);
rpcRequest.setArguments(decodeRequestParameter(input, paramtersDesc, serialization));
rpcRequest.setAttachments(decodeRequestAttachments(input));
input.close();
return rpcRequest;
}
use of com.weibo.api.motan.rpc.DefaultRequest in project motan by weibocom.
the class RefererCommonHandler method buildRequest.
@Override
public Request buildRequest(String interfaceName, String methodName, Object[] arguments) {
DefaultRequest request = new DefaultRequest();
request.setRequestId(RequestIdGenerator.getRequestId());
request.setInterfaceName(interfaceName);
request.setMethodName(methodName);
request.setArguments(arguments);
return request;
}
use of com.weibo.api.motan.rpc.DefaultRequest in project motan by weibocom.
the class DefaultRpcCodecTest method testNullRequest.
@Test
public void testNullRequest() throws Exception {
DefaultRequest request = getRequest("com.weibo.api.motan.protocol.example.Model", new Object[] { null });
testCodecRequest(request);
}
use of com.weibo.api.motan.rpc.DefaultRequest in project motan by weibocom.
the class DefaultRpcCodecTest method testMultiTypeRequest.
@Test
public void testMultiTypeRequest() throws Exception {
DefaultRequest request = getRequest("com.weibo.api.motan.protocol.example.Model,java.lang.Integer,java.lang.String", new Object[] { new Model("world", 12, Model.class), 1, "hello" });
testCodecRequest(request);
}
Aggregations