//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)); }
private static void ReleaseIfPossible(ByteBuf buf) { if (buf.refCnt() > 0) { buf.release(); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static byte[] chunk(int maxChunkSize, byte[][] messages) throws java.io.IOException public static sbyte[] Chunk(int maxChunkSize, sbyte[][] messages) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final ByteBuffer outputBuffer = ByteBuffer.allocate(1024 * 8); ByteBuffer outputBuffer = ByteBuffer.allocate(1024 * 8); Channel ch = mock(typeof(Channel)); when(ch.alloc()).thenReturn(UnpooledByteBufAllocator.DEFAULT); when(ch.writeAndFlush(any(), Null)).then(inv => { ByteBuf buf = inv.getArgument(0); outputBuffer.limit(outputBuffer.position() + buf.readableBytes()); buf.readBytes(outputBuffer); buf.release(); return(null); }); int maxBufferSize = maxChunkSize + CHUNK_HEADER_SIZE; ChunkedOutput @out = new ChunkedOutput(ch, maxBufferSize, maxBufferSize, TransportThrottleGroup.NO_THROTTLE); foreach (sbyte[] message in messages) { @out.BeginMessage(); @out.WriteBytes(message, 0, message.Length); @out.MessageSucceeded(); } @out.Flush(); @out.Dispose(); sbyte[] bytes = new sbyte[outputBuffer.limit()]; outputBuffer.position(0); outputBuffer.get(bytes); return(bytes); }
//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(); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @After public void cleanup() public virtual void Cleanup() { if (_expected != null) { _expected.release(); } if (_client != null) { _client.disconnect(); } if (_server != null) { _server.stop(); } }