use of com.weibo.api.motan.protocol.v2motan.MotanV2Codec in project motan by weibocom.
the class NettyDecoderTest method onlyOneDecodeInvoked.
@Test
public void onlyOneDecodeInvoked() {
NettyNewCntDecoder nettyDecoder = new NettyNewCntDecoder(new MotanV2Codec(), nettyServer, 24);
NettyChannelHandler handler = new NettyChannelHandler(nettyServer, messageHandler, (ThreadPoolExecutor) Executors.newFixedThreadPool(4));
EmbeddedChannel channel = new EmbeddedChannel(nettyDecoder, handler);
ByteBuf buf = Unpooled.wrappedBuffer(new byte[] { 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e' });
channel.writeInbound(buf.copy());
buf.release();
assertEquals(true, 1 == nettyDecoder.getDecodeInvokeCnt());
}
use of com.weibo.api.motan.protocol.v2motan.MotanV2Codec in project motan by weibocom.
the class NettyDecoderTest method repeatDecodeInvokedByOldCode.
@Test
public void repeatDecodeInvokedByOldCode() {
NettyOldFakeDecoder nettyDecoder = new NettyOldFakeDecoder(new MotanV2Codec(), nettyServer, 24);
NettyChannelHandler handler = new NettyChannelHandler(nettyServer, messageHandler, (ThreadPoolExecutor) Executors.newFixedThreadPool(4));
EmbeddedChannel channel = new EmbeddedChannel(nettyDecoder, handler);
ByteBuf buf = Unpooled.wrappedBuffer(new byte[] { 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e' });
channel.writeInbound(buf.copy());
buf.release();
assertEquals(false, 1 == nettyDecoder.getDecodeInvokeCnt());
}
Aggregations