Search in sources :

Example 1 with DubboCodec

use of org.apache.dubbo.rpc.protocol.dubbo.DubboCodec in project dubbo by alibaba.

the class DubboTelnetDecodeTest method createDubboByteBuf.

private ByteBuf createDubboByteBuf() throws IOException {
    Request request = new Request();
    RpcInvocation rpcInvocation = new RpcInvocation();
    rpcInvocation.setMethodName("sayHello");
    rpcInvocation.setParameterTypes(new Class[] { String.class });
    rpcInvocation.setParameterTypesDesc(ReflectUtils.getDesc(new Class[] { String.class }));
    rpcInvocation.setArguments(new String[] { "dubbo" });
    rpcInvocation.setAttachment("path", DemoService.class.getName());
    rpcInvocation.setAttachment("interface", DemoService.class.getName());
    rpcInvocation.setAttachment("version", "0.0.0");
    request.setData(rpcInvocation);
    request.setVersion("2.0.2");
    ByteBuf dubboByteBuf = Unpooled.buffer();
    ChannelBuffer buffer = new NettyBackedChannelBuffer(dubboByteBuf);
    DubboCodec dubboCodec = new DubboCodec();
    dubboCodec.encode(new MockChannel(), buffer, request);
    return dubboByteBuf;
}
Also used : RpcInvocation(org.apache.dubbo.rpc.RpcInvocation) DecodeableRpcInvocation(org.apache.dubbo.rpc.protocol.dubbo.DecodeableRpcInvocation) DubboCodec(org.apache.dubbo.rpc.protocol.dubbo.DubboCodec) NettyBackedChannelBuffer(org.apache.dubbo.remoting.transport.netty4.NettyBackedChannelBuffer) Request(org.apache.dubbo.remoting.exchange.Request) DemoService(org.apache.dubbo.rpc.protocol.dubbo.support.DemoService) ByteBuf(io.netty.buffer.ByteBuf) NettyBackedChannelBuffer(org.apache.dubbo.remoting.transport.netty4.NettyBackedChannelBuffer) ChannelBuffer(org.apache.dubbo.remoting.buffer.ChannelBuffer)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)1 ChannelBuffer (org.apache.dubbo.remoting.buffer.ChannelBuffer)1 Request (org.apache.dubbo.remoting.exchange.Request)1 NettyBackedChannelBuffer (org.apache.dubbo.remoting.transport.netty4.NettyBackedChannelBuffer)1 RpcInvocation (org.apache.dubbo.rpc.RpcInvocation)1 DecodeableRpcInvocation (org.apache.dubbo.rpc.protocol.dubbo.DecodeableRpcInvocation)1 DubboCodec (org.apache.dubbo.rpc.protocol.dubbo.DubboCodec)1 DemoService (org.apache.dubbo.rpc.protocol.dubbo.support.DemoService)1