use of com.weibo.api.motan.rpc.DefaultResponse in project motan by weibocom.
the class DefaultRpcCodecTest method exceptionResponseSize.
/**
* 不带参数的Request大小
*/
private static byte[] exceptionResponseSize(DefaultRpcCodec codec, Channel channel) throws Exception {
DefaultResponse response = new DefaultResponse();
response.setRequestId(System.currentTimeMillis());
response.setProcessTime(System.currentTimeMillis());
response.setException(new MotanBizException(new RuntimeException("hi, boy, i am biz exception.")));
byte[] bytes = codec.encode(channel, response);
return bytes;
}
use of com.weibo.api.motan.rpc.DefaultResponse in project motan by weibocom.
the class YarProtocolUtil method convert.
public static Response convert(YarResponse yarResponse) {
DefaultResponse response = new DefaultResponse();
response.setRequestId(yarResponse.getId());
response.setValue(yarResponse.getRet());
if (StringUtils.isNotBlank(yarResponse.getError())) {
response.setException(new MotanBizException(yarResponse.getError()));
}
return response;
}
use of com.weibo.api.motan.rpc.DefaultResponse in project motan by weibocom.
the class YarMessageRouterTest method testHandle.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testHandle() {
response = new DefaultResponse();
response.setValue("test");
response.setProcessTime(1);
Provider provider = new DefaultProvider(null, null, AnnoService.class);
router.addProvider(provider);
YarRequest yarRequest = new YarRequest(1, "JSON", "hello", new Object[] { "params" });
yarRequest.setRequestPath(requestPath);
YarResponse yarResponse = (YarResponse) router.handle(null, yarRequest);
assertEquals(YarProtocolUtil.convert(response, "JSON"), yarResponse);
}
use of com.weibo.api.motan.rpc.DefaultResponse in project motan by weibocom.
the class DefaultRpcCodecTest method testOriginalTypeResponse.
@Test
public void testOriginalTypeResponse() throws Exception {
DefaultResponse response = new DefaultResponse();
response.setValue(1);
testCodecResponse(response);
}
use of com.weibo.api.motan.rpc.DefaultResponse in project motan by weibocom.
the class OpenTracingFilterTest method setUp.
@Before
public void setUp() throws Exception {
OTFilter = new OpenTracingFilter();
tracer = new MockTracer();
OpenTracingContext.tracerFactory = new TracerFactory() {
@Override
public Tracer getTracer() {
return tracer;
}
};
URL url = new URL("motan", "localhost", 8002, "HelloService");
request = new DefaultRequest();
request.setInterfaceName("HelloService");
request.setAttachment(URLParamType.group.name(), "test");
request.setMethodName("sayHello");
request.setParamtersDesc("java.lang.String");
response = new DefaultResponse();
refer = new AbstractReferer<HelloService>(HelloService.class, url) {
@Override
public void destroy() {
}
@Override
public boolean isAvailable() {
return true;
}
@Override
protected Response doCall(Request request) {
return response;
}
@Override
protected boolean doInit() {
return true;
}
};
provider = new DefaultProvider<HelloService>(new HelloServiceImpl(), url, HelloService.class) {
@Override
public Response call(Request request) {
return response;
}
};
}
Aggregations