Check that all decompression algorithms throw IOException on failure

Signed-off-by: Graham <gpe@openrs2.dev>
Graham 4 years ago
parent 0d384fa8f2
commit d2ee9d3b8b
  1. 27
      cache/src/test/java/dev/openrs2/cache/Js5CompressionTest.kt
  2. BIN
      cache/src/test/resources/dev/openrs2/cache/compression/bzip2-corrupt.dat
  3. BIN
      cache/src/test/resources/dev/openrs2/cache/compression/gzip-corrupt.dat
  4. BIN
      cache/src/test/resources/dev/openrs2/cache/compression/lzma-corrupt.dat

@ -320,6 +320,33 @@ object Js5CompressionTest {
} }
} }
@Test
fun testBzip2Corrupt() {
read("bzip2-corrupt.dat").use { compressed ->
assertThrows<IOException> {
Js5Compression.uncompress(compressed).release()
}
}
}
@Test
fun testGzipCorrupt() {
read("gzip-corrupt.dat").use { compressed ->
assertThrows<IOException> {
Js5Compression.uncompress(compressed).release()
}
}
}
@Test
fun testLzmaCorrupt() {
read("lzma-corrupt.dat").use { compressed ->
assertThrows<IOException> {
Js5Compression.uncompress(compressed).release()
}
}
}
private fun read(name: String): ByteBuf { private fun read(name: String): ByteBuf {
Js5CompressionTest::class.java.getResourceAsStream("compression/$name").use { input -> Js5CompressionTest::class.java.getResourceAsStream("compression/$name").use { input ->
return Unpooled.wrappedBuffer(input.readAllBytes()) return Unpooled.wrappedBuffer(input.readAllBytes())

Loading…
Cancel
Save