@Test public void sendZipFileChunked() throws IOException { Path path = Files.createTempFile(null, ".zip"); Files.copy(this.getClass().getResourceAsStream("/zipFile.zip"), path, StandardCopyOption.REPLACE_EXISTING); path.toFile().deleteOnExit(); try (FileSystem zipFs = FileSystems.newFileSystem(path, null)) { Path fromZipFile = zipFs.getPath("/largeFile.txt"); long fileSize = Files.size(fromZipFile); assertSendFile(out -> out.sendFileChunked(fromZipFile, 0, fileSize)); } }
@Test public void sendFileChunked() throws IOException, URISyntaxException { Path largeFile = Paths.get(getClass().getResource("/largeFile.txt").toURI()); long fileSize = Files.size(largeFile); assertSendFile(out -> out.sendFileChunked(largeFile, 0, fileSize)); }
@Test public void sendFileChunkedOffset() throws IOException, URISyntaxException { Path largeFile = Paths.get(getClass().getResource("/largeFile.txt").toURI()); long fileSize = Files.size(largeFile); assertSendFile(out -> out.sendFileChunked(largeFile, 1024, fileSize - 1024), false, -1, (req, res) -> false, body -> assertThat(body).startsWith("<- 1024 mark here") .endsWith("End of File")); }