Replace assertThrows with assertFailsWith

Signed-off-by: Graham <gpe@openrs2.org>
Graham 4 years ago
parent 410bf909ff
commit 30828308b2
  1. 24
      buffer/src/test/kotlin/org/openrs2/buffer/ByteBufExtensionsTest.kt
  2. 6
      cache/src/test/kotlin/org/openrs2/cache/BufferedFileChannelTest.kt
  3. 72
      cache/src/test/kotlin/org/openrs2/cache/DiskStoreTest.kt
  4. 50
      cache/src/test/kotlin/org/openrs2/cache/FlatFileStoreTest.kt
  5. 36
      cache/src/test/kotlin/org/openrs2/cache/Js5CompressionTest.kt
  6. 8
      cache/src/test/kotlin/org/openrs2/cache/Js5IndexTest.kt
  7. 42
      cache/src/test/kotlin/org/openrs2/cache/NamedEntryCollectionTest.kt
  8. 10
      db/src/test/kotlin/org/openrs2/db/BackoffStrategyTest.kt
  9. 10
      db/src/test/kotlin/org/openrs2/db/DatabaseTest.kt
  10. 8
      protocol/src/test/kotlin/org/openrs2/protocol/Rs2DecoderTest.kt
  11. 14
      protocol/src/test/kotlin/org/openrs2/protocol/Rs2EncoderTest.kt
  12. 4
      protocol/src/test/kotlin/org/openrs2/protocol/jaggrab/JaggrabRequestDecoderTest.kt
  13. 4
      protocol/src/test/kotlin/org/openrs2/protocol/js5/Js5RequestDecoderTest.kt
  14. 10
      protocol/src/test/kotlin/org/openrs2/protocol/js5/Js5ResponseDecoderTest.kt
  15. 4
      protocol/src/test/kotlin/org/openrs2/protocol/js5/Js5ResponseEncoderTest.kt
  16. 4
      util/src/test/kotlin/org/openrs2/util/collect/IterableUtilsTest.kt

@ -2,9 +2,9 @@ package org.openrs2.buffer
import io.netty.buffer.ByteBufAllocator import io.netty.buffer.ByteBufAllocator
import io.netty.buffer.Unpooled import io.netty.buffer.Unpooled
import org.junit.jupiter.api.assertThrows
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
import kotlin.test.assertFalse import kotlin.test.assertFalse
object ByteBufExtensionsTest { object ByteBufExtensionsTest {
@ -119,13 +119,13 @@ object ByteBufExtensionsTest {
} }
ByteBufAllocator.DEFAULT.buffer().use { buf -> ByteBufAllocator.DEFAULT.buffer().use { buf ->
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
buf.writeShortSmart(-0x4001) buf.writeShortSmart(-0x4001)
} }
} }
ByteBufAllocator.DEFAULT.buffer().use { buf -> ByteBufAllocator.DEFAULT.buffer().use { buf ->
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
buf.writeShortSmart(0x4000) buf.writeShortSmart(0x4000)
} }
} }
@ -209,13 +209,13 @@ object ByteBufExtensionsTest {
} }
ByteBufAllocator.DEFAULT.buffer().use { buf -> ByteBufAllocator.DEFAULT.buffer().use { buf ->
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
buf.writeUnsignedShortSmart(-0x1) buf.writeUnsignedShortSmart(-0x1)
} }
} }
ByteBufAllocator.DEFAULT.buffer().use { buf -> ByteBufAllocator.DEFAULT.buffer().use { buf ->
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
buf.writeUnsignedShortSmart(0x10000) buf.writeUnsignedShortSmart(0x10000)
} }
} }
@ -311,13 +311,13 @@ object ByteBufExtensionsTest {
} }
ByteBufAllocator.DEFAULT.buffer().use { buf -> ByteBufAllocator.DEFAULT.buffer().use { buf ->
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
buf.writeIntSmart(-0x40000001) buf.writeIntSmart(-0x40000001)
} }
} }
ByteBufAllocator.DEFAULT.buffer().use { buf -> ByteBufAllocator.DEFAULT.buffer().use { buf ->
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
buf.writeIntSmart(0x40000000) buf.writeIntSmart(0x40000000)
} }
} }
@ -401,7 +401,7 @@ object ByteBufExtensionsTest {
} }
ByteBufAllocator.DEFAULT.buffer().use { buf -> ByteBufAllocator.DEFAULT.buffer().use { buf ->
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
buf.writeUnsignedIntSmart(0x80000000.toInt()) buf.writeUnsignedIntSmart(0x80000000.toInt())
} }
} }
@ -450,19 +450,19 @@ object ByteBufExtensionsTest {
@Test @Test
fun testCrc32Bounds() { fun testCrc32Bounds() {
assertThrows<IndexOutOfBoundsException> { assertFailsWith<IndexOutOfBoundsException> {
Unpooled.EMPTY_BUFFER.crc32(-1, 0) Unpooled.EMPTY_BUFFER.crc32(-1, 0)
} }
assertThrows<IndexOutOfBoundsException> { assertFailsWith<IndexOutOfBoundsException> {
Unpooled.EMPTY_BUFFER.crc32(0, -1) Unpooled.EMPTY_BUFFER.crc32(0, -1)
} }
assertThrows<IndexOutOfBoundsException> { assertFailsWith<IndexOutOfBoundsException> {
Unpooled.EMPTY_BUFFER.crc32(1, 0) Unpooled.EMPTY_BUFFER.crc32(1, 0)
} }
assertThrows<IndexOutOfBoundsException> { assertFailsWith<IndexOutOfBoundsException> {
Unpooled.EMPTY_BUFFER.crc32(0, 1) Unpooled.EMPTY_BUFFER.crc32(0, 1)
} }
} }

@ -4,7 +4,6 @@ import com.google.common.jimfs.Configuration
import com.google.common.jimfs.Jimfs import com.google.common.jimfs.Jimfs
import io.netty.buffer.ByteBufAllocator import io.netty.buffer.ByteBufAllocator
import io.netty.buffer.Unpooled import io.netty.buffer.Unpooled
import org.junit.jupiter.api.assertThrows
import org.openrs2.buffer.copiedBuffer import org.openrs2.buffer.copiedBuffer
import org.openrs2.buffer.use import org.openrs2.buffer.use
import org.openrs2.buffer.wrappedBuffer import org.openrs2.buffer.wrappedBuffer
@ -16,6 +15,7 @@ import java.nio.file.StandardOpenOption.READ
import java.nio.file.StandardOpenOption.WRITE import java.nio.file.StandardOpenOption.WRITE
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
object BufferedFileChannelTest { object BufferedFileChannelTest {
@Test @Test
@ -197,7 +197,7 @@ object BufferedFileChannelTest {
BufferedFileChannel(FileChannel.open(path, CREATE, READ, WRITE), 8, 8).use { channel -> BufferedFileChannel(FileChannel.open(path, CREATE, READ, WRITE), 8, 8).use { channel ->
ByteBufAllocator.DEFAULT.buffer(1, 1).use { buf -> ByteBufAllocator.DEFAULT.buffer(1, 1).use { buf ->
assertThrows<EOFException> { assertFailsWith<EOFException> {
channel.read(0, buf, buf.writableBytes()) channel.read(0, buf, buf.writableBytes())
} }
} }
@ -213,7 +213,7 @@ object BufferedFileChannelTest {
BufferedFileChannel(FileChannel.open(path, READ), 8, 8).use { channel -> BufferedFileChannel(FileChannel.open(path, READ), 8, 8).use { channel ->
ByteBufAllocator.DEFAULT.buffer(15, 15).use { buf -> ByteBufAllocator.DEFAULT.buffer(15, 15).use { buf ->
assertThrows<EOFException> { assertFailsWith<EOFException> {
channel.read(0, buf, buf.writableBytes()) channel.read(0, buf, buf.writableBytes())
} }
} }

@ -3,7 +3,6 @@ package org.openrs2.cache
import com.google.common.jimfs.Configuration import com.google.common.jimfs.Configuration
import com.google.common.jimfs.Jimfs import com.google.common.jimfs.Jimfs
import io.netty.buffer.Unpooled import io.netty.buffer.Unpooled
import org.junit.jupiter.api.assertThrows
import org.openrs2.buffer.copiedBuffer import org.openrs2.buffer.copiedBuffer
import org.openrs2.buffer.use import org.openrs2.buffer.use
import org.openrs2.util.io.recursiveCopy import org.openrs2.util.io.recursiveCopy
@ -12,6 +11,7 @@ import java.io.FileNotFoundException
import java.nio.file.Paths import java.nio.file.Paths
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
import kotlin.test.assertFalse import kotlin.test.assertFalse
import kotlin.test.assertTrue import kotlin.test.assertTrue
@ -21,85 +21,85 @@ object DiskStoreTest {
@Test @Test
fun testBounds() { fun testBounds() {
readTest("empty") { store -> readTest("empty") { store ->
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.exists(-1) store.exists(-1)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.exists(256) store.exists(256)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.list(-1) store.list(-1)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.list(256) store.list(256)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.exists(-1, 0) store.exists(-1, 0)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.exists(256, 0) store.exists(256, 0)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.exists(0, -1) store.exists(0, -1)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.read(-1, 0).release() store.read(-1, 0).release()
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.read(256, 0).release() store.read(256, 0).release()
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.read(0, -1).release() store.read(0, -1).release()
} }
} }
writeTest("empty") { store -> writeTest("empty") { store ->
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.create(-1) store.create(-1)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.create(256) store.create(256)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.write(-1, 0, Unpooled.EMPTY_BUFFER) store.write(-1, 0, Unpooled.EMPTY_BUFFER)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.write(256, 0, Unpooled.EMPTY_BUFFER) store.write(256, 0, Unpooled.EMPTY_BUFFER)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.write(0, -1, Unpooled.EMPTY_BUFFER) store.write(0, -1, Unpooled.EMPTY_BUFFER)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.remove(-1) store.remove(-1)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.remove(256) store.remove(256)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.remove(-1, 0) store.remove(-1, 0)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.remove(256, 0) store.remove(256, 0)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.remove(0, -1) store.remove(0, -1)
} }
} }
@ -200,7 +200,7 @@ object DiskStoreTest {
@Test @Test
fun testListNonExistent() { fun testListNonExistent() {
readTest("empty") { store -> readTest("empty") { store ->
assertThrows<FileNotFoundException> { assertFailsWith<FileNotFoundException> {
store.list(0) store.list(0)
} }
} }
@ -275,15 +275,15 @@ object DiskStoreTest {
@Test @Test
fun testReadNonExistent() { fun testReadNonExistent() {
readTest("single-block") { store -> readTest("single-block") { store ->
assertThrows<FileNotFoundException> { assertFailsWith<FileNotFoundException> {
store.read(0, 0) store.read(0, 0)
} }
assertThrows<FileNotFoundException> { assertFailsWith<FileNotFoundException> {
store.read(255, 0) store.read(255, 0)
} }
assertThrows<FileNotFoundException> { assertFailsWith<FileNotFoundException> {
store.read(255, 2) store.read(255, 2)
} }
} }
@ -498,67 +498,67 @@ object DiskStoreTest {
@Test @Test
fun testReadCorrupt() { fun testReadCorrupt() {
readTest("corrupt-eof-late") { store -> readTest("corrupt-eof-late") { store ->
assertThrows<StoreCorruptException> { assertFailsWith<StoreCorruptException> {
store.read(255, 1).release() store.read(255, 1).release()
} }
} }
readTest("corrupt-first-eof-early") { store -> readTest("corrupt-first-eof-early") { store ->
assertThrows<StoreCorruptException> { assertFailsWith<StoreCorruptException> {
store.read(255, 1).release() store.read(255, 1).release()
} }
} }
readTest("corrupt-first-invalid-archive") { store -> readTest("corrupt-first-invalid-archive") { store ->
assertThrows<StoreCorruptException> { assertFailsWith<StoreCorruptException> {
store.read(255, 1).release() store.read(255, 1).release()
} }
} }
readTest("corrupt-first-invalid-block-number") { store -> readTest("corrupt-first-invalid-block-number") { store ->
assertThrows<StoreCorruptException> { assertFailsWith<StoreCorruptException> {
store.read(255, 1).release() store.read(255, 1).release()
} }
} }
readTest("corrupt-first-invalid-group") { store -> readTest("corrupt-first-invalid-group") { store ->
assertThrows<StoreCorruptException> { assertFailsWith<StoreCorruptException> {
store.read(255, 1).release() store.read(255, 1).release()
} }
} }
readTest("corrupt-first-outside-data-file") { store -> readTest("corrupt-first-outside-data-file") { store ->
assertThrows<StoreCorruptException> { assertFailsWith<StoreCorruptException> {
store.read(255, 1).release() store.read(255, 1).release()
} }
} }
readTest("corrupt-second-eof-early") { store -> readTest("corrupt-second-eof-early") { store ->
assertThrows<StoreCorruptException> { assertFailsWith<StoreCorruptException> {
store.read(255, 1).release() store.read(255, 1).release()
} }
} }
readTest("corrupt-second-invalid-archive") { store -> readTest("corrupt-second-invalid-archive") { store ->
assertThrows<StoreCorruptException> { assertFailsWith<StoreCorruptException> {
store.read(255, 1).release() store.read(255, 1).release()
} }
} }
readTest("corrupt-second-invalid-block-number") { store -> readTest("corrupt-second-invalid-block-number") { store ->
assertThrows<StoreCorruptException> { assertFailsWith<StoreCorruptException> {
store.read(255, 1).release() store.read(255, 1).release()
} }
} }
readTest("corrupt-second-invalid-group") { store -> readTest("corrupt-second-invalid-group") { store ->
assertThrows<StoreCorruptException> { assertFailsWith<StoreCorruptException> {
store.read(255, 1).release() store.read(255, 1).release()
} }
} }
readTest("corrupt-second-outside-data-file") { store -> readTest("corrupt-second-outside-data-file") { store ->
assertThrows<StoreCorruptException> { assertFailsWith<StoreCorruptException> {
store.read(255, 1).release() store.read(255, 1).release()
} }
} }

@ -3,7 +3,6 @@ package org.openrs2.cache
import com.google.common.jimfs.Configuration import com.google.common.jimfs.Configuration
import com.google.common.jimfs.Jimfs import com.google.common.jimfs.Jimfs
import io.netty.buffer.Unpooled import io.netty.buffer.Unpooled
import org.junit.jupiter.api.assertThrows
import org.openrs2.buffer.copiedBuffer import org.openrs2.buffer.copiedBuffer
import org.openrs2.buffer.use import org.openrs2.buffer.use
import org.openrs2.util.io.recursiveCopy import org.openrs2.util.io.recursiveCopy
@ -13,6 +12,7 @@ import java.nio.file.Path
import java.nio.file.Paths import java.nio.file.Paths
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
import kotlin.test.assertFalse import kotlin.test.assertFalse
import kotlin.test.assertTrue import kotlin.test.assertTrue
@ -23,85 +23,85 @@ object FlatFileStoreTest {
@Test @Test
fun testBounds() { fun testBounds() {
readTest("empty") { store -> readTest("empty") { store ->
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.exists(-1) store.exists(-1)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.exists(256) store.exists(256)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.list(-1) store.list(-1)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.list(256) store.list(256)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.exists(-1, 0) store.exists(-1, 0)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.exists(256, 0) store.exists(256, 0)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.exists(0, -1) store.exists(0, -1)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.read(-1, 0).release() store.read(-1, 0).release()
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.read(256, 0).release() store.read(256, 0).release()
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.read(0, -1).release() store.read(0, -1).release()
} }
} }
writeTest("empty") { store -> writeTest("empty") { store ->
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.create(-1) store.create(-1)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.create(256) store.create(256)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.write(-1, 0, Unpooled.EMPTY_BUFFER) store.write(-1, 0, Unpooled.EMPTY_BUFFER)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.write(256, 0, Unpooled.EMPTY_BUFFER) store.write(256, 0, Unpooled.EMPTY_BUFFER)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.write(0, -1, Unpooled.EMPTY_BUFFER) store.write(0, -1, Unpooled.EMPTY_BUFFER)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.remove(-1) store.remove(-1)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.remove(256) store.remove(256)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.remove(-1, 0) store.remove(-1, 0)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.remove(256, 0) store.remove(256, 0)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.remove(0, -1) store.remove(0, -1)
} }
} }
@ -142,11 +142,11 @@ object FlatFileStoreTest {
assertEquals(listOf(0, 1), store.list(0)) assertEquals(listOf(0, 1), store.list(0))
assertEquals(listOf(0, 65536), store.list(255)) assertEquals(listOf(0, 65536), store.list(255))
assertThrows<FileNotFoundException> { assertFailsWith<FileNotFoundException> {
store.list(1) store.list(1)
} }
assertThrows<FileNotFoundException> { assertFailsWith<FileNotFoundException> {
store.list(254) store.list(254)
} }
} }
@ -174,11 +174,11 @@ object FlatFileStoreTest {
assertEquals(Unpooled.EMPTY_BUFFER, actual) assertEquals(Unpooled.EMPTY_BUFFER, actual)
} }
assertThrows<FileNotFoundException> { assertFailsWith<FileNotFoundException> {
store.read(0, 2).release() store.read(0, 2).release()
} }
assertThrows<FileNotFoundException> { assertFailsWith<FileNotFoundException> {
store.read(1, 0).release() store.read(1, 0).release()
} }

@ -2,13 +2,13 @@ package org.openrs2.cache
import io.netty.buffer.ByteBuf import io.netty.buffer.ByteBuf
import io.netty.buffer.Unpooled import io.netty.buffer.Unpooled
import org.junit.jupiter.api.assertThrows
import org.openrs2.buffer.copiedBuffer import org.openrs2.buffer.copiedBuffer
import org.openrs2.buffer.use import org.openrs2.buffer.use
import org.openrs2.crypto.XteaKey import org.openrs2.crypto.XteaKey
import java.io.IOException import java.io.IOException
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
import kotlin.test.assertFalse import kotlin.test.assertFalse
import kotlin.test.assertNotEquals import kotlin.test.assertNotEquals
import kotlin.test.assertTrue import kotlin.test.assertTrue
@ -264,11 +264,11 @@ object Js5CompressionTest {
@Test @Test
fun testInvalidType() { fun testInvalidType() {
read("invalid-type.dat").use { compressed -> read("invalid-type.dat").use { compressed ->
assertThrows<IOException> { assertFailsWith<IOException> {
Js5Compression.uncompress(compressed.slice()).release() Js5Compression.uncompress(compressed.slice()).release()
} }
assertThrows<IOException> { assertFailsWith<IOException> {
Js5Compression.isKeyValid(compressed.slice(), XteaKey.ZERO) Js5Compression.isKeyValid(compressed.slice(), XteaKey.ZERO)
} }
} }
@ -277,11 +277,11 @@ object Js5CompressionTest {
@Test @Test
fun testInvalidLength() { fun testInvalidLength() {
read("invalid-length.dat").use { compressed -> read("invalid-length.dat").use { compressed ->
assertThrows<IOException> { assertFailsWith<IOException> {
Js5Compression.uncompress(compressed.slice()).release() Js5Compression.uncompress(compressed.slice()).release()
} }
assertThrows<IOException> { assertFailsWith<IOException> {
Js5Compression.isKeyValid(compressed.slice(), XteaKey.ZERO) Js5Compression.isKeyValid(compressed.slice(), XteaKey.ZERO)
} }
} }
@ -290,7 +290,7 @@ object Js5CompressionTest {
@Test @Test
fun testInvalidUncompressedLength() { fun testInvalidUncompressedLength() {
read("invalid-uncompressed-length.dat").use { compressed -> read("invalid-uncompressed-length.dat").use { compressed ->
assertThrows<IOException> { assertFailsWith<IOException> {
Js5Compression.uncompress(compressed.slice()).release() Js5Compression.uncompress(compressed.slice()).release()
} }
@ -301,7 +301,7 @@ object Js5CompressionTest {
@Test @Test
fun testNoneEof() { fun testNoneEof() {
read("none-eof.dat").use { compressed -> read("none-eof.dat").use { compressed ->
assertThrows<IOException> { assertFailsWith<IOException> {
Js5Compression.uncompress(compressed).release() Js5Compression.uncompress(compressed).release()
} }
} }
@ -310,7 +310,7 @@ object Js5CompressionTest {
@Test @Test
fun testBzip2Eof() { fun testBzip2Eof() {
read("bzip2-eof.dat").use { compressed -> read("bzip2-eof.dat").use { compressed ->
assertThrows<IOException> { assertFailsWith<IOException> {
Js5Compression.uncompress(compressed.slice()).release() Js5Compression.uncompress(compressed.slice()).release()
} }
@ -321,7 +321,7 @@ object Js5CompressionTest {
@Test @Test
fun testGzipEof() { fun testGzipEof() {
read("gzip-eof.dat").use { compressed -> read("gzip-eof.dat").use { compressed ->
assertThrows<IOException> { assertFailsWith<IOException> {
Js5Compression.uncompress(compressed.slice()).release() Js5Compression.uncompress(compressed.slice()).release()
} }
@ -332,7 +332,7 @@ object Js5CompressionTest {
@Test @Test
fun testLzmaEof() { fun testLzmaEof() {
read("lzma-eof.dat").use { compressed -> read("lzma-eof.dat").use { compressed ->
assertThrows<IOException> { assertFailsWith<IOException> {
Js5Compression.uncompress(compressed.slice()).release() Js5Compression.uncompress(compressed.slice()).release()
} }
@ -343,7 +343,7 @@ object Js5CompressionTest {
@Test @Test
fun testBzip2Corrupt() { fun testBzip2Corrupt() {
read("bzip2-corrupt.dat").use { compressed -> read("bzip2-corrupt.dat").use { compressed ->
assertThrows<IOException> { assertFailsWith<IOException> {
Js5Compression.uncompress(compressed.slice()).release() Js5Compression.uncompress(compressed.slice()).release()
} }
@ -354,7 +354,7 @@ object Js5CompressionTest {
@Test @Test
fun testGzipCorrupt() { fun testGzipCorrupt() {
read("gzip-corrupt.dat").use { compressed -> read("gzip-corrupt.dat").use { compressed ->
assertThrows<IOException> { assertFailsWith<IOException> {
Js5Compression.uncompress(compressed.slice()).release() Js5Compression.uncompress(compressed.slice()).release()
} }
@ -365,7 +365,7 @@ object Js5CompressionTest {
@Test @Test
fun testLzmaCorrupt() { fun testLzmaCorrupt() {
read("lzma-corrupt.dat").use { compressed -> read("lzma-corrupt.dat").use { compressed ->
assertThrows<IOException> { assertFailsWith<IOException> {
Js5Compression.uncompress(compressed.slice()).release() Js5Compression.uncompress(compressed.slice()).release()
} }
@ -461,7 +461,7 @@ object Js5CompressionTest {
@Test @Test
fun testKeyValidShorterThanTwoBlocks() { fun testKeyValidShorterThanTwoBlocks() {
read("shorter-than-two-blocks.dat").use { compressed -> read("shorter-than-two-blocks.dat").use { compressed ->
assertThrows<IOException> { assertFailsWith<IOException> {
Js5Compression.isKeyValid(compressed, XteaKey.ZERO) Js5Compression.isKeyValid(compressed, XteaKey.ZERO)
} }
} }
@ -470,11 +470,11 @@ object Js5CompressionTest {
@Test @Test
fun testCompressedUnderflow() { fun testCompressedUnderflow() {
read("compressed-underflow.dat").use { compressed -> read("compressed-underflow.dat").use { compressed ->
assertThrows<IOException> { assertFailsWith<IOException> {
Js5Compression.uncompress(compressed.slice()).release() Js5Compression.uncompress(compressed.slice()).release()
} }
assertThrows<IOException> { assertFailsWith<IOException> {
Js5Compression.isKeyValid(compressed.slice(), XteaKey.ZERO) Js5Compression.isKeyValid(compressed.slice(), XteaKey.ZERO)
} }
} }
@ -483,7 +483,7 @@ object Js5CompressionTest {
@Test @Test
fun testUncompressedOverflow() { fun testUncompressedOverflow() {
read("uncompressed-overflow.dat").use { compressed -> read("uncompressed-overflow.dat").use { compressed ->
assertThrows<IOException> { assertFailsWith<IOException> {
Js5Compression.uncompress(compressed).release() Js5Compression.uncompress(compressed).release()
} }
} }
@ -492,7 +492,7 @@ object Js5CompressionTest {
@Test @Test
fun testUncompressedUnderflow() { fun testUncompressedUnderflow() {
read("uncompressed-underflow.dat").use { compressed -> read("uncompressed-underflow.dat").use { compressed ->
assertThrows<IOException> { assertFailsWith<IOException> {
Js5Compression.uncompress(compressed).release() Js5Compression.uncompress(compressed).release()
} }
} }

@ -4,12 +4,12 @@ import io.netty.buffer.ByteBuf
import io.netty.buffer.ByteBufAllocator import io.netty.buffer.ByteBufAllocator
import io.netty.buffer.ByteBufUtil import io.netty.buffer.ByteBufUtil
import io.netty.buffer.Unpooled import io.netty.buffer.Unpooled
import org.junit.jupiter.api.assertThrows
import org.openrs2.buffer.use import org.openrs2.buffer.use
import org.openrs2.buffer.wrappedBuffer import org.openrs2.buffer.wrappedBuffer
import org.openrs2.util.krHashCode import org.openrs2.util.krHashCode
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
import kotlin.test.assertFalse import kotlin.test.assertFalse
import kotlin.test.assertNull import kotlin.test.assertNull
import kotlin.test.assertTrue import kotlin.test.assertTrue
@ -130,13 +130,13 @@ object Js5IndexTest {
@Test @Test
fun testReadUnsupportedProtocol() { fun testReadUnsupportedProtocol() {
wrappedBuffer(4).use { buf -> wrappedBuffer(4).use { buf ->
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
Js5Index.read(buf) Js5Index.read(buf)
} }
} }
wrappedBuffer(8).use { buf -> wrappedBuffer(8).use { buf ->
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
Js5Index.read(buf) Js5Index.read(buf)
} }
} }
@ -228,7 +228,7 @@ object Js5IndexTest {
index.createOrGet(65536) index.createOrGet(65536)
ByteBufAllocator.DEFAULT.buffer().use { buf -> ByteBufAllocator.DEFAULT.buffer().use { buf ->
assertThrows<IllegalStateException> { assertFailsWith<IllegalStateException> {
index.write(buf) index.write(buf)
} }
} }

@ -1,9 +1,9 @@
package org.openrs2.cache package org.openrs2.cache
import org.junit.jupiter.api.assertThrows
import org.openrs2.util.krHashCode import org.openrs2.util.krHashCode
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
import kotlin.test.assertFalse import kotlin.test.assertFalse
import kotlin.test.assertNull import kotlin.test.assertNull
import kotlin.test.assertTrue import kotlin.test.assertTrue
@ -33,35 +33,35 @@ object NamedEntryCollectionTest {
fun testBounds() { fun testBounds() {
val collection = TestCollection() val collection = TestCollection()
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
-1 in collection -1 in collection
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
collection.containsNamed(-1) collection.containsNamed(-1)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
collection[-1] collection[-1]
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
collection.getNamed(-1) collection.getNamed(-1)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
collection.createOrGet(-1) collection.createOrGet(-1)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
collection.createOrGetNamed(-1) collection.createOrGetNamed(-1)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
collection.remove(-1) collection.remove(-1)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
collection.removeNamed(-1) collection.removeNamed(-1)
} }
} }
@ -590,17 +590,17 @@ object NamedEntryCollectionTest {
val it = collection.iterator() val it = collection.iterator()
assertThrows<IllegalStateException> { assertFailsWith<IllegalStateException> {
it.remove() it.remove()
} }
assertFalse(it.hasNext()) assertFalse(it.hasNext())
assertThrows<NoSuchElementException> { assertFailsWith<NoSuchElementException> {
it.next() it.next()
} }
assertThrows<IllegalStateException> { assertFailsWith<IllegalStateException> {
it.remove() it.remove()
} }
} }
@ -615,7 +615,7 @@ object NamedEntryCollectionTest {
val it = collection.iterator() val it = collection.iterator()
assertThrows<IllegalStateException> { assertFailsWith<IllegalStateException> {
it.remove() it.remove()
} }
@ -624,11 +624,11 @@ object NamedEntryCollectionTest {
assertFalse(it.hasNext()) assertFalse(it.hasNext())
assertThrows<NoSuchElementException> { assertFailsWith<NoSuchElementException> {
it.next() it.next()
} }
assertThrows<IllegalStateException> { assertFailsWith<IllegalStateException> {
it.remove() it.remove()
} }
} }
@ -647,7 +647,7 @@ object NamedEntryCollectionTest {
val it = collection.iterator() val it = collection.iterator()
assertThrows<IllegalStateException> { assertFailsWith<IllegalStateException> {
it.remove() it.remove()
} }
@ -659,11 +659,11 @@ object NamedEntryCollectionTest {
assertFalse(it.hasNext()) assertFalse(it.hasNext())
assertThrows<NoSuchElementException> { assertFailsWith<NoSuchElementException> {
it.next() it.next()
} }
assertThrows<IllegalStateException> { assertFailsWith<IllegalStateException> {
it.remove() it.remove()
} }
} }
@ -683,7 +683,7 @@ object NamedEntryCollectionTest {
it.remove() it.remove()
assertThrows<IllegalStateException> { assertFailsWith<IllegalStateException> {
it.remove() it.remove()
} }
@ -713,7 +713,7 @@ object NamedEntryCollectionTest {
it.remove() it.remove()
assertThrows<IllegalStateException> { assertFailsWith<IllegalStateException> {
it.remove() it.remove()
} }
@ -722,7 +722,7 @@ object NamedEntryCollectionTest {
it.remove() it.remove()
assertThrows<IllegalStateException> { assertFailsWith<IllegalStateException> {
it.remove() it.remove()
} }

@ -1,8 +1,8 @@
package org.openrs2.db package org.openrs2.db
import org.junit.jupiter.api.assertThrows
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
object BackoffStrategyTest { object BackoffStrategyTest {
@Test @Test
@ -13,22 +13,22 @@ object BackoffStrategyTest {
assertEquals(1000, strategy.getDelay(1)) assertEquals(1000, strategy.getDelay(1))
assertEquals(1000, strategy.getDelay(2)) assertEquals(1000, strategy.getDelay(2))
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
strategy.getDelay(-1) strategy.getDelay(-1)
} }
} }
@Test @Test
fun testBinaryExponentialBackoff() { fun testBinaryExponentialBackoff() {
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
BinaryExponentialBackoffStrategy(0, 1) BinaryExponentialBackoffStrategy(0, 1)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
BinaryExponentialBackoffStrategy(1, 0) BinaryExponentialBackoffStrategy(1, 0)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
BinaryExponentialBackoffStrategy(1, 1).getDelay(-1) BinaryExponentialBackoffStrategy(1, 1).getDelay(-1)
} }
} }

@ -3,10 +3,10 @@ package org.openrs2.db
import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runBlockingTest import kotlinx.coroutines.test.runBlockingTest
import org.h2.jdbcx.JdbcDataSource import org.h2.jdbcx.JdbcDataSource
import org.junit.jupiter.api.assertThrows
import java.sql.SQLException import java.sql.SQLException
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
import kotlin.test.assertTrue import kotlin.test.assertTrue
@ExperimentalCoroutinesApi @ExperimentalCoroutinesApi
@ -35,7 +35,7 @@ object DatabaseTest {
@Test @Test
fun testBounds() { fun testBounds() {
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
Database(dataSource, attempts = 0) Database(dataSource, attempts = 0)
} }
} }
@ -86,7 +86,7 @@ object DatabaseTest {
fun testDeadlockFailure() { fun testDeadlockFailure() {
var attempts = 0 var attempts = 0
assertThrows<DeadlockException> { assertFailsWith<DeadlockException> {
runBlockingTest { runBlockingTest {
database.execute<Unit> { database.execute<Unit> {
attempts++ attempts++
@ -102,7 +102,7 @@ object DatabaseTest {
fun testNonDeadlockFailure() { fun testNonDeadlockFailure() {
var attempts = 0 var attempts = 0
assertThrows<TestException> { assertFailsWith<TestException> {
runBlockingTest { runBlockingTest {
database.execute<Unit> { database.execute<Unit> {
attempts++ attempts++
@ -168,7 +168,7 @@ object DatabaseTest {
fun testNonDeadlockNextChain() { fun testNonDeadlockNextChain() {
var attempts = 0 var attempts = 0
assertThrows<NonDeadlockException> { assertFailsWith<NonDeadlockException> {
runBlockingTest { runBlockingTest {
database.execute<Unit> { database.execute<Unit> {
attempts++ attempts++

@ -3,10 +3,10 @@ package org.openrs2.protocol
import io.netty.buffer.Unpooled import io.netty.buffer.Unpooled
import io.netty.channel.embedded.EmbeddedChannel import io.netty.channel.embedded.EmbeddedChannel
import io.netty.handler.codec.DecoderException import io.netty.handler.codec.DecoderException
import org.junit.jupiter.api.assertThrows
import org.openrs2.buffer.wrappedBuffer import org.openrs2.buffer.wrappedBuffer
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
object Rs2DecoderTest { object Rs2DecoderTest {
@Test @Test
@ -28,7 +28,7 @@ object Rs2DecoderTest {
fun testUnsupported() { fun testUnsupported() {
val channel = EmbeddedChannel(Rs2Decoder(Protocol())) val channel = EmbeddedChannel(Rs2Decoder(Protocol()))
assertThrows<DecoderException> { assertFailsWith<DecoderException> {
channel.writeInbound(wrappedBuffer(0)) channel.writeInbound(wrappedBuffer(0))
} }
} }
@ -53,7 +53,7 @@ object Rs2DecoderTest {
channel.writeInbound(wrappedBuffer(0, 0x11, 0x22, 0x33, 0x44)) channel.writeInbound(wrappedBuffer(0, 0x11, 0x22, 0x33, 0x44))
channel.readInbound<Packet>() channel.readInbound<Packet>()
assertThrows<DecoderException> { assertFailsWith<DecoderException> {
channel.writeInbound(wrappedBuffer(5)) channel.writeInbound(wrappedBuffer(5))
} }
@ -64,7 +64,7 @@ object Rs2DecoderTest {
val actual = channel.readInbound<Packet>() val actual = channel.readInbound<Packet>()
assertEquals(EmptyPacket, actual) assertEquals(EmptyPacket, actual)
assertThrows<DecoderException> { assertFailsWith<DecoderException> {
channel.writeInbound(wrappedBuffer(0, 0x11, 0x22, 0x33, 0x44)) channel.writeInbound(wrappedBuffer(0, 0x11, 0x22, 0x33, 0x44))
} }
} }

@ -4,11 +4,11 @@ import io.netty.buffer.ByteBuf
import io.netty.buffer.Unpooled import io.netty.buffer.Unpooled
import io.netty.channel.embedded.EmbeddedChannel import io.netty.channel.embedded.EmbeddedChannel
import io.netty.handler.codec.EncoderException import io.netty.handler.codec.EncoderException
import org.junit.jupiter.api.assertThrows
import org.openrs2.buffer.use import org.openrs2.buffer.use
import org.openrs2.buffer.wrappedBuffer import org.openrs2.buffer.wrappedBuffer
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
object Rs2EncoderTest { object Rs2EncoderTest {
@Test @Test
@ -36,11 +36,11 @@ object Rs2EncoderTest {
channel.writeOutbound(VariableShortPacket(ByteArray(65535))) channel.writeOutbound(VariableShortPacket(ByteArray(65535)))
channel.readOutbound<ByteBuf>().release() channel.readOutbound<ByteBuf>().release()
assertThrows<EncoderException> { assertFailsWith<EncoderException> {
channel.writeOutbound(VariableBytePacket(ByteArray(256))) channel.writeOutbound(VariableBytePacket(ByteArray(256)))
} }
assertThrows<EncoderException> { assertFailsWith<EncoderException> {
channel.writeOutbound(VariableShortPacket(ByteArray(65536))) channel.writeOutbound(VariableShortPacket(ByteArray(65536)))
} }
} }
@ -49,7 +49,7 @@ object Rs2EncoderTest {
fun testUnsupported() { fun testUnsupported() {
val channel = EmbeddedChannel(Rs2Encoder(Protocol())) val channel = EmbeddedChannel(Rs2Encoder(Protocol()))
assertThrows<EncoderException> { assertFailsWith<EncoderException> {
channel.writeOutbound(FixedPacket(0x11223344)) channel.writeOutbound(FixedPacket(0x11223344))
} }
} }
@ -58,7 +58,7 @@ object Rs2EncoderTest {
fun testLengthMismatch() { fun testLengthMismatch() {
val channel = EmbeddedChannel(Rs2Encoder(Protocol(LengthMismatchPacketCodec))) val channel = EmbeddedChannel(Rs2Encoder(Protocol(LengthMismatchPacketCodec)))
assertThrows<EncoderException> { assertFailsWith<EncoderException> {
channel.writeOutbound(FixedPacket(0x11223344)) channel.writeOutbound(FixedPacket(0x11223344))
} }
} }
@ -92,7 +92,7 @@ object Rs2EncoderTest {
channel.writeOutbound(FixedPacket(0x11223344)) channel.writeOutbound(FixedPacket(0x11223344))
channel.readOutbound<ByteBuf>().release() channel.readOutbound<ByteBuf>().release()
assertThrows<EncoderException> { assertFailsWith<EncoderException> {
channel.writeOutbound(EmptyPacket) channel.writeOutbound(EmptyPacket)
} }
@ -106,7 +106,7 @@ object Rs2EncoderTest {
} }
} }
assertThrows<EncoderException> { assertFailsWith<EncoderException> {
channel.writeOutbound(FixedPacket(0x11223344)) channel.writeOutbound(FixedPacket(0x11223344))
} }
} }

@ -2,9 +2,9 @@ package org.openrs2.protocol.jaggrab
import io.netty.channel.embedded.EmbeddedChannel import io.netty.channel.embedded.EmbeddedChannel
import io.netty.handler.codec.DecoderException import io.netty.handler.codec.DecoderException
import org.junit.jupiter.api.assertThrows
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
object JaggrabRequestDecoderTest { object JaggrabRequestDecoderTest {
@Test @Test
@ -20,7 +20,7 @@ object JaggrabRequestDecoderTest {
fun testInvalid() { fun testInvalid() {
val channel = EmbeddedChannel(JaggrabRequestDecoder) val channel = EmbeddedChannel(JaggrabRequestDecoder)
assertThrows<DecoderException> { assertFailsWith<DecoderException> {
channel.writeInbound("Hello, world!") channel.writeInbound("Hello, world!")
} }
} }

@ -3,10 +3,10 @@ package org.openrs2.protocol.js5
import io.netty.buffer.Unpooled import io.netty.buffer.Unpooled
import io.netty.channel.embedded.EmbeddedChannel import io.netty.channel.embedded.EmbeddedChannel
import io.netty.handler.codec.DecoderException import io.netty.handler.codec.DecoderException
import org.junit.jupiter.api.assertThrows
import org.openrs2.buffer.wrappedBuffer import org.openrs2.buffer.wrappedBuffer
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
object Js5RequestDecoderTest { object Js5RequestDecoderTest {
@Test @Test
@ -32,7 +32,7 @@ object Js5RequestDecoderTest {
fun testUnknownOpcode() { fun testUnknownOpcode() {
val channel = EmbeddedChannel(Js5RequestDecoder()) val channel = EmbeddedChannel(Js5RequestDecoder())
assertThrows<DecoderException> { assertFailsWith<DecoderException> {
channel.writeInbound(wrappedBuffer(8, 0, 0, 0)) channel.writeInbound(wrappedBuffer(8, 0, 0, 0))
} }
} }

@ -5,11 +5,11 @@ import io.netty.buffer.ByteBufAllocator
import io.netty.buffer.Unpooled import io.netty.buffer.Unpooled
import io.netty.channel.embedded.EmbeddedChannel import io.netty.channel.embedded.EmbeddedChannel
import io.netty.handler.codec.DecoderException import io.netty.handler.codec.DecoderException
import org.junit.jupiter.api.assertThrows
import org.openrs2.buffer.use import org.openrs2.buffer.use
import org.openrs2.buffer.wrappedBuffer import org.openrs2.buffer.wrappedBuffer
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
object Js5ResponseDecoderTest { object Js5ResponseDecoderTest {
@Test @Test
@ -58,7 +58,7 @@ object Js5ResponseDecoderTest {
fun testDecodeNegativeLength() { fun testDecodeNegativeLength() {
val channel = EmbeddedChannel(Js5ResponseDecoder()) val channel = EmbeddedChannel(Js5ResponseDecoder())
assertThrows<DecoderException> { assertFailsWith<DecoderException> {
channel.writeInbound(wrappedBuffer(2, 0, 3, 0, 0xFF.toByte(), 0xFF.toByte(), 0xFF.toByte(), 0xFF.toByte())) channel.writeInbound(wrappedBuffer(2, 0, 3, 0, 0xFF.toByte(), 0xFF.toByte(), 0xFF.toByte(), 0xFF.toByte()))
} }
} }
@ -67,7 +67,7 @@ object Js5ResponseDecoderTest {
fun testDecodeOverflowUncompressed() { fun testDecodeOverflowUncompressed() {
val channel = EmbeddedChannel(Js5ResponseDecoder()) val channel = EmbeddedChannel(Js5ResponseDecoder())
assertThrows<DecoderException> { assertFailsWith<DecoderException> {
channel.writeInbound(wrappedBuffer(2, 0, 3, 0, 0x7F, 0xFF.toByte(), 0xFF.toByte(), 0xFB.toByte())) channel.writeInbound(wrappedBuffer(2, 0, 3, 0, 0x7F, 0xFF.toByte(), 0xFF.toByte(), 0xFB.toByte()))
} }
} }
@ -76,7 +76,7 @@ object Js5ResponseDecoderTest {
fun testDecodeOverflowCompressed() { fun testDecodeOverflowCompressed() {
val channel = EmbeddedChannel(Js5ResponseDecoder()) val channel = EmbeddedChannel(Js5ResponseDecoder())
assertThrows<DecoderException> { assertFailsWith<DecoderException> {
channel.writeInbound(wrappedBuffer(2, 0, 3, 1, 0x7F, 0xFF.toByte(), 0xFF.toByte(), 0xF7.toByte())) channel.writeInbound(wrappedBuffer(2, 0, 3, 1, 0x7F, 0xFF.toByte(), 0xFF.toByte(), 0xF7.toByte()))
} }
} }
@ -85,7 +85,7 @@ object Js5ResponseDecoderTest {
fun testDecodeInvalidBlockTrailer() { fun testDecodeInvalidBlockTrailer() {
val channel = EmbeddedChannel(Js5ResponseDecoder()) val channel = EmbeddedChannel(Js5ResponseDecoder())
assertThrows<DecoderException> { assertFailsWith<DecoderException> {
channel.writeInbound(read("invalid-block-trailer.dat")) channel.writeInbound(read("invalid-block-trailer.dat"))
} }
} }

@ -4,10 +4,10 @@ import io.netty.buffer.ByteBuf
import io.netty.buffer.Unpooled import io.netty.buffer.Unpooled
import io.netty.channel.embedded.EmbeddedChannel import io.netty.channel.embedded.EmbeddedChannel
import io.netty.handler.codec.EncoderException import io.netty.handler.codec.EncoderException
import org.junit.jupiter.api.assertThrows
import org.openrs2.buffer.use import org.openrs2.buffer.use
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
object Js5ResponseEncoderTest { object Js5ResponseEncoderTest {
@Test @Test
@ -35,7 +35,7 @@ object Js5ResponseEncoderTest {
fun testEncodeEmpty() { fun testEncodeEmpty() {
val channel = EmbeddedChannel(Js5ResponseEncoder) val channel = EmbeddedChannel(Js5ResponseEncoder)
assertThrows<EncoderException> { assertFailsWith<EncoderException> {
channel.writeOutbound(Js5Response(true, 2, 3, Unpooled.EMPTY_BUFFER)) channel.writeOutbound(Js5Response(true, 2, 3, Unpooled.EMPTY_BUFFER))
} }
} }

@ -1,8 +1,8 @@
package org.openrs2.util.collect package org.openrs2.util.collect
import org.junit.jupiter.api.assertThrows
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
import kotlin.test.assertFalse import kotlin.test.assertFalse
import kotlin.test.assertNull import kotlin.test.assertNull
import kotlin.test.assertTrue import kotlin.test.assertTrue
@ -20,7 +20,7 @@ object IterableUtilsTest {
assertEquals(3, list.removeFirst()) assertEquals(3, list.removeFirst())
assertEquals(emptyList<Int>(), list) assertEquals(emptyList<Int>(), list)
assertThrows<NoSuchElementException> { assertFailsWith<NoSuchElementException> {
list.removeFirst() list.removeFirst()
} }
} }

Loading…
Cancel
Save