Search in sources :

Example 1 with ReferenceCounted

use of io.netty.util.ReferenceCounted in project netty by netty.

the class DefaultChannelPipelineTest method testFreeCalled.

@Test
public void testFreeCalled() throws Exception {
    final CountDownLatch free = new CountDownLatch(1);
    final ReferenceCounted holder = new AbstractReferenceCounted() {

        @Override
        protected void deallocate() {
            free.countDown();
        }

        @Override
        public ReferenceCounted touch(Object hint) {
            return this;
        }
    };
    StringInboundHandler handler = new StringInboundHandler();
    setUp(handler);
    peer.writeAndFlush(holder).sync();
    assertTrue(free.await(10, TimeUnit.SECONDS));
    assertTrue(handler.called);
}
Also used : AbstractReferenceCounted(io.netty.util.AbstractReferenceCounted) CountDownLatch(java.util.concurrent.CountDownLatch) AbstractReferenceCounted(io.netty.util.AbstractReferenceCounted) ReferenceCounted(io.netty.util.ReferenceCounted) Test(org.junit.Test)

Aggregations

AbstractReferenceCounted (io.netty.util.AbstractReferenceCounted)1 ReferenceCounted (io.netty.util.ReferenceCounted)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Test (org.junit.Test)1