Java 类io.netty.util.AbstractReferenceCounted 实例源码

项目:netty4.0.27Learn    文件:DefaultChannelPipelineTest.java   
@Test
public void testFreeCalled() throws Exception {
    final CountDownLatch free = new CountDownLatch(1);

    final ReferenceCounted holder = new AbstractReferenceCounted() {
        @Override
        protected void deallocate() {
            free.countDown();
        }
    };

    StringInboundHandler handler = new StringInboundHandler();
    setUp(handler);

    peer.writeAndFlush(holder).sync();

    assertTrue(free.await(10, TimeUnit.SECONDS));
    assertTrue(handler.called);
}
项目:netty4study    文件:DefaultChannelPipelineTest.java   
@Test
public void testFreeCalled() throws Exception {
    final CountDownLatch free = new CountDownLatch(1);

    final ReferenceCounted holder = new AbstractReferenceCounted() {
        @Override
        protected void deallocate() {
            free.countDown();
        }
    };

    StringInboundHandler handler = new StringInboundHandler();
    setUp(handler);

    peer.writeAndFlush(holder).sync();

    assertTrue(free.await(10, TimeUnit.SECONDS));
    assertTrue(handler.called);
}
项目:netty-netty-5.0.0.Alpha1    文件:DefaultChannelPipelineTest.java   
@Test
public void testFreeCalled() throws Exception {
    final CountDownLatch free = new CountDownLatch(1);

    final ReferenceCounted holder = new AbstractReferenceCounted() {
        @Override
        protected void deallocate() {
            free.countDown();
        }
    };

    StringInboundHandler handler = new StringInboundHandler();
    setUp(handler);

    peer.writeAndFlush(holder).sync();

    assertTrue(free.await(10, TimeUnit.SECONDS));
    assertTrue(handler.called);
}
项目:armeria    文件:AbstractStreamMessageAndWriterTest.java   
@Test
public void rejectReferenceCounted() {
    AbstractReferenceCounted item = new AbstractReferenceCounted() {
        @Override
        protected void deallocate() {}

        @Override
        public ReferenceCounted touch(Object hint) {
            return this;
        }
    };
    StreamMessageAndWriter<Object> stream = newStreamWriter(ImmutableList.of(item));
    assertThatThrownBy(() -> stream.write(item)).isInstanceOf(IllegalArgumentException.class);
}