//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldThrowErrorWithRemoteAddressWhenClosed() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldThrowErrorWithRemoteAddressWhenClosed() { Channel channel = mock(typeof(Channel)); ByteBufAllocator allocator = mock(typeof(ByteBufAllocator)); when(allocator.buffer(anyInt())).thenReturn(Unpooled.buffer()); when(channel.alloc()).thenReturn(allocator); SocketAddress remoteAddress = mock(typeof(SocketAddress)); string remoteAddressString = "client.server.com:7687"; when(remoteAddress.ToString()).thenReturn(remoteAddressString); when(channel.remoteAddress()).thenReturn(remoteAddress); ChunkedOutput output = new ChunkedOutput(channel, DEFAULT_TEST_BUFFER_SIZE, DEFAULT_TEST_BUFFER_SIZE, NO_THROTTLE); output.Dispose(); try { output.WriteInt(42); fail("Exception expected"); } catch (PackOutputClosedException e) { assertThat(e.Message, containsString(remoteAddressString)); } }
//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) { if (_endOfInput) { return(null); } ByteBuf data = _byteBufAwareMarshal.readChunk(allocator); if (data == null) { return(null); } _endOfInput = _byteBufAwareMarshal.EndOfInput; CompositeByteBuf allData = new CompositeByteBuf(allocator, false, 2); allData.addComponent(true, data); try { bool isFirstChunk = Progress() == 0; int metaDataCapacity = MetadataSize(isFirstChunk); ByteBuf metaDataBuffer = allocator.buffer(metaDataCapacity, metaDataCapacity); allData.addComponent(true, 0, WriteMetadata(isFirstChunk, _byteBufAwareMarshal.EndOfInput, _contentType, metaDataBuffer)); _progress += allData.readableBytes(); Debug.Assert(_progress > 0); // logic relies on this return(allData); } catch (Exception e) { allData.release(); throw e; } }
public override ByteBuf ReadChunk(ByteBufAllocator allocator) { //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: int?size = Sizes.next(); if (size == null) { return(null); } return(allocator.buffer(size).writerIndex(size)); }
//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) { if (IsEndOfInput) { return(null); } ByteBuf buffer = allocator.buffer(); Marshaller.accept(new BoundedNetworkWritableChannel(buffer)); IsEndOfInput = true; Offset = buffer.readableBytes(); return(buffer); }
public override ByteBuf ReadChunk(ByteBufAllocator allocator) { _hasRead = true; if (EndOfInput) { return(null); } int toWrite = Math.Min(Available(), _chunkSize); ByteBuf buffer = allocator.buffer(toWrite); try { buffer.writeBytes(_content, _pos, toWrite); _pos += toWrite; return(buffer); } catch (Exception t) { buffer.release(); throw t; } }
public override ByteBuf Buffer() { return(Add(_allocator.buffer())); }
private ByteBuf AllocateNewBuffer() { return(_allocator.buffer(_initSize, _maxChunkSize)); }