示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldProvideExpectedMetaData() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldProvideExpectedMetaData()
        {
            ChunkedInput <ByteBuf> replicatedContent = ChunkedReplicatedContent.Chunked(( sbyte )1, new ThreeChunks(this, -1, 8));

            UnpooledByteBufAllocator allocator = UnpooledByteBufAllocator.DEFAULT;

            ByteBuf byteBuf = replicatedContent.readChunk(allocator);

            // is not last
            assertFalse(byteBuf.readBoolean());
            // first chunk has content
            assertEquals(( sbyte )1, byteBuf.readByte());
            byteBuf.release();

            byteBuf = replicatedContent.readChunk(allocator);
            // is not last
            assertFalse(byteBuf.readBoolean());
            byteBuf.release();

            byteBuf = replicatedContent.readChunk(allocator);
            // is last
            assertTrue(byteBuf.readBoolean());
            byteBuf.release();

            assertNull(replicatedContent.readChunk(allocator));
        }
示例#2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void encode(io.netty.buffer.ByteBuf buffer, io.netty.handler.stream.ChunkedInput<io.netty.buffer.ByteBuf> marshal) throws Exception
        private static void Encode(ByteBuf buffer, ChunkedInput <ByteBuf> marshal)
        {
            while (!marshal.EndOfInput)
            {
                ByteBuf tmp = marshal.readChunk(UnpooledByteBufAllocator.DEFAULT);
                if (tmp != null)
                {
                    buffer.writeBytes(tmp);
                    tmp.release();
                }
            }
        }
示例#3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public io.netty.buffer.ByteBuf readChunk(io.netty.buffer.ByteBufAllocator allocator) throws Exception
        public override ByteBuf ReadChunk(ByteBufAllocator allocator)
        {
            ByteBuf byteBuf = _chunkedInput.readChunk(allocator);

            if (byteBuf != null)
            {
                int additionalBytes = byteBuf.readableBytes();
                this._totalSize += additionalBytes;
                if (this._totalSize > _maxSize)
                {
                    throw new MessageTooBigException(format("Size limit exceeded. Limit is %d, wanted to write %d, written so far %d", _maxSize, additionalBytes, _totalSize - additionalBytes));
                }
            }
            return(byteBuf);
        }