diff --git a/buffer/src/test/kotlin/org/openrs2/buffer/ByteBufExtensionsTest.kt b/buffer/src/test/kotlin/org/openrs2/buffer/ByteBufExtensionsTest.kt index 98c4c083..27109fde 100644 --- a/buffer/src/test/kotlin/org/openrs2/buffer/ByteBufExtensionsTest.kt +++ b/buffer/src/test/kotlin/org/openrs2/buffer/ByteBufExtensionsTest.kt @@ -2,9 +2,9 @@ package org.openrs2.buffer import io.netty.buffer.ByteBufAllocator import io.netty.buffer.Unpooled -import org.junit.jupiter.api.assertThrows import kotlin.test.Test import kotlin.test.assertEquals +import kotlin.test.assertFailsWith import kotlin.test.assertFalse object ByteBufExtensionsTest { @@ -119,13 +119,13 @@ object ByteBufExtensionsTest { } ByteBufAllocator.DEFAULT.buffer().use { buf -> - assertThrows { + assertFailsWith { buf.writeShortSmart(-0x4001) } } ByteBufAllocator.DEFAULT.buffer().use { buf -> - assertThrows { + assertFailsWith { buf.writeShortSmart(0x4000) } } @@ -209,13 +209,13 @@ object ByteBufExtensionsTest { } ByteBufAllocator.DEFAULT.buffer().use { buf -> - assertThrows { + assertFailsWith { buf.writeUnsignedShortSmart(-0x1) } } ByteBufAllocator.DEFAULT.buffer().use { buf -> - assertThrows { + assertFailsWith { buf.writeUnsignedShortSmart(0x10000) } } @@ -311,13 +311,13 @@ object ByteBufExtensionsTest { } ByteBufAllocator.DEFAULT.buffer().use { buf -> - assertThrows { + assertFailsWith { buf.writeIntSmart(-0x40000001) } } ByteBufAllocator.DEFAULT.buffer().use { buf -> - assertThrows { + assertFailsWith { buf.writeIntSmart(0x40000000) } } @@ -401,7 +401,7 @@ object ByteBufExtensionsTest { } ByteBufAllocator.DEFAULT.buffer().use { buf -> - assertThrows { + assertFailsWith { buf.writeUnsignedIntSmart(0x80000000.toInt()) } } @@ -450,19 +450,19 @@ object ByteBufExtensionsTest { @Test fun testCrc32Bounds() { - assertThrows { + assertFailsWith { Unpooled.EMPTY_BUFFER.crc32(-1, 0) } - assertThrows { + assertFailsWith { Unpooled.EMPTY_BUFFER.crc32(0, -1) } - assertThrows { + assertFailsWith { Unpooled.EMPTY_BUFFER.crc32(1, 0) } - assertThrows { + assertFailsWith { Unpooled.EMPTY_BUFFER.crc32(0, 1) } } diff --git a/cache/src/test/kotlin/org/openrs2/cache/BufferedFileChannelTest.kt b/cache/src/test/kotlin/org/openrs2/cache/BufferedFileChannelTest.kt index 3715fb59..9aa09d5a 100644 --- a/cache/src/test/kotlin/org/openrs2/cache/BufferedFileChannelTest.kt +++ b/cache/src/test/kotlin/org/openrs2/cache/BufferedFileChannelTest.kt @@ -4,7 +4,6 @@ import com.google.common.jimfs.Configuration import com.google.common.jimfs.Jimfs import io.netty.buffer.ByteBufAllocator import io.netty.buffer.Unpooled -import org.junit.jupiter.api.assertThrows import org.openrs2.buffer.copiedBuffer import org.openrs2.buffer.use import org.openrs2.buffer.wrappedBuffer @@ -16,6 +15,7 @@ import java.nio.file.StandardOpenOption.READ import java.nio.file.StandardOpenOption.WRITE import kotlin.test.Test import kotlin.test.assertEquals +import kotlin.test.assertFailsWith object BufferedFileChannelTest { @Test @@ -197,7 +197,7 @@ object BufferedFileChannelTest { BufferedFileChannel(FileChannel.open(path, CREATE, READ, WRITE), 8, 8).use { channel -> ByteBufAllocator.DEFAULT.buffer(1, 1).use { buf -> - assertThrows { + assertFailsWith { channel.read(0, buf, buf.writableBytes()) } } @@ -213,7 +213,7 @@ object BufferedFileChannelTest { BufferedFileChannel(FileChannel.open(path, READ), 8, 8).use { channel -> ByteBufAllocator.DEFAULT.buffer(15, 15).use { buf -> - assertThrows { + assertFailsWith { channel.read(0, buf, buf.writableBytes()) } } diff --git a/cache/src/test/kotlin/org/openrs2/cache/DiskStoreTest.kt b/cache/src/test/kotlin/org/openrs2/cache/DiskStoreTest.kt index b7f4fc57..212c3209 100644 --- a/cache/src/test/kotlin/org/openrs2/cache/DiskStoreTest.kt +++ b/cache/src/test/kotlin/org/openrs2/cache/DiskStoreTest.kt @@ -3,7 +3,6 @@ package org.openrs2.cache import com.google.common.jimfs.Configuration import com.google.common.jimfs.Jimfs import io.netty.buffer.Unpooled -import org.junit.jupiter.api.assertThrows import org.openrs2.buffer.copiedBuffer import org.openrs2.buffer.use import org.openrs2.util.io.recursiveCopy @@ -12,6 +11,7 @@ import java.io.FileNotFoundException import java.nio.file.Paths import kotlin.test.Test import kotlin.test.assertEquals +import kotlin.test.assertFailsWith import kotlin.test.assertFalse import kotlin.test.assertTrue @@ -21,85 +21,85 @@ object DiskStoreTest { @Test fun testBounds() { readTest("empty") { store -> - assertThrows { + assertFailsWith { store.exists(-1) } - assertThrows { + assertFailsWith { store.exists(256) } - assertThrows { + assertFailsWith { store.list(-1) } - assertThrows { + assertFailsWith { store.list(256) } - assertThrows { + assertFailsWith { store.exists(-1, 0) } - assertThrows { + assertFailsWith { store.exists(256, 0) } - assertThrows { + assertFailsWith { store.exists(0, -1) } - assertThrows { + assertFailsWith { store.read(-1, 0).release() } - assertThrows { + assertFailsWith { store.read(256, 0).release() } - assertThrows { + assertFailsWith { store.read(0, -1).release() } } writeTest("empty") { store -> - assertThrows { + assertFailsWith { store.create(-1) } - assertThrows { + assertFailsWith { store.create(256) } - assertThrows { + assertFailsWith { store.write(-1, 0, Unpooled.EMPTY_BUFFER) } - assertThrows { + assertFailsWith { store.write(256, 0, Unpooled.EMPTY_BUFFER) } - assertThrows { + assertFailsWith { store.write(0, -1, Unpooled.EMPTY_BUFFER) } - assertThrows { + assertFailsWith { store.remove(-1) } - assertThrows { + assertFailsWith { store.remove(256) } - assertThrows { + assertFailsWith { store.remove(-1, 0) } - assertThrows { + assertFailsWith { store.remove(256, 0) } - assertThrows { + assertFailsWith { store.remove(0, -1) } } @@ -200,7 +200,7 @@ object DiskStoreTest { @Test fun testListNonExistent() { readTest("empty") { store -> - assertThrows { + assertFailsWith { store.list(0) } } @@ -275,15 +275,15 @@ object DiskStoreTest { @Test fun testReadNonExistent() { readTest("single-block") { store -> - assertThrows { + assertFailsWith { store.read(0, 0) } - assertThrows { + assertFailsWith { store.read(255, 0) } - assertThrows { + assertFailsWith { store.read(255, 2) } } @@ -498,67 +498,67 @@ object DiskStoreTest { @Test fun testReadCorrupt() { readTest("corrupt-eof-late") { store -> - assertThrows { + assertFailsWith { store.read(255, 1).release() } } readTest("corrupt-first-eof-early") { store -> - assertThrows { + assertFailsWith { store.read(255, 1).release() } } readTest("corrupt-first-invalid-archive") { store -> - assertThrows { + assertFailsWith { store.read(255, 1).release() } } readTest("corrupt-first-invalid-block-number") { store -> - assertThrows { + assertFailsWith { store.read(255, 1).release() } } readTest("corrupt-first-invalid-group") { store -> - assertThrows { + assertFailsWith { store.read(255, 1).release() } } readTest("corrupt-first-outside-data-file") { store -> - assertThrows { + assertFailsWith { store.read(255, 1).release() } } readTest("corrupt-second-eof-early") { store -> - assertThrows { + assertFailsWith { store.read(255, 1).release() } } readTest("corrupt-second-invalid-archive") { store -> - assertThrows { + assertFailsWith { store.read(255, 1).release() } } readTest("corrupt-second-invalid-block-number") { store -> - assertThrows { + assertFailsWith { store.read(255, 1).release() } } readTest("corrupt-second-invalid-group") { store -> - assertThrows { + assertFailsWith { store.read(255, 1).release() } } readTest("corrupt-second-outside-data-file") { store -> - assertThrows { + assertFailsWith { store.read(255, 1).release() } } diff --git a/cache/src/test/kotlin/org/openrs2/cache/FlatFileStoreTest.kt b/cache/src/test/kotlin/org/openrs2/cache/FlatFileStoreTest.kt index da4824ed..1a2e5024 100644 --- a/cache/src/test/kotlin/org/openrs2/cache/FlatFileStoreTest.kt +++ b/cache/src/test/kotlin/org/openrs2/cache/FlatFileStoreTest.kt @@ -3,7 +3,6 @@ package org.openrs2.cache import com.google.common.jimfs.Configuration import com.google.common.jimfs.Jimfs import io.netty.buffer.Unpooled -import org.junit.jupiter.api.assertThrows import org.openrs2.buffer.copiedBuffer import org.openrs2.buffer.use import org.openrs2.util.io.recursiveCopy @@ -13,6 +12,7 @@ import java.nio.file.Path import java.nio.file.Paths import kotlin.test.Test import kotlin.test.assertEquals +import kotlin.test.assertFailsWith import kotlin.test.assertFalse import kotlin.test.assertTrue @@ -23,85 +23,85 @@ object FlatFileStoreTest { @Test fun testBounds() { readTest("empty") { store -> - assertThrows { + assertFailsWith { store.exists(-1) } - assertThrows { + assertFailsWith { store.exists(256) } - assertThrows { + assertFailsWith { store.list(-1) } - assertThrows { + assertFailsWith { store.list(256) } - assertThrows { + assertFailsWith { store.exists(-1, 0) } - assertThrows { + assertFailsWith { store.exists(256, 0) } - assertThrows { + assertFailsWith { store.exists(0, -1) } - assertThrows { + assertFailsWith { store.read(-1, 0).release() } - assertThrows { + assertFailsWith { store.read(256, 0).release() } - assertThrows { + assertFailsWith { store.read(0, -1).release() } } writeTest("empty") { store -> - assertThrows { + assertFailsWith { store.create(-1) } - assertThrows { + assertFailsWith { store.create(256) } - assertThrows { + assertFailsWith { store.write(-1, 0, Unpooled.EMPTY_BUFFER) } - assertThrows { + assertFailsWith { store.write(256, 0, Unpooled.EMPTY_BUFFER) } - assertThrows { + assertFailsWith { store.write(0, -1, Unpooled.EMPTY_BUFFER) } - assertThrows { + assertFailsWith { store.remove(-1) } - assertThrows { + assertFailsWith { store.remove(256) } - assertThrows { + assertFailsWith { store.remove(-1, 0) } - assertThrows { + assertFailsWith { store.remove(256, 0) } - assertThrows { + assertFailsWith { store.remove(0, -1) } } @@ -142,11 +142,11 @@ object FlatFileStoreTest { assertEquals(listOf(0, 1), store.list(0)) assertEquals(listOf(0, 65536), store.list(255)) - assertThrows { + assertFailsWith { store.list(1) } - assertThrows { + assertFailsWith { store.list(254) } } @@ -174,11 +174,11 @@ object FlatFileStoreTest { assertEquals(Unpooled.EMPTY_BUFFER, actual) } - assertThrows { + assertFailsWith { store.read(0, 2).release() } - assertThrows { + assertFailsWith { store.read(1, 0).release() } diff --git a/cache/src/test/kotlin/org/openrs2/cache/Js5CompressionTest.kt b/cache/src/test/kotlin/org/openrs2/cache/Js5CompressionTest.kt index 7bb8c145..fbeb61fb 100644 --- a/cache/src/test/kotlin/org/openrs2/cache/Js5CompressionTest.kt +++ b/cache/src/test/kotlin/org/openrs2/cache/Js5CompressionTest.kt @@ -2,13 +2,13 @@ package org.openrs2.cache import io.netty.buffer.ByteBuf import io.netty.buffer.Unpooled -import org.junit.jupiter.api.assertThrows import org.openrs2.buffer.copiedBuffer import org.openrs2.buffer.use import org.openrs2.crypto.XteaKey import java.io.IOException import kotlin.test.Test import kotlin.test.assertEquals +import kotlin.test.assertFailsWith import kotlin.test.assertFalse import kotlin.test.assertNotEquals import kotlin.test.assertTrue @@ -264,11 +264,11 @@ object Js5CompressionTest { @Test fun testInvalidType() { read("invalid-type.dat").use { compressed -> - assertThrows { + assertFailsWith { Js5Compression.uncompress(compressed.slice()).release() } - assertThrows { + assertFailsWith { Js5Compression.isKeyValid(compressed.slice(), XteaKey.ZERO) } } @@ -277,11 +277,11 @@ object Js5CompressionTest { @Test fun testInvalidLength() { read("invalid-length.dat").use { compressed -> - assertThrows { + assertFailsWith { Js5Compression.uncompress(compressed.slice()).release() } - assertThrows { + assertFailsWith { Js5Compression.isKeyValid(compressed.slice(), XteaKey.ZERO) } } @@ -290,7 +290,7 @@ object Js5CompressionTest { @Test fun testInvalidUncompressedLength() { read("invalid-uncompressed-length.dat").use { compressed -> - assertThrows { + assertFailsWith { Js5Compression.uncompress(compressed.slice()).release() } @@ -301,7 +301,7 @@ object Js5CompressionTest { @Test fun testNoneEof() { read("none-eof.dat").use { compressed -> - assertThrows { + assertFailsWith { Js5Compression.uncompress(compressed).release() } } @@ -310,7 +310,7 @@ object Js5CompressionTest { @Test fun testBzip2Eof() { read("bzip2-eof.dat").use { compressed -> - assertThrows { + assertFailsWith { Js5Compression.uncompress(compressed.slice()).release() } @@ -321,7 +321,7 @@ object Js5CompressionTest { @Test fun testGzipEof() { read("gzip-eof.dat").use { compressed -> - assertThrows { + assertFailsWith { Js5Compression.uncompress(compressed.slice()).release() } @@ -332,7 +332,7 @@ object Js5CompressionTest { @Test fun testLzmaEof() { read("lzma-eof.dat").use { compressed -> - assertThrows { + assertFailsWith { Js5Compression.uncompress(compressed.slice()).release() } @@ -343,7 +343,7 @@ object Js5CompressionTest { @Test fun testBzip2Corrupt() { read("bzip2-corrupt.dat").use { compressed -> - assertThrows { + assertFailsWith { Js5Compression.uncompress(compressed.slice()).release() } @@ -354,7 +354,7 @@ object Js5CompressionTest { @Test fun testGzipCorrupt() { read("gzip-corrupt.dat").use { compressed -> - assertThrows { + assertFailsWith { Js5Compression.uncompress(compressed.slice()).release() } @@ -365,7 +365,7 @@ object Js5CompressionTest { @Test fun testLzmaCorrupt() { read("lzma-corrupt.dat").use { compressed -> - assertThrows { + assertFailsWith { Js5Compression.uncompress(compressed.slice()).release() } @@ -461,7 +461,7 @@ object Js5CompressionTest { @Test fun testKeyValidShorterThanTwoBlocks() { read("shorter-than-two-blocks.dat").use { compressed -> - assertThrows { + assertFailsWith { Js5Compression.isKeyValid(compressed, XteaKey.ZERO) } } @@ -470,11 +470,11 @@ object Js5CompressionTest { @Test fun testCompressedUnderflow() { read("compressed-underflow.dat").use { compressed -> - assertThrows { + assertFailsWith { Js5Compression.uncompress(compressed.slice()).release() } - assertThrows { + assertFailsWith { Js5Compression.isKeyValid(compressed.slice(), XteaKey.ZERO) } } @@ -483,7 +483,7 @@ object Js5CompressionTest { @Test fun testUncompressedOverflow() { read("uncompressed-overflow.dat").use { compressed -> - assertThrows { + assertFailsWith { Js5Compression.uncompress(compressed).release() } } @@ -492,7 +492,7 @@ object Js5CompressionTest { @Test fun testUncompressedUnderflow() { read("uncompressed-underflow.dat").use { compressed -> - assertThrows { + assertFailsWith { Js5Compression.uncompress(compressed).release() } } diff --git a/cache/src/test/kotlin/org/openrs2/cache/Js5IndexTest.kt b/cache/src/test/kotlin/org/openrs2/cache/Js5IndexTest.kt index 4bc17ba9..85dd3aa6 100644 --- a/cache/src/test/kotlin/org/openrs2/cache/Js5IndexTest.kt +++ b/cache/src/test/kotlin/org/openrs2/cache/Js5IndexTest.kt @@ -4,12 +4,12 @@ import io.netty.buffer.ByteBuf import io.netty.buffer.ByteBufAllocator import io.netty.buffer.ByteBufUtil import io.netty.buffer.Unpooled -import org.junit.jupiter.api.assertThrows import org.openrs2.buffer.use import org.openrs2.buffer.wrappedBuffer import org.openrs2.util.krHashCode import kotlin.test.Test import kotlin.test.assertEquals +import kotlin.test.assertFailsWith import kotlin.test.assertFalse import kotlin.test.assertNull import kotlin.test.assertTrue @@ -130,13 +130,13 @@ object Js5IndexTest { @Test fun testReadUnsupportedProtocol() { wrappedBuffer(4).use { buf -> - assertThrows { + assertFailsWith { Js5Index.read(buf) } } wrappedBuffer(8).use { buf -> - assertThrows { + assertFailsWith { Js5Index.read(buf) } } @@ -228,7 +228,7 @@ object Js5IndexTest { index.createOrGet(65536) ByteBufAllocator.DEFAULT.buffer().use { buf -> - assertThrows { + assertFailsWith { index.write(buf) } } diff --git a/cache/src/test/kotlin/org/openrs2/cache/NamedEntryCollectionTest.kt b/cache/src/test/kotlin/org/openrs2/cache/NamedEntryCollectionTest.kt index 1dd1ee3f..4bd791ff 100644 --- a/cache/src/test/kotlin/org/openrs2/cache/NamedEntryCollectionTest.kt +++ b/cache/src/test/kotlin/org/openrs2/cache/NamedEntryCollectionTest.kt @@ -1,9 +1,9 @@ package org.openrs2.cache -import org.junit.jupiter.api.assertThrows import org.openrs2.util.krHashCode import kotlin.test.Test import kotlin.test.assertEquals +import kotlin.test.assertFailsWith import kotlin.test.assertFalse import kotlin.test.assertNull import kotlin.test.assertTrue @@ -33,35 +33,35 @@ object NamedEntryCollectionTest { fun testBounds() { val collection = TestCollection() - assertThrows { + assertFailsWith { -1 in collection } - assertThrows { + assertFailsWith { collection.containsNamed(-1) } - assertThrows { + assertFailsWith { collection[-1] } - assertThrows { + assertFailsWith { collection.getNamed(-1) } - assertThrows { + assertFailsWith { collection.createOrGet(-1) } - assertThrows { + assertFailsWith { collection.createOrGetNamed(-1) } - assertThrows { + assertFailsWith { collection.remove(-1) } - assertThrows { + assertFailsWith { collection.removeNamed(-1) } } @@ -590,17 +590,17 @@ object NamedEntryCollectionTest { val it = collection.iterator() - assertThrows { + assertFailsWith { it.remove() } assertFalse(it.hasNext()) - assertThrows { + assertFailsWith { it.next() } - assertThrows { + assertFailsWith { it.remove() } } @@ -615,7 +615,7 @@ object NamedEntryCollectionTest { val it = collection.iterator() - assertThrows { + assertFailsWith { it.remove() } @@ -624,11 +624,11 @@ object NamedEntryCollectionTest { assertFalse(it.hasNext()) - assertThrows { + assertFailsWith { it.next() } - assertThrows { + assertFailsWith { it.remove() } } @@ -647,7 +647,7 @@ object NamedEntryCollectionTest { val it = collection.iterator() - assertThrows { + assertFailsWith { it.remove() } @@ -659,11 +659,11 @@ object NamedEntryCollectionTest { assertFalse(it.hasNext()) - assertThrows { + assertFailsWith { it.next() } - assertThrows { + assertFailsWith { it.remove() } } @@ -683,7 +683,7 @@ object NamedEntryCollectionTest { it.remove() - assertThrows { + assertFailsWith { it.remove() } @@ -713,7 +713,7 @@ object NamedEntryCollectionTest { it.remove() - assertThrows { + assertFailsWith { it.remove() } @@ -722,7 +722,7 @@ object NamedEntryCollectionTest { it.remove() - assertThrows { + assertFailsWith { it.remove() } diff --git a/db/src/test/kotlin/org/openrs2/db/BackoffStrategyTest.kt b/db/src/test/kotlin/org/openrs2/db/BackoffStrategyTest.kt index 66533ee3..55b80173 100644 --- a/db/src/test/kotlin/org/openrs2/db/BackoffStrategyTest.kt +++ b/db/src/test/kotlin/org/openrs2/db/BackoffStrategyTest.kt @@ -1,8 +1,8 @@ package org.openrs2.db -import org.junit.jupiter.api.assertThrows import kotlin.test.Test import kotlin.test.assertEquals +import kotlin.test.assertFailsWith object BackoffStrategyTest { @Test @@ -13,22 +13,22 @@ object BackoffStrategyTest { assertEquals(1000, strategy.getDelay(1)) assertEquals(1000, strategy.getDelay(2)) - assertThrows { + assertFailsWith { strategy.getDelay(-1) } } @Test fun testBinaryExponentialBackoff() { - assertThrows { + assertFailsWith { BinaryExponentialBackoffStrategy(0, 1) } - assertThrows { + assertFailsWith { BinaryExponentialBackoffStrategy(1, 0) } - assertThrows { + assertFailsWith { BinaryExponentialBackoffStrategy(1, 1).getDelay(-1) } } diff --git a/db/src/test/kotlin/org/openrs2/db/DatabaseTest.kt b/db/src/test/kotlin/org/openrs2/db/DatabaseTest.kt index 5cf80770..39ceb15c 100644 --- a/db/src/test/kotlin/org/openrs2/db/DatabaseTest.kt +++ b/db/src/test/kotlin/org/openrs2/db/DatabaseTest.kt @@ -3,10 +3,10 @@ package org.openrs2.db import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runBlockingTest import org.h2.jdbcx.JdbcDataSource -import org.junit.jupiter.api.assertThrows import java.sql.SQLException import kotlin.test.Test import kotlin.test.assertEquals +import kotlin.test.assertFailsWith import kotlin.test.assertTrue @ExperimentalCoroutinesApi @@ -35,7 +35,7 @@ object DatabaseTest { @Test fun testBounds() { - assertThrows { + assertFailsWith { Database(dataSource, attempts = 0) } } @@ -86,7 +86,7 @@ object DatabaseTest { fun testDeadlockFailure() { var attempts = 0 - assertThrows { + assertFailsWith { runBlockingTest { database.execute { attempts++ @@ -102,7 +102,7 @@ object DatabaseTest { fun testNonDeadlockFailure() { var attempts = 0 - assertThrows { + assertFailsWith { runBlockingTest { database.execute { attempts++ @@ -168,7 +168,7 @@ object DatabaseTest { fun testNonDeadlockNextChain() { var attempts = 0 - assertThrows { + assertFailsWith { runBlockingTest { database.execute { attempts++ diff --git a/protocol/src/test/kotlin/org/openrs2/protocol/Rs2DecoderTest.kt b/protocol/src/test/kotlin/org/openrs2/protocol/Rs2DecoderTest.kt index 51ed5f26..915e0b9f 100644 --- a/protocol/src/test/kotlin/org/openrs2/protocol/Rs2DecoderTest.kt +++ b/protocol/src/test/kotlin/org/openrs2/protocol/Rs2DecoderTest.kt @@ -3,10 +3,10 @@ package org.openrs2.protocol import io.netty.buffer.Unpooled import io.netty.channel.embedded.EmbeddedChannel import io.netty.handler.codec.DecoderException -import org.junit.jupiter.api.assertThrows import org.openrs2.buffer.wrappedBuffer import kotlin.test.Test import kotlin.test.assertEquals +import kotlin.test.assertFailsWith object Rs2DecoderTest { @Test @@ -28,7 +28,7 @@ object Rs2DecoderTest { fun testUnsupported() { val channel = EmbeddedChannel(Rs2Decoder(Protocol())) - assertThrows { + assertFailsWith { channel.writeInbound(wrappedBuffer(0)) } } @@ -53,7 +53,7 @@ object Rs2DecoderTest { channel.writeInbound(wrappedBuffer(0, 0x11, 0x22, 0x33, 0x44)) channel.readInbound() - assertThrows { + assertFailsWith { channel.writeInbound(wrappedBuffer(5)) } @@ -64,7 +64,7 @@ object Rs2DecoderTest { val actual = channel.readInbound() assertEquals(EmptyPacket, actual) - assertThrows { + assertFailsWith { channel.writeInbound(wrappedBuffer(0, 0x11, 0x22, 0x33, 0x44)) } } diff --git a/protocol/src/test/kotlin/org/openrs2/protocol/Rs2EncoderTest.kt b/protocol/src/test/kotlin/org/openrs2/protocol/Rs2EncoderTest.kt index 5fc505ea..d69985f7 100644 --- a/protocol/src/test/kotlin/org/openrs2/protocol/Rs2EncoderTest.kt +++ b/protocol/src/test/kotlin/org/openrs2/protocol/Rs2EncoderTest.kt @@ -4,11 +4,11 @@ import io.netty.buffer.ByteBuf import io.netty.buffer.Unpooled import io.netty.channel.embedded.EmbeddedChannel import io.netty.handler.codec.EncoderException -import org.junit.jupiter.api.assertThrows import org.openrs2.buffer.use import org.openrs2.buffer.wrappedBuffer import kotlin.test.Test import kotlin.test.assertEquals +import kotlin.test.assertFailsWith object Rs2EncoderTest { @Test @@ -36,11 +36,11 @@ object Rs2EncoderTest { channel.writeOutbound(VariableShortPacket(ByteArray(65535))) channel.readOutbound().release() - assertThrows { + assertFailsWith { channel.writeOutbound(VariableBytePacket(ByteArray(256))) } - assertThrows { + assertFailsWith { channel.writeOutbound(VariableShortPacket(ByteArray(65536))) } } @@ -49,7 +49,7 @@ object Rs2EncoderTest { fun testUnsupported() { val channel = EmbeddedChannel(Rs2Encoder(Protocol())) - assertThrows { + assertFailsWith { channel.writeOutbound(FixedPacket(0x11223344)) } } @@ -58,7 +58,7 @@ object Rs2EncoderTest { fun testLengthMismatch() { val channel = EmbeddedChannel(Rs2Encoder(Protocol(LengthMismatchPacketCodec))) - assertThrows { + assertFailsWith { channel.writeOutbound(FixedPacket(0x11223344)) } } @@ -92,7 +92,7 @@ object Rs2EncoderTest { channel.writeOutbound(FixedPacket(0x11223344)) channel.readOutbound().release() - assertThrows { + assertFailsWith { channel.writeOutbound(EmptyPacket) } @@ -106,7 +106,7 @@ object Rs2EncoderTest { } } - assertThrows { + assertFailsWith { channel.writeOutbound(FixedPacket(0x11223344)) } } diff --git a/protocol/src/test/kotlin/org/openrs2/protocol/jaggrab/JaggrabRequestDecoderTest.kt b/protocol/src/test/kotlin/org/openrs2/protocol/jaggrab/JaggrabRequestDecoderTest.kt index 6c554d03..7b3d5bf6 100644 --- a/protocol/src/test/kotlin/org/openrs2/protocol/jaggrab/JaggrabRequestDecoderTest.kt +++ b/protocol/src/test/kotlin/org/openrs2/protocol/jaggrab/JaggrabRequestDecoderTest.kt @@ -2,9 +2,9 @@ package org.openrs2.protocol.jaggrab import io.netty.channel.embedded.EmbeddedChannel import io.netty.handler.codec.DecoderException -import org.junit.jupiter.api.assertThrows import kotlin.test.Test import kotlin.test.assertEquals +import kotlin.test.assertFailsWith object JaggrabRequestDecoderTest { @Test @@ -20,7 +20,7 @@ object JaggrabRequestDecoderTest { fun testInvalid() { val channel = EmbeddedChannel(JaggrabRequestDecoder) - assertThrows { + assertFailsWith { channel.writeInbound("Hello, world!") } } diff --git a/protocol/src/test/kotlin/org/openrs2/protocol/js5/Js5RequestDecoderTest.kt b/protocol/src/test/kotlin/org/openrs2/protocol/js5/Js5RequestDecoderTest.kt index 8fa9fbb5..0a046eb8 100644 --- a/protocol/src/test/kotlin/org/openrs2/protocol/js5/Js5RequestDecoderTest.kt +++ b/protocol/src/test/kotlin/org/openrs2/protocol/js5/Js5RequestDecoderTest.kt @@ -3,10 +3,10 @@ package org.openrs2.protocol.js5 import io.netty.buffer.Unpooled import io.netty.channel.embedded.EmbeddedChannel import io.netty.handler.codec.DecoderException -import org.junit.jupiter.api.assertThrows import org.openrs2.buffer.wrappedBuffer import kotlin.test.Test import kotlin.test.assertEquals +import kotlin.test.assertFailsWith object Js5RequestDecoderTest { @Test @@ -32,7 +32,7 @@ object Js5RequestDecoderTest { fun testUnknownOpcode() { val channel = EmbeddedChannel(Js5RequestDecoder()) - assertThrows { + assertFailsWith { channel.writeInbound(wrappedBuffer(8, 0, 0, 0)) } } diff --git a/protocol/src/test/kotlin/org/openrs2/protocol/js5/Js5ResponseDecoderTest.kt b/protocol/src/test/kotlin/org/openrs2/protocol/js5/Js5ResponseDecoderTest.kt index 3301b2a5..c79b9433 100644 --- a/protocol/src/test/kotlin/org/openrs2/protocol/js5/Js5ResponseDecoderTest.kt +++ b/protocol/src/test/kotlin/org/openrs2/protocol/js5/Js5ResponseDecoderTest.kt @@ -5,11 +5,11 @@ import io.netty.buffer.ByteBufAllocator import io.netty.buffer.Unpooled import io.netty.channel.embedded.EmbeddedChannel import io.netty.handler.codec.DecoderException -import org.junit.jupiter.api.assertThrows import org.openrs2.buffer.use import org.openrs2.buffer.wrappedBuffer import kotlin.test.Test import kotlin.test.assertEquals +import kotlin.test.assertFailsWith object Js5ResponseDecoderTest { @Test @@ -58,7 +58,7 @@ object Js5ResponseDecoderTest { fun testDecodeNegativeLength() { val channel = EmbeddedChannel(Js5ResponseDecoder()) - assertThrows { + assertFailsWith { channel.writeInbound(wrappedBuffer(2, 0, 3, 0, 0xFF.toByte(), 0xFF.toByte(), 0xFF.toByte(), 0xFF.toByte())) } } @@ -67,7 +67,7 @@ object Js5ResponseDecoderTest { fun testDecodeOverflowUncompressed() { val channel = EmbeddedChannel(Js5ResponseDecoder()) - assertThrows { + assertFailsWith { channel.writeInbound(wrappedBuffer(2, 0, 3, 0, 0x7F, 0xFF.toByte(), 0xFF.toByte(), 0xFB.toByte())) } } @@ -76,7 +76,7 @@ object Js5ResponseDecoderTest { fun testDecodeOverflowCompressed() { val channel = EmbeddedChannel(Js5ResponseDecoder()) - assertThrows { + assertFailsWith { channel.writeInbound(wrappedBuffer(2, 0, 3, 1, 0x7F, 0xFF.toByte(), 0xFF.toByte(), 0xF7.toByte())) } } @@ -85,7 +85,7 @@ object Js5ResponseDecoderTest { fun testDecodeInvalidBlockTrailer() { val channel = EmbeddedChannel(Js5ResponseDecoder()) - assertThrows { + assertFailsWith { channel.writeInbound(read("invalid-block-trailer.dat")) } } diff --git a/protocol/src/test/kotlin/org/openrs2/protocol/js5/Js5ResponseEncoderTest.kt b/protocol/src/test/kotlin/org/openrs2/protocol/js5/Js5ResponseEncoderTest.kt index f559c98c..277c97fc 100644 --- a/protocol/src/test/kotlin/org/openrs2/protocol/js5/Js5ResponseEncoderTest.kt +++ b/protocol/src/test/kotlin/org/openrs2/protocol/js5/Js5ResponseEncoderTest.kt @@ -4,10 +4,10 @@ import io.netty.buffer.ByteBuf import io.netty.buffer.Unpooled import io.netty.channel.embedded.EmbeddedChannel import io.netty.handler.codec.EncoderException -import org.junit.jupiter.api.assertThrows import org.openrs2.buffer.use import kotlin.test.Test import kotlin.test.assertEquals +import kotlin.test.assertFailsWith object Js5ResponseEncoderTest { @Test @@ -35,7 +35,7 @@ object Js5ResponseEncoderTest { fun testEncodeEmpty() { val channel = EmbeddedChannel(Js5ResponseEncoder) - assertThrows { + assertFailsWith { channel.writeOutbound(Js5Response(true, 2, 3, Unpooled.EMPTY_BUFFER)) } } diff --git a/util/src/test/kotlin/org/openrs2/util/collect/IterableUtilsTest.kt b/util/src/test/kotlin/org/openrs2/util/collect/IterableUtilsTest.kt index 0f1523d2..4c9b51b4 100644 --- a/util/src/test/kotlin/org/openrs2/util/collect/IterableUtilsTest.kt +++ b/util/src/test/kotlin/org/openrs2/util/collect/IterableUtilsTest.kt @@ -1,8 +1,8 @@ package org.openrs2.util.collect -import org.junit.jupiter.api.assertThrows import kotlin.test.Test import kotlin.test.assertEquals +import kotlin.test.assertFailsWith import kotlin.test.assertFalse import kotlin.test.assertNull import kotlin.test.assertTrue @@ -20,7 +20,7 @@ object IterableUtilsTest { assertEquals(3, list.removeFirst()) assertEquals(emptyList(), list) - assertThrows { + assertFailsWith { list.removeFirst() } }