本文整理匯總了Java中io.netty.handler.codec.Delimiters.nulDelimiter方法的典型用法代碼示例。如果您正苦於以下問題:Java Delimiters.nulDelimiter方法的具體用法?Java Delimiters.nulDelimiter怎麽用?Java Delimiters.nulDelimiter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.netty.handler.codec.Delimiters
的用法示例。
在下文中一共展示了Delimiters.nulDelimiter方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testFailSlowTooLongFrameRecovery
import io.netty.handler.codec.Delimiters; //導入方法依賴的package包/類
@Test
public void testFailSlowTooLongFrameRecovery() throws Exception {
EmbeddedChannel ch = new EmbeddedChannel(
new DelimiterBasedFrameDecoder(1, true, false, Delimiters.nulDelimiter()));
for (int i = 0; i < 2; i ++) {
ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 1, 2 }));
try {
assertTrue(ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0 })));
fail(DecoderException.class.getSimpleName() + " must be raised.");
} catch (TooLongFrameException e) {
// Expected
}
ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 'A', 0 }));
ByteBuf buf = releaseLater((ByteBuf) ch.readInbound());
assertEquals("A", buf.toString(CharsetUtil.ISO_8859_1));
}
}
示例2: testFailFastTooLongFrameRecovery
import io.netty.handler.codec.Delimiters; //導入方法依賴的package包/類
@Test
public void testFailFastTooLongFrameRecovery() throws Exception {
EmbeddedChannel ch = new EmbeddedChannel(
new DelimiterBasedFrameDecoder(1, Delimiters.nulDelimiter()));
for (int i = 0; i < 2; i ++) {
try {
assertTrue(ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 1, 2 })));
fail(DecoderException.class.getSimpleName() + " must be raised.");
} catch (TooLongFrameException e) {
// Expected
}
ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 0, 'A', 0 }));
ByteBuf buf = releaseLater((ByteBuf) ch.readInbound());
assertEquals("A", buf.toString(CharsetUtil.ISO_8859_1));
}
}