MinimalZipArchive { public static List<MinimalZipEntry> listEntries(File file) throws IOException { try (RandomAccessFileInputStream in = new RandomAccessFileInputStream(file)) { return listEntriesInternal(in); } }  static List<MinimalZipEntry> listEntries(File file);  }
@Test public void testListEntries() throws IOException { List<MinimalZipEntry> parsedEntries = MinimalZipArchive.listEntries(tempFile); long lastSeenHeaderOffset = -1; for (int x = 0; x < UnitTestZipArchive.allEntriesInFileOrder.size(); x++) { UnitTestZipEntry expected = UnitTestZipArchive.allEntriesInFileOrder.get(x); MinimalZipEntry actual = parsedEntries.get(x); Assert.assertEquals(expected.path, actual.getFileName()); Assert.assertEquals(expected.level == 0 ? 0 : 8, actual.getCompressionMethod()); Assert.assertEquals(expected.getCompressedBinaryContent().length, actual.getCompressedSize()); Assert.assertEquals( expected.getUncompressedBinaryContent().length, actual.getUncompressedSize()); Assert.assertEquals(false, actual.getGeneralPurposeFlagBit11()); CRC32 crc32 = new CRC32(); crc32.update(expected.getUncompressedBinaryContent()); Assert.assertEquals(crc32.getValue(), actual.getCrc32OfUncompressedData()); Assert.assertTrue(actual.getFileOffsetOfLocalEntry() > lastSeenHeaderOffset); lastSeenHeaderOffset = actual.getFileOffsetOfLocalEntry(); byte[] expectedSignatureBlock = new byte[] {0x50, 0x4b, 0x03, 0x04}; for (int index = 0; index < 4; index++) { byte actualByte = unitTestZipArchive[((int) actual.getFileOffsetOfLocalEntry()) + index]; Assert.assertEquals(expectedSignatureBlock[index], actualByte); } byte[] expectedContent = expected.getCompressedBinaryContent(); int calculatedDataOffset = (int) actual.getFileOffsetOfCompressedData(); for (int index = 0; index < expectedContent.length; index++) { Assert.assertEquals( expectedContent[index], unitTestZipArchive[calculatedDataOffset + index]); } } }