public override bool OnFileContent(CompletableFuture <T> signal, FileChunk fileChunk) { try { _storeFileStream.write(fileChunk.Bytes()); } catch (Exception e) { signal.completeExceptionally(e); } return(fileChunk.Last); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void sendEmptyFile() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void SendEmptyFile() { // given File emptyFile = TestDirectory.file("emptyFile"); _fs.create(emptyFile).close(); FileSender fileSender = new FileSender(new StoreResource(emptyFile, null, 16, _fs)); // when + then assertFalse(fileSender.EndOfInput); assertEquals(FileChunk.Create(new sbyte[0], true), fileSender.ReadChunk(_allocator)); assertNull(fileSender.ReadChunk(_allocator)); assertTrue(fileSender.EndOfInput); }
public override bool Equals(object o) { if (this == o) { return(true); } if (o == null || this.GetType() != o.GetType()) { return(false); } FileChunk fileChunk = ( FileChunk )o; return(_encodedLength == fileChunk._encodedLength && Arrays.Equals(_bytes, fileChunk._bytes)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void sendEmptyFileWhichGrowsBeforeSendCommences() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void SendEmptyFileWhichGrowsBeforeSendCommences() { // given File file = TestDirectory.file("file"); StoreChannel writer = _fs.create(file); FileSender fileSender = new FileSender(new StoreResource(file, null, 16, _fs)); // when sbyte[] bytes = WriteRandomBytes(writer, 1024); // then assertFalse(fileSender.EndOfInput); assertEquals(FileChunk.Create(bytes, true), fileSender.ReadChunk(_allocator)); assertTrue(fileSender.EndOfInput); assertNull(fileSender.ReadChunk(_allocator)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void sendSmallFile() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void SendSmallFile() { // given sbyte[] bytes = new sbyte[10]; _random.NextBytes(bytes); File smallFile = TestDirectory.file("smallFile"); using (StoreChannel storeChannel = _fs.create(smallFile)) { storeChannel.write(ByteBuffer.wrap(bytes)); } FileSender fileSender = new FileSender(new StoreResource(smallFile, null, 16, _fs)); // when + then assertFalse(fileSender.EndOfInput); assertEquals(FileChunk.Create(bytes, true), fileSender.ReadChunk(_allocator)); assertNull(fileSender.ReadChunk(_allocator)); assertTrue(fileSender.EndOfInput); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void sendFileWhichGrowsAfterLastChunkWasSent() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void SendFileWhichGrowsAfterLastChunkWasSent() { // given File file = TestDirectory.file("file"); StoreChannel writer = _fs.create(file); FileSender fileSender = new FileSender(new StoreResource(file, null, 16, _fs)); // when sbyte[] chunkA = WriteRandomBytes(writer, MAX_SIZE); FileChunk readChunkA = fileSender.ReadChunk(_allocator); // then assertEquals(FileChunk.Create(chunkA, true), readChunkA); assertTrue(fileSender.EndOfInput); // when WriteRandomBytes(writer, MAX_SIZE); // then assertTrue(fileSender.EndOfInput); assertNull(fileSender.ReadChunk(_allocator)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void sendEmptyFileWhichGrowsWithPartialChunkSizes() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void SendEmptyFileWhichGrowsWithPartialChunkSizes() { // given File file = TestDirectory.file("file"); StoreChannel writer = _fs.create(file); FileSender fileSender = new FileSender(new StoreResource(file, null, 16, _fs)); // when sbyte[] chunkA = WriteRandomBytes(writer, MAX_SIZE); sbyte[] chunkB = WriteRandomBytes(writer, MAX_SIZE / 2); // then assertEquals(FileChunk.Create(chunkA, false), fileSender.ReadChunk(_allocator)); assertFalse(fileSender.EndOfInput); // when WriteRandomBytes(writer, MAX_SIZE / 2); // then assertEquals(FileChunk.Create(chunkB, true), fileSender.ReadChunk(_allocator)); assertTrue(fileSender.EndOfInput); assertNull(fileSender.ReadChunk(_allocator)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void sendLargeFileWithSizeMultipleOfTheChunkSize() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void SendLargeFileWithSizeMultipleOfTheChunkSize() { // given sbyte[] bytes = new sbyte[MAX_SIZE * 3]; _random.NextBytes(bytes); File smallFile = TestDirectory.file("smallFile"); using (StoreChannel storeChannel = _fs.create(smallFile)) { storeChannel.write(ByteBuffer.wrap(bytes)); } FileSender fileSender = new FileSender(new StoreResource(smallFile, null, 16, _fs)); // when + then assertFalse(fileSender.EndOfInput); assertEquals(FileChunk.Create(copyOfRange(bytes, 0, MAX_SIZE), false), fileSender.ReadChunk(_allocator)); assertEquals(FileChunk.Create(copyOfRange(bytes, MAX_SIZE, MAX_SIZE * 2), false), fileSender.ReadChunk(_allocator)); assertEquals(FileChunk.Create(copyOfRange(bytes, MAX_SIZE * 2, bytes.Length), true), fileSender.ReadChunk(_allocator)); assertNull(fileSender.ReadChunk(_allocator)); assertTrue(fileSender.EndOfInput); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: protected void decode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf msg, java.util.List<Object> out) throws Exception protected internal override void Decode(ChannelHandlerContext ctx, ByteBuf msg, IList <object> @out) { @out.Add(FileChunk.Marshal().unmarshal(new NetworkReadableClosableChannelNetty4(msg))); }