diff --git a/cache/src/test/java/dev/openrs2/cache/Js5CompressionTest.kt b/cache/src/test/java/dev/openrs2/cache/Js5CompressionTest.kt index b39544343d..9d4b00fb3d 100644 --- a/cache/src/test/java/dev/openrs2/cache/Js5CompressionTest.kt +++ b/cache/src/test/java/dev/openrs2/cache/Js5CompressionTest.kt @@ -320,6 +320,33 @@ object Js5CompressionTest { } } + @Test + fun testBzip2Corrupt() { + read("bzip2-corrupt.dat").use { compressed -> + assertThrows { + Js5Compression.uncompress(compressed).release() + } + } + } + + @Test + fun testGzipCorrupt() { + read("gzip-corrupt.dat").use { compressed -> + assertThrows { + Js5Compression.uncompress(compressed).release() + } + } + } + + @Test + fun testLzmaCorrupt() { + read("lzma-corrupt.dat").use { compressed -> + assertThrows { + Js5Compression.uncompress(compressed).release() + } + } + } + private fun read(name: String): ByteBuf { Js5CompressionTest::class.java.getResourceAsStream("compression/$name").use { input -> return Unpooled.wrappedBuffer(input.readAllBytes()) diff --git a/cache/src/test/resources/dev/openrs2/cache/compression/bzip2-corrupt.dat b/cache/src/test/resources/dev/openrs2/cache/compression/bzip2-corrupt.dat new file mode 100644 index 0000000000..b6fd1229a8 Binary files /dev/null and b/cache/src/test/resources/dev/openrs2/cache/compression/bzip2-corrupt.dat differ diff --git a/cache/src/test/resources/dev/openrs2/cache/compression/gzip-corrupt.dat b/cache/src/test/resources/dev/openrs2/cache/compression/gzip-corrupt.dat new file mode 100644 index 0000000000..c24f0e8720 Binary files /dev/null and b/cache/src/test/resources/dev/openrs2/cache/compression/gzip-corrupt.dat differ diff --git a/cache/src/test/resources/dev/openrs2/cache/compression/lzma-corrupt.dat b/cache/src/test/resources/dev/openrs2/cache/compression/lzma-corrupt.dat new file mode 100644 index 0000000000..e2754a1988 Binary files /dev/null and b/cache/src/test/resources/dev/openrs2/cache/compression/lzma-corrupt.dat differ