|
62 | 62 | import org.apache.commons.compress.utils.MultiReadOnlySeekableByteChannel; |
63 | 63 | import org.apache.commons.compress.utils.SeekableInMemoryByteChannel; |
64 | 64 | import org.apache.commons.io.IOUtils; |
| 65 | +import org.apache.commons.io.channels.ByteArraySeekableByteChannel; |
65 | 66 | import org.apache.commons.io.input.ChecksumInputStream; |
66 | 67 | import org.junit.jupiter.api.BeforeEach; |
67 | 68 | import org.junit.jupiter.api.Test; |
@@ -337,6 +338,14 @@ void test7zDeflateUnarchive() throws Exception { |
337 | 338 |
|
338 | 339 | @Test |
339 | 340 | void test7zMultiVolumeUnarchive() throws Exception { |
| 341 | + try (SevenZFile sevenZFile = SevenZFile.builder() |
| 342 | + .setChannel(MultiReadOnlySeekableByteChannel.forFiles(getFile("bla-multi.7z.001"), getFile("bla-multi.7z.002"))).get()) { |
| 343 | + test7zUnarchive(sevenZFile, SevenZMethod.LZMA2); |
| 344 | + } |
| 345 | + } |
| 346 | + |
| 347 | + @Test |
| 348 | + void test7zMultiVolumeUnarchiveDeprecated() throws Exception { |
340 | 349 | try (SevenZFile sevenZFile = SevenZFile.builder() |
341 | 350 | .setSeekableByteChannel(MultiReadOnlySeekableByteChannel.forFiles(getFile("bla-multi.7z.001"), getFile("bla-multi.7z.002"))).get()) { |
342 | 351 | test7zUnarchive(sevenZFile, SevenZMethod.LZMA2); |
@@ -539,6 +548,20 @@ void testGetDefaultName() throws Exception { |
539 | 548 |
|
540 | 549 | @Test |
541 | 550 | void testGetEntriesOfUnarchiveInMemory() throws IOException { |
| 551 | + final byte[] data = readAllBytes("bla.7z"); |
| 552 | + try (SevenZFile sevenZFile = SevenZFile.builder().setChannel(ByteArraySeekableByteChannel.wrap(data)).get()) { |
| 553 | + final Iterable<SevenZArchiveEntry> entries = sevenZFile.getEntries(); |
| 554 | + final Iterator<SevenZArchiveEntry> iter = entries.iterator(); |
| 555 | + SevenZArchiveEntry entry = iter.next(); |
| 556 | + assertEquals("test1.xml", entry.getName()); |
| 557 | + entry = iter.next(); |
| 558 | + assertEquals("test2.xml", entry.getName()); |
| 559 | + assertFalse(iter.hasNext()); |
| 560 | + } |
| 561 | + } |
| 562 | + |
| 563 | + @Test |
| 564 | + void testGetEntriesOfUnarchiveInMemoryDeprecacted() throws IOException { |
542 | 565 | final byte[] data = readAllBytes("bla.7z"); |
543 | 566 | try (SevenZFile sevenZFile = SevenZFile.builder().setSeekableByteChannel(new SeekableInMemoryByteChannel(data)).get()) { |
544 | 567 | final Iterable<SevenZArchiveEntry> entries = sevenZFile.getEntries(); |
|
0 commit comments