本文整理汇总了Java中com.alibaba.dubbo.remoting.exchange.Response.setVersion方法的典型用法代码示例。如果您正苦于以下问题:Java Response.setVersion方法的具体用法?Java Response.setVersion怎么用?Java Response.setVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.dubbo.remoting.exchange.Response
的用法示例。
在下文中一共展示了Response.setVersion方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_Encode_Response
import com.alibaba.dubbo.remoting.exchange.Response; //导入方法依赖的package包/类
@Test
public void test_Encode_Response() throws IOException{
ChannelBuffer encodeBuffer = ChannelBuffers.dynamicBuffer(1024);
Channel channel = getCliendSideChannel(url);
Response response = new Response();
response.setHeartbeat(true);
response.setId(1001l);
response.setStatus((byte)20 );
response.setVersion("11");
Person person = new Person();
response.setResult(person);
codec.encode(channel, encodeBuffer, response);
byte[] data = new byte[encodeBuffer.writerIndex()];
encodeBuffer.readBytes(data);
//encode resault check need decode
ChannelBuffer decodeBuffer = ChannelBuffers.wrappedBuffer(data);
Response obj = (Response)codec.decode(channel, decodeBuffer);
Assert.assertEquals(response.getId(), obj.getId());
Assert.assertEquals(response.getStatus(), obj.getStatus());
Assert.assertEquals(response.isHeartbeat(), obj.isHeartbeat());
Assert.assertEquals(person, obj.getResult());
// encode response verson ??
// Assert.assertEquals(response.getVersion(), obj.getVersion());
}
示例2: test_Encode_Error_Response
import com.alibaba.dubbo.remoting.exchange.Response; //导入方法依赖的package包/类
@Test
public void test_Encode_Error_Response() throws IOException{
ChannelBuffer encodeBuffer = ChannelBuffers.dynamicBuffer(1024);
Channel channel = getCliendSideChannel(url);
Response response = new Response();
response.setHeartbeat(true);
response.setId(1001l);
response.setStatus((byte)10 );
response.setVersion("11");
String badString = "bad" ;
response.setErrorMessage(badString);
Person person = new Person();
response.setResult(person);
codec.encode(channel, encodeBuffer, response);
byte[] data = new byte[encodeBuffer.writerIndex()];
encodeBuffer.readBytes(data);
//encode resault check need decode
ChannelBuffer decodeBuffer = ChannelBuffers.wrappedBuffer(data);
Response obj = (Response)codec.decode(channel, decodeBuffer);
Assert.assertEquals(response.getId(), obj.getId());
Assert.assertEquals(response.getStatus(), obj.getStatus());
Assert.assertEquals(response.isHeartbeat(), obj.isHeartbeat());
Assert.assertEquals(badString, obj.getErrorMessage());
Assert.assertEquals(null, obj.getResult());
// Assert.assertEquals(response.getVersion(), obj.getVersion());
}