Skip to content

Commit a52076d

Browse files
committed
Add test case for LArc lz4 compression method
1 parent 758daf7 commit a52076d

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

src/test/java/org/apache/commons/compress/archivers/lha/LhaArchiveInputStreamTest.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,33 @@ void testParseHeaderLevel0FileWithFoldersMsdos() throws IOException {
495495
}
496496
}
497497

498+
@Test
499+
void testParseHeaderLevel0Larc() throws IOException {
500+
// This archive was created using LArc 3.33 on MS-DOS
501+
try (LhaArchiveInputStream archive = LhaArchiveInputStream.builder().setInputStream(newInputStream("test-msdos-l0-lz4.lzs")).get()) {
502+
// Check file entry
503+
final LhaArchiveEntry entry = archive.getNextEntry();
504+
assertNotNull(entry);
505+
assertEquals("TEST1.TXT", entry.getName());
506+
assertFalse(entry.isDirectory());
507+
assertEquals(14, entry.getSize());
508+
assertEquals(1757247072000L, convertSystemTimeZoneDateToUTC(entry.getLastModifiedDate()).toInstant().toEpochMilli());
509+
assertEquals(ZonedDateTime.parse("2025-09-07T12:11:12Z"), convertSystemTimeZoneDateToUTC(entry.getLastModifiedDate()));
510+
assertEquals(14, entry.getCompressedSize());
511+
assertEquals("-lz4-", entry.getCompressionMethod());
512+
assertEquals(0xc9b4, entry.getCrcValue());
513+
assertNull(entry.getOsId());
514+
assertNull(entry.getUnixPermissionMode());
515+
assertNull(entry.getUnixGroupId());
516+
assertNull(entry.getUnixUserId());
517+
assertNull(entry.getMsdosFileAttributes());
518+
assertNull(entry.getHeaderCrc());
519+
520+
// No more entries expected
521+
assertNull(archive.getNextEntry());
522+
}
523+
}
524+
498525
@Test
499526
void testParseHeaderLevel1File() throws IOException {
500527
try (LhaArchiveInputStream archive = LhaArchiveInputStream.builder()
@@ -1444,6 +1471,16 @@ void testDecompressLh7() throws Exception {
14441471
}
14451472
}
14461473

1474+
@Test
1475+
void testDecompressLz4() throws Exception {
1476+
// This archive was created using LArc 3.33 on MS-DOS
1477+
try (LhaArchiveInputStream archive = LhaArchiveInputStream.builder().setInputStream(newInputStream("test-msdos-l0-lz4.lzs")).get()) {
1478+
final List<String> files = new ArrayList<>();
1479+
files.add("TEST1.TXT");
1480+
checkArchiveContent(archive, files);
1481+
}
1482+
}
1483+
14471484
@Test
14481485
void testMatches() {
14491486
byte[] data;
48 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)