本文整理汇总了Java中com.alibaba.dubbo.remoting.telnet.codec.TelnetCodec类的典型用法代码示例。如果您正苦于以下问题:Java TelnetCodec类的具体用法?Java TelnetCodec怎么用?Java TelnetCodec使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TelnetCodec类属于com.alibaba.dubbo.remoting.telnet.codec包,在下文中一共展示了TelnetCodec类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_Decode_Error_MagicNum
import com.alibaba.dubbo.remoting.telnet.codec.TelnetCodec; //导入依赖的package包/类
@Test
public void test_Decode_Error_MagicNum() throws IOException{
HashMap<byte[] , Object> inputBytes = new HashMap<byte[] , Object>();
inputBytes.put( new byte[] { 0 }, TelnetCodec.DecodeResult.NEED_MORE_INPUT );
inputBytes.put( new byte[] { MAGIC_HIGH, 0 }, TelnetCodec.DecodeResult.NEED_MORE_INPUT );
inputBytes.put( new byte[] { 0 , MAGIC_LOW }, TelnetCodec.DecodeResult.NEED_MORE_INPUT );
for (byte[] input : inputBytes.keySet()){
testDecode_assertEquals(assemblyDataProtocol(input) ,inputBytes.get(input));
}
}
示例2: test_Decode_Check_Payload
import com.alibaba.dubbo.remoting.telnet.codec.TelnetCodec; //导入依赖的package包/类
@Test
public void test_Decode_Check_Payload() throws IOException {
byte[] header = new byte[]{MAGIC_HIGH, MAGIC_LOW, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
byte[] request = assemblyDataProtocol(header);
try {
testDecode_assertEquals(request, TelnetCodec.DecodeResult.NEED_MORE_INPUT);
fail();
} catch (IOException expected) {
Assert.assertTrue(expected.getMessage().startsWith("Data length too large: " + Bytes.bytes2int(new byte[]{1, 1, 1, 1})));
}
}
示例3: test_Decode_MigicCodec_Contain_ExchangeHeader
import com.alibaba.dubbo.remoting.telnet.codec.TelnetCodec; //导入依赖的package包/类
@Test
public void test_Decode_MigicCodec_Contain_ExchangeHeader() throws IOException{
//
byte[] header = new byte[] { 0, 0, MAGIC_HIGH , MAGIC_LOW , 0 ,0 ,0 ,0 ,0 , 0 ,0 ,0 ,0 };
Channel channel = getServerSideChannel(url);
ChannelBuffer buffer = ChannelBuffers.wrappedBuffer(header);
Object obj = codec.decode(channel, buffer);
Assert.assertEquals(TelnetCodec.DecodeResult.NEED_MORE_INPUT, obj);
//如果telnet数据与request数据在同一个数据包中,不能因为telnet没有结尾字符而影响其他数据的接收.
Assert.assertEquals(2, buffer.readerIndex());
}