当前位置: 首页>>代码示例>>Java>>正文


Java ReferenceCountUtil.releaseLater方法代码示例

本文整理汇总了Java中io.netty.util.ReferenceCountUtil.releaseLater方法的典型用法代码示例。如果您正苦于以下问题:Java ReferenceCountUtil.releaseLater方法的具体用法?Java ReferenceCountUtil.releaseLater怎么用?Java ReferenceCountUtil.releaseLater使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.netty.util.ReferenceCountUtil的用法示例。


在下文中一共展示了ReferenceCountUtil.releaseLater方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testProgressivelyDiscardUnknownEmptyFrame

import io.netty.util.ReferenceCountUtil; //导入方法依赖的package包/类
@Test
public void testProgressivelyDiscardUnknownEmptyFrame() throws Exception {
    short type = 5;
    byte flags = (byte) 0xFF;
    int segment = 4;
    int length = 2 * segment;

    ByteBuf header = ReferenceCountUtil.releaseLater(Unpooled.buffer(SPDY_HEADER_SIZE));
    ByteBuf segment1 = Unpooled.buffer(segment);
    ByteBuf segment2 = Unpooled.buffer(segment);
    encodeControlFrameHeader(header, type, flags, length);
    segment1.writeInt(RANDOM.nextInt());
    segment2.writeInt(RANDOM.nextInt());

    replay(delegate);
    decoder.decode(header);
    decoder.decode(segment1);
    decoder.decode(segment2);
    verify(delegate);
    assertFalse(header.isReadable());
    assertFalse(segment1.isReadable());
    assertFalse(segment2.isReadable());
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:24,代码来源:SpdyFrameDecoderTest.java

示例2: testReservedSpdySynReplyFrameBits

import io.netty.util.ReferenceCountUtil; //导入方法依赖的package包/类
@Test
public void testReservedSpdySynReplyFrameBits() throws Exception {
    short type = 2;
    byte flags = 0;
    int length = 4;
    int streamId = RANDOM.nextInt() & 0x7FFFFFFF | 0x01;

    ByteBuf buf = ReferenceCountUtil.releaseLater(Unpooled.buffer(SPDY_HEADER_SIZE + length));
    encodeControlFrameHeader(buf, type, flags, length);
    buf.writeInt(streamId | 0x80000000); // should ignore reserved bit

    delegate.readSynReplyFrame(streamId, false);
    delegate.readHeaderBlockEnd();
    replay(delegate);
    decoder.decode(buf);
    verify(delegate);
    assertFalse(buf.isReadable());
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:19,代码来源:SpdyFrameDecoderTest.java

示例3: testIllegalSpdySynStreamFrameStreamId

import io.netty.util.ReferenceCountUtil; //导入方法依赖的package包/类
@Test
public void testIllegalSpdySynStreamFrameStreamId() throws Exception {
    short type = 1;
    byte flags = 0;
    int length = 10;
    int streamId = 0; // invalid stream identifier
    int associatedToStreamId = RANDOM.nextInt() & 0x7FFFFFFF;
    byte priority = (byte) (RANDOM.nextInt() & 0x07);

    ByteBuf buf = ReferenceCountUtil.releaseLater(Unpooled.buffer(SPDY_HEADER_SIZE + length));
    encodeControlFrameHeader(buf, type, flags, length);
    buf.writeInt(streamId);
    buf.writeInt(associatedToStreamId);
    buf.writeByte(priority << 5);
    buf.writeByte(0);

    delegate.readFrameError((String) anyObject());
    replay(delegate);
    decoder.decode(buf);
    verify(delegate);
    assertFalse(buf.isReadable());
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:23,代码来源:SpdyFrameDecoderTest.java

示例4: testSpdySynReplyFrame

import io.netty.util.ReferenceCountUtil; //导入方法依赖的package包/类
@Test
public void testSpdySynReplyFrame() throws Exception {
    short type = 2;
    byte flags = 0;
    int length = 4;
    int streamId = RANDOM.nextInt() & 0x7FFFFFFF | 0x01;

    ByteBuf buf = ReferenceCountUtil.releaseLater(Unpooled.buffer(SPDY_HEADER_SIZE + length));
    encodeControlFrameHeader(buf, type, flags, length);
    buf.writeInt(streamId);

    delegate.readSynReplyFrame(streamId, false);
    delegate.readHeaderBlockEnd();
    replay(delegate);
    decoder.decode(buf);
    verify(delegate);
    assertFalse(buf.isReadable());
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:19,代码来源:SpdyFrameDecoderTest.java

示例5: testUnknownSpdyHeadersFrameFlags

import io.netty.util.ReferenceCountUtil; //导入方法依赖的package包/类
@Test
public void testUnknownSpdyHeadersFrameFlags() throws Exception {
    short type = 8;
    byte flags = (byte) 0xFE; // undefined flags
    int length = 4;
    int streamId = RANDOM.nextInt() & 0x7FFFFFFF | 0x01;

    ByteBuf buf = ReferenceCountUtil.releaseLater(Unpooled.buffer(SPDY_HEADER_SIZE + length));
    encodeControlFrameHeader(buf, type, flags, length);
    buf.writeInt(streamId);

    delegate.readHeadersFrame(streamId, false);
    delegate.readHeaderBlockEnd();
    replay(delegate);
    decoder.decode(buf);
    verify(delegate);
    assertFalse(buf.isReadable());
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:19,代码来源:SpdyFrameDecoderTest.java

示例6: testLargeHeaderName

import io.netty.util.ReferenceCountUtil; //导入方法依赖的package包/类
@Test
public void testLargeHeaderName() throws Exception {
    ByteBuf headerBlock = ReferenceCountUtil.releaseLater(Unpooled.buffer(8220));
    headerBlock.writeBytes(zlibHeader);
    headerBlock.writeByte(0); // Non-compressed block
    headerBlock.writeByte(0x0c); // little-endian length (8204)
    headerBlock.writeByte(0x20); // little-endian length (8204)
    headerBlock.writeByte(0xf3); // one's compliment of length
    headerBlock.writeByte(0xdf); // one's compliment of length
    headerBlock.writeInt(1); // number of Name/Value pairs
    headerBlock.writeInt(8192); // length of name
    for (int i = 0; i < 8192; i++) {
        headerBlock.writeByte('n');
    }
    headerBlock.writeInt(0); // length of value
    headerBlock.writeBytes(zlibSyncFlush);
    decoder.decode(ByteBufAllocator.DEFAULT, headerBlock, frame);
    decoder.endHeaderBlock(frame);

    assertFalse(headerBlock.isReadable());
    assertFalse(frame.isInvalid());
    assertFalse(frame.isTruncated());
    assertEquals(1, frame.headers().names().size());
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:25,代码来源:SpdyHeaderBlockZlibDecoderTest.java

示例7: testZeroValueLength

import io.netty.util.ReferenceCountUtil; //导入方法依赖的package包/类
@Test
public void testZeroValueLength() throws Exception {
    ByteBuf headerBlock = ReferenceCountUtil.releaseLater(Unpooled.buffer(16));
    headerBlock.writeInt(1);
    headerBlock.writeInt(4);
    headerBlock.writeBytes(nameBytes);
    headerBlock.writeInt(0);
    decoder.decode(ByteBufAllocator.DEFAULT, headerBlock, frame);
    decoder.endHeaderBlock(frame);

    assertFalse(headerBlock.isReadable());
    assertFalse(frame.isInvalid());
    assertEquals(1, frame.headers().names().size());
    assertTrue(frame.headers().contains(name));
    assertEquals(1, frame.headers().getAll(name).size());
    assertEquals("", frame.headers().get(name));
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:18,代码来源:SpdyHeaderBlockRawDecoderTest.java

示例8: testReservedSpdyWindowUpdateFrameBits

import io.netty.util.ReferenceCountUtil; //导入方法依赖的package包/类
@Test
public void testReservedSpdyWindowUpdateFrameBits() throws Exception {
    short type = 9;
    byte flags = 0;
    int length = 8;
    int streamId = RANDOM.nextInt() & 0x7FFFFFFF;
    int deltaWindowSize = RANDOM.nextInt() & 0x7FFFFFFF | 0x01;

    ByteBuf buf = ReferenceCountUtil.releaseLater(Unpooled.buffer(SPDY_HEADER_SIZE + length));
    encodeControlFrameHeader(buf, type, flags, length);
    buf.writeInt(streamId | 0x80000000); // should ignore reserved bit
    buf.writeInt(deltaWindowSize | 0x80000000); // should ignore reserved bit

    delegate.readWindowUpdateFrame(streamId, deltaWindowSize);
    replay(delegate);
    decoder.decode(buf);
    verify(delegate);
    assertFalse(buf.isReadable());
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:20,代码来源:SpdyFrameDecoderTest.java

示例9: testReservedSpdyRstStreamFrameBits

import io.netty.util.ReferenceCountUtil; //导入方法依赖的package包/类
@Test
public void testReservedSpdyRstStreamFrameBits() throws Exception {
    short type = 3;
    byte flags = 0;
    int length = 8;
    int streamId = RANDOM.nextInt() & 0x7FFFFFFF | 0x01;
    int statusCode = RANDOM.nextInt() | 0x01;

    ByteBuf buf = ReferenceCountUtil.releaseLater(Unpooled.buffer(SPDY_HEADER_SIZE + length));
    encodeControlFrameHeader(buf, type, flags, length);
    buf.writeInt(streamId | 0x80000000); // should ignore reserved bit
    buf.writeInt(statusCode);

    delegate.readRstStreamFrame(streamId, statusCode);
    replay(delegate);
    decoder.decode(buf);
    verify(delegate);
    assertFalse(buf.isReadable());
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:20,代码来源:SpdyFrameDecoderTest.java

示例10: testSpdyHeadersFrameHeaderBlock

import io.netty.util.ReferenceCountUtil; //导入方法依赖的package包/类
@Test
public void testSpdyHeadersFrameHeaderBlock() throws Exception {
    short type = 8;
    byte flags = 0;
    int length = 4;
    int headerBlockLength = 1024;
    int streamId = RANDOM.nextInt() & 0x7FFFFFFF | 0x01;

    ByteBuf buf = ReferenceCountUtil.releaseLater(Unpooled.buffer(SPDY_HEADER_SIZE + length));
    encodeControlFrameHeader(buf, type, flags, length + headerBlockLength);
    buf.writeInt(streamId);

    ByteBuf headerBlock = ReferenceCountUtil.releaseLater(Unpooled.buffer(headerBlockLength));
    for (int i = 0; i < 256; i ++) {
        headerBlock.writeInt(RANDOM.nextInt());
    }

    delegate.readHeadersFrame(streamId, false);
    delegate.readHeaderBlock(headerBlock.duplicate());
    delegate.readHeaderBlockEnd();
    replay(delegate);
    decoder.decode(buf);
    decoder.decode(headerBlock);
    verify(delegate);
    assertFalse(buf.isReadable());
    assertFalse(headerBlock.isReadable());
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:28,代码来源:SpdyFrameDecoderTest.java

示例11: testInvalidSpdySynReplyFrameLength

import io.netty.util.ReferenceCountUtil; //导入方法依赖的package包/类
@Test
public void testInvalidSpdySynReplyFrameLength() throws Exception {
    short type = 2;
    byte flags = 0;
    int length = 0; // invalid length

    ByteBuf buf = ReferenceCountUtil.releaseLater(Unpooled.buffer(SPDY_HEADER_SIZE + length));
    encodeControlFrameHeader(buf, type, flags, length);

    delegate.readFrameError((String) anyObject());
    replay(delegate);
    decoder.decode(buf);
    verify(delegate);
    assertFalse(buf.isReadable());
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:16,代码来源:SpdyFrameDecoderTest.java

示例12: testSpdySettingsFrame

import io.netty.util.ReferenceCountUtil; //导入方法依赖的package包/类
@Test
public void testSpdySettingsFrame() throws Exception {
    short type = 4;
    byte flags = 0;
    int numSettings = 2;
    int length = 8 * numSettings + 4;
    byte idFlags = 0;
    int id = RANDOM.nextInt() & 0x00FFFFFF;
    int value = RANDOM.nextInt();

    ByteBuf buf = ReferenceCountUtil.releaseLater(Unpooled.buffer(SPDY_HEADER_SIZE + length));
    encodeControlFrameHeader(buf, type, flags, length);
    buf.writeInt(numSettings);
    for (int i = 0; i < numSettings; i++) {
        buf.writeByte(idFlags);
        buf.writeMedium(id);
        buf.writeInt(value);
    }

    delegate.readSettingsFrame(false);
    delegate.readSetting(id, value, false, false);
    expectLastCall().times(numSettings);
    delegate.readSettingsEnd();
    replay(delegate);
    decoder.decode(buf);
    verify(delegate);
    assertFalse(buf.isReadable());
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:29,代码来源:SpdyFrameDecoderTest.java

示例13: testInvalidSpdyHeadersFrameLength

import io.netty.util.ReferenceCountUtil; //导入方法依赖的package包/类
@Test
public void testInvalidSpdyHeadersFrameLength() throws Exception {
    short type = 8;
    byte flags = 0;
    int length = 0; // invalid length

    ByteBuf buf = ReferenceCountUtil.releaseLater(Unpooled.buffer(SPDY_HEADER_SIZE + length));
    encodeControlFrameHeader(buf, type, flags, length);

    delegate.readFrameError((String) anyObject());
    replay(delegate);
    decoder.decode(buf);
    verify(delegate);
    assertFalse(buf.isReadable());
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:16,代码来源:SpdyFrameDecoderTest.java

示例14: testMissingNameLength

import io.netty.util.ReferenceCountUtil; //导入方法依赖的package包/类
@Test
public void testMissingNameLength() throws Exception {
    ByteBuf headerBlock = ReferenceCountUtil.releaseLater(Unpooled.buffer(4));
    headerBlock.writeInt(1);
    decoder.decode(ByteBufAllocator.DEFAULT, headerBlock, frame);
    decoder.endHeaderBlock(frame);

    assertFalse(headerBlock.isReadable());
    assertTrue(frame.isInvalid());
    assertEquals(0, frame.headers().names().size());
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:12,代码来源:SpdyHeaderBlockRawDecoderTest.java

示例15: testZeroNameLength

import io.netty.util.ReferenceCountUtil; //导入方法依赖的package包/类
@Test
public void testZeroNameLength() throws Exception {
    ByteBuf headerBlock = ReferenceCountUtil.releaseLater(Unpooled.buffer(8));
    headerBlock.writeInt(1);
    headerBlock.writeInt(0);
    decoder.decode(ByteBufAllocator.DEFAULT, headerBlock, frame);

    assertFalse(headerBlock.isReadable());
    assertTrue(frame.isInvalid());
    assertEquals(0, frame.headers().names().size());
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:12,代码来源:SpdyHeaderBlockRawDecoderTest.java


注:本文中的io.netty.util.ReferenceCountUtil.releaseLater方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。