Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test @SuppressWarnings("unchecked") public void newBuffersAreCreatedIfNoFreeBuffersAreAvailable()
        public virtual void NewBuffersAreCreatedIfNoFreeBuffersAreAvailable()
        {
            CountingChannelBufferFactory       bufferFactory = new CountingChannelBufferFactory();
            BufferReusingChunkingChannelBuffer buffer        = NewBufferReusingChunkingChannelBuffer(10, bufferFactory);

            buffer.WriteLong(1);
            buffer.WriteLong(2);
            buffer.WriteLong(3);

            assertEquals(3, bufferFactory.InstancesCreated);
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static org.jboss.netty.buffer.ChannelBuffer triggerOperationCompleteCallback(BufferReusingChunkingChannelBuffer buffer) throws Exception
        private static ChannelBuffer TriggerOperationCompleteCallback(BufferReusingChunkingChannelBuffer buffer)
        {
            ChannelBuffer reusedBuffer = spy(ChannelBuffers.dynamicBuffer());

            ChannelFuture channelFuture = mock(typeof(ChannelFuture));

            when(channelFuture.Done).thenReturn(true);
            when(channelFuture.Success).thenReturn(true);

            buffer.NewChannelFutureListener(reusedBuffer).operationComplete(channelFuture);
            return(reusedBuffer);
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test @SuppressWarnings("unchecked") public void freeBuffersAreReused() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void FreeBuffersAreReused()
        {
            CountingChannelBufferFactory       bufferFactory = new CountingChannelBufferFactory();
            BufferReusingChunkingChannelBuffer buffer        = NewBufferReusingChunkingChannelBuffer(10, bufferFactory);

            buffer.WriteLong(1);
            buffer.WriteLong(2);

            // return 2 buffers to the pool
            ChannelBuffer reusedBuffer1 = TriggerOperationCompleteCallback(buffer);
            ChannelBuffer reusedBuffer2 = TriggerOperationCompleteCallback(buffer);

            buffer.WriteLong(3);
            buffer.WriteLong(4);

            // 2 buffers were created
            assertEquals(2, bufferFactory.InstancesCreated);

            // and 2 buffers were reused
            verify(reusedBuffer1).writeLong(3);
            verify(reusedBuffer2).writeLong(4);
        }