Replace assertThrows with assertFailsWith

Signed-off-by: Graham <gpe@openrs2.org>
bzip2
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.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<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
buf.writeShortSmart(-0x4001)
}
}
ByteBufAllocator.DEFAULT.buffer().use { buf ->
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
buf.writeShortSmart(0x4000)
}
}
@ -209,13 +209,13 @@ object ByteBufExtensionsTest {
}
ByteBufAllocator.DEFAULT.buffer().use { buf ->
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
buf.writeUnsignedShortSmart(-0x1)
}
}
ByteBufAllocator.DEFAULT.buffer().use { buf ->
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
buf.writeUnsignedShortSmart(0x10000)
}
}
@ -311,13 +311,13 @@ object ByteBufExtensionsTest {
}
ByteBufAllocator.DEFAULT.buffer().use { buf ->
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
buf.writeIntSmart(-0x40000001)
}
}
ByteBufAllocator.DEFAULT.buffer().use { buf ->
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
buf.writeIntSmart(0x40000000)
}
}
@ -401,7 +401,7 @@ object ByteBufExtensionsTest {
}
ByteBufAllocator.DEFAULT.buffer().use { buf ->
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
buf.writeUnsignedIntSmart(0x80000000.toInt())
}
}
@ -450,19 +450,19 @@ object ByteBufExtensionsTest {
@Test
fun testCrc32Bounds() {
assertThrows<IndexOutOfBoundsException> {
assertFailsWith<IndexOutOfBoundsException> {
Unpooled.EMPTY_BUFFER.crc32(-1, 0)
}
assertThrows<IndexOutOfBoundsException> {
assertFailsWith<IndexOutOfBoundsException> {
Unpooled.EMPTY_BUFFER.crc32(0, -1)
}
assertThrows<IndexOutOfBoundsException> {
assertFailsWith<IndexOutOfBoundsException> {
Unpooled.EMPTY_BUFFER.crc32(1, 0)
}
assertThrows<IndexOutOfBoundsException> {
assertFailsWith<IndexOutOfBoundsException> {
Unpooled.EMPTY_BUFFER.crc32(0, 1)
}
}

@ -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<EOFException> {
assertFailsWith<EOFException> {
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<EOFException> {
assertFailsWith<EOFException> {
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.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<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.exists(-1)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.exists(256)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.list(-1)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.list(256)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.exists(-1, 0)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.exists(256, 0)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.exists(0, -1)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.read(-1, 0).release()
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.read(256, 0).release()
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.read(0, -1).release()
}
}
writeTest("empty") { store ->
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.create(-1)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.create(256)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.write(-1, 0, Unpooled.EMPTY_BUFFER)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.write(256, 0, Unpooled.EMPTY_BUFFER)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.write(0, -1, Unpooled.EMPTY_BUFFER)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.remove(-1)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.remove(256)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.remove(-1, 0)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.remove(256, 0)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.remove(0, -1)
}
}
@ -200,7 +200,7 @@ object DiskStoreTest {
@Test
fun testListNonExistent() {
readTest("empty") { store ->
assertThrows<FileNotFoundException> {
assertFailsWith<FileNotFoundException> {
store.list(0)
}
}
@ -275,15 +275,15 @@ object DiskStoreTest {
@Test
fun testReadNonExistent() {
readTest("single-block") { store ->
assertThrows<FileNotFoundException> {
assertFailsWith<FileNotFoundException> {
store.read(0, 0)
}
assertThrows<FileNotFoundException> {
assertFailsWith<FileNotFoundException> {
store.read(255, 0)
}
assertThrows<FileNotFoundException> {
assertFailsWith<FileNotFoundException> {
store.read(255, 2)
}
}
@ -498,67 +498,67 @@ object DiskStoreTest {
@Test
fun testReadCorrupt() {
readTest("corrupt-eof-late") { store ->
assertThrows<StoreCorruptException> {
assertFailsWith<StoreCorruptException> {
store.read(255, 1).release()
}
}
readTest("corrupt-first-eof-early") { store ->
assertThrows<StoreCorruptException> {
assertFailsWith<StoreCorruptException> {
store.read(255, 1).release()
}
}
readTest("corrupt-first-invalid-archive") { store ->
assertThrows<StoreCorruptException> {
assertFailsWith<StoreCorruptException> {
store.read(255, 1).release()
}
}
readTest("corrupt-first-invalid-block-number") { store ->
assertThrows<StoreCorruptException> {
assertFailsWith<StoreCorruptException> {
store.read(255, 1).release()
}
}
readTest("corrupt-first-invalid-group") { store ->
assertThrows<StoreCorruptException> {
assertFailsWith<StoreCorruptException> {
store.read(255, 1).release()
}
}
readTest("corrupt-first-outside-data-file") { store ->
assertThrows<StoreCorruptException> {
assertFailsWith<StoreCorruptException> {
store.read(255, 1).release()
}
}
readTest("corrupt-second-eof-early") { store ->
assertThrows<StoreCorruptException> {
assertFailsWith<StoreCorruptException> {
store.read(255, 1).release()
}
}
readTest("corrupt-second-invalid-archive") { store ->
assertThrows<StoreCorruptException> {
assertFailsWith<StoreCorruptException> {
store.read(255, 1).release()
}
}
readTest("corrupt-second-invalid-block-number") { store ->
assertThrows<StoreCorruptException> {
assertFailsWith<StoreCorruptException> {
store.read(255, 1).release()
}
}
readTest("corrupt-second-invalid-group") { store ->
assertThrows<StoreCorruptException> {
assertFailsWith<StoreCorruptException> {
store.read(255, 1).release()
}
}
readTest("corrupt-second-outside-data-file") { store ->
assertThrows<StoreCorruptException> {
assertFailsWith<StoreCorruptException> {
store.read(255, 1).release()
}
}

@ -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<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.exists(-1)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.exists(256)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.list(-1)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.list(256)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.exists(-1, 0)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.exists(256, 0)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.exists(0, -1)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.read(-1, 0).release()
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.read(256, 0).release()
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.read(0, -1).release()
}
}
writeTest("empty") { store ->
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.create(-1)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.create(256)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.write(-1, 0, Unpooled.EMPTY_BUFFER)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.write(256, 0, Unpooled.EMPTY_BUFFER)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.write(0, -1, Unpooled.EMPTY_BUFFER)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.remove(-1)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.remove(256)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.remove(-1, 0)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
store.remove(256, 0)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
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<FileNotFoundException> {
assertFailsWith<FileNotFoundException> {
store.list(1)
}
assertThrows<FileNotFoundException> {
assertFailsWith<FileNotFoundException> {
store.list(254)
}
}
@ -174,11 +174,11 @@ object FlatFileStoreTest {
assertEquals(Unpooled.EMPTY_BUFFER, actual)
}
assertThrows<FileNotFoundException> {
assertFailsWith<FileNotFoundException> {
store.read(0, 2).release()
}
assertThrows<FileNotFoundException> {
assertFailsWith<FileNotFoundException> {
store.read(1, 0).release()
}

@ -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<IOException> {
assertFailsWith<IOException> {
Js5Compression.uncompress(compressed.slice()).release()
}
assertThrows<IOException> {
assertFailsWith<IOException> {
Js5Compression.isKeyValid(compressed.slice(), XteaKey.ZERO)
}
}
@ -277,11 +277,11 @@ object Js5CompressionTest {
@Test
fun testInvalidLength() {
read("invalid-length.dat").use { compressed ->
assertThrows<IOException> {
assertFailsWith<IOException> {
Js5Compression.uncompress(compressed.slice()).release()
}
assertThrows<IOException> {
assertFailsWith<IOException> {
Js5Compression.isKeyValid(compressed.slice(), XteaKey.ZERO)
}
}
@ -290,7 +290,7 @@ object Js5CompressionTest {
@Test
fun testInvalidUncompressedLength() {
read("invalid-uncompressed-length.dat").use { compressed ->
assertThrows<IOException> {
assertFailsWith<IOException> {
Js5Compression.uncompress(compressed.slice()).release()
}
@ -301,7 +301,7 @@ object Js5CompressionTest {
@Test
fun testNoneEof() {
read("none-eof.dat").use { compressed ->
assertThrows<IOException> {
assertFailsWith<IOException> {
Js5Compression.uncompress(compressed).release()
}
}
@ -310,7 +310,7 @@ object Js5CompressionTest {
@Test
fun testBzip2Eof() {
read("bzip2-eof.dat").use { compressed ->
assertThrows<IOException> {
assertFailsWith<IOException> {
Js5Compression.uncompress(compressed.slice()).release()
}
@ -321,7 +321,7 @@ object Js5CompressionTest {
@Test
fun testGzipEof() {
read("gzip-eof.dat").use { compressed ->
assertThrows<IOException> {
assertFailsWith<IOException> {
Js5Compression.uncompress(compressed.slice()).release()
}
@ -332,7 +332,7 @@ object Js5CompressionTest {
@Test
fun testLzmaEof() {
read("lzma-eof.dat").use { compressed ->
assertThrows<IOException> {
assertFailsWith<IOException> {
Js5Compression.uncompress(compressed.slice()).release()
}
@ -343,7 +343,7 @@ object Js5CompressionTest {
@Test
fun testBzip2Corrupt() {
read("bzip2-corrupt.dat").use { compressed ->
assertThrows<IOException> {
assertFailsWith<IOException> {
Js5Compression.uncompress(compressed.slice()).release()
}
@ -354,7 +354,7 @@ object Js5CompressionTest {
@Test
fun testGzipCorrupt() {
read("gzip-corrupt.dat").use { compressed ->
assertThrows<IOException> {
assertFailsWith<IOException> {
Js5Compression.uncompress(compressed.slice()).release()
}
@ -365,7 +365,7 @@ object Js5CompressionTest {
@Test
fun testLzmaCorrupt() {
read("lzma-corrupt.dat").use { compressed ->
assertThrows<IOException> {
assertFailsWith<IOException> {
Js5Compression.uncompress(compressed.slice()).release()
}
@ -461,7 +461,7 @@ object Js5CompressionTest {
@Test
fun testKeyValidShorterThanTwoBlocks() {
read("shorter-than-two-blocks.dat").use { compressed ->
assertThrows<IOException> {
assertFailsWith<IOException> {
Js5Compression.isKeyValid(compressed, XteaKey.ZERO)
}
}
@ -470,11 +470,11 @@ object Js5CompressionTest {
@Test
fun testCompressedUnderflow() {
read("compressed-underflow.dat").use { compressed ->
assertThrows<IOException> {
assertFailsWith<IOException> {
Js5Compression.uncompress(compressed.slice()).release()
}
assertThrows<IOException> {
assertFailsWith<IOException> {
Js5Compression.isKeyValid(compressed.slice(), XteaKey.ZERO)
}
}
@ -483,7 +483,7 @@ object Js5CompressionTest {
@Test
fun testUncompressedOverflow() {
read("uncompressed-overflow.dat").use { compressed ->
assertThrows<IOException> {
assertFailsWith<IOException> {
Js5Compression.uncompress(compressed).release()
}
}
@ -492,7 +492,7 @@ object Js5CompressionTest {
@Test
fun testUncompressedUnderflow() {
read("uncompressed-underflow.dat").use { compressed ->
assertThrows<IOException> {
assertFailsWith<IOException> {
Js5Compression.uncompress(compressed).release()
}
}

@ -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<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
Js5Index.read(buf)
}
}
wrappedBuffer(8).use { buf ->
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
Js5Index.read(buf)
}
}
@ -228,7 +228,7 @@ object Js5IndexTest {
index.createOrGet(65536)
ByteBufAllocator.DEFAULT.buffer().use { buf ->
assertThrows<IllegalStateException> {
assertFailsWith<IllegalStateException> {
index.write(buf)
}
}

@ -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<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
-1 in collection
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
collection.containsNamed(-1)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
collection[-1]
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
collection.getNamed(-1)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
collection.createOrGet(-1)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
collection.createOrGetNamed(-1)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
collection.remove(-1)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
collection.removeNamed(-1)
}
}
@ -590,17 +590,17 @@ object NamedEntryCollectionTest {
val it = collection.iterator()
assertThrows<IllegalStateException> {
assertFailsWith<IllegalStateException> {
it.remove()
}
assertFalse(it.hasNext())
assertThrows<NoSuchElementException> {
assertFailsWith<NoSuchElementException> {
it.next()
}
assertThrows<IllegalStateException> {
assertFailsWith<IllegalStateException> {
it.remove()
}
}
@ -615,7 +615,7 @@ object NamedEntryCollectionTest {
val it = collection.iterator()
assertThrows<IllegalStateException> {
assertFailsWith<IllegalStateException> {
it.remove()
}
@ -624,11 +624,11 @@ object NamedEntryCollectionTest {
assertFalse(it.hasNext())
assertThrows<NoSuchElementException> {
assertFailsWith<NoSuchElementException> {
it.next()
}
assertThrows<IllegalStateException> {
assertFailsWith<IllegalStateException> {
it.remove()
}
}
@ -647,7 +647,7 @@ object NamedEntryCollectionTest {
val it = collection.iterator()
assertThrows<IllegalStateException> {
assertFailsWith<IllegalStateException> {
it.remove()
}
@ -659,11 +659,11 @@ object NamedEntryCollectionTest {
assertFalse(it.hasNext())
assertThrows<NoSuchElementException> {
assertFailsWith<NoSuchElementException> {
it.next()
}
assertThrows<IllegalStateException> {
assertFailsWith<IllegalStateException> {
it.remove()
}
}
@ -683,7 +683,7 @@ object NamedEntryCollectionTest {
it.remove()
assertThrows<IllegalStateException> {
assertFailsWith<IllegalStateException> {
it.remove()
}
@ -713,7 +713,7 @@ object NamedEntryCollectionTest {
it.remove()
assertThrows<IllegalStateException> {
assertFailsWith<IllegalStateException> {
it.remove()
}
@ -722,7 +722,7 @@ object NamedEntryCollectionTest {
it.remove()
assertThrows<IllegalStateException> {
assertFailsWith<IllegalStateException> {
it.remove()
}

@ -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<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
strategy.getDelay(-1)
}
}
@Test
fun testBinaryExponentialBackoff() {
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
BinaryExponentialBackoffStrategy(0, 1)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
BinaryExponentialBackoffStrategy(1, 0)
}
assertThrows<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
BinaryExponentialBackoffStrategy(1, 1).getDelay(-1)
}
}

@ -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<IllegalArgumentException> {
assertFailsWith<IllegalArgumentException> {
Database(dataSource, attempts = 0)
}
}
@ -86,7 +86,7 @@ object DatabaseTest {
fun testDeadlockFailure() {
var attempts = 0
assertThrows<DeadlockException> {
assertFailsWith<DeadlockException> {
runBlockingTest {
database.execute<Unit> {
attempts++
@ -102,7 +102,7 @@ object DatabaseTest {
fun testNonDeadlockFailure() {
var attempts = 0
assertThrows<TestException> {
assertFailsWith<TestException> {
runBlockingTest {
database.execute<Unit> {
attempts++
@ -168,7 +168,7 @@ object DatabaseTest {
fun testNonDeadlockNextChain() {
var attempts = 0
assertThrows<NonDeadlockException> {
assertFailsWith<NonDeadlockException> {
runBlockingTest {
database.execute<Unit> {
attempts++

@ -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<DecoderException> {
assertFailsWith<DecoderException> {
channel.writeInbound(wrappedBuffer(0))
}
}
@ -53,7 +53,7 @@ object Rs2DecoderTest {
channel.writeInbound(wrappedBuffer(0, 0x11, 0x22, 0x33, 0x44))
channel.readInbound<Packet>()
assertThrows<DecoderException> {
assertFailsWith<DecoderException> {
channel.writeInbound(wrappedBuffer(5))
}
@ -64,7 +64,7 @@ object Rs2DecoderTest {
val actual = channel.readInbound<Packet>()
assertEquals(EmptyPacket, actual)
assertThrows<DecoderException> {
assertFailsWith<DecoderException> {
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.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<ByteBuf>().release()
assertThrows<EncoderException> {
assertFailsWith<EncoderException> {
channel.writeOutbound(VariableBytePacket(ByteArray(256)))
}
assertThrows<EncoderException> {
assertFailsWith<EncoderException> {
channel.writeOutbound(VariableShortPacket(ByteArray(65536)))
}
}
@ -49,7 +49,7 @@ object Rs2EncoderTest {
fun testUnsupported() {
val channel = EmbeddedChannel(Rs2Encoder(Protocol()))
assertThrows<EncoderException> {
assertFailsWith<EncoderException> {
channel.writeOutbound(FixedPacket(0x11223344))
}
}
@ -58,7 +58,7 @@ object Rs2EncoderTest {
fun testLengthMismatch() {
val channel = EmbeddedChannel(Rs2Encoder(Protocol(LengthMismatchPacketCodec)))
assertThrows<EncoderException> {
assertFailsWith<EncoderException> {
channel.writeOutbound(FixedPacket(0x11223344))
}
}
@ -92,7 +92,7 @@ object Rs2EncoderTest {
channel.writeOutbound(FixedPacket(0x11223344))
channel.readOutbound<ByteBuf>().release()
assertThrows<EncoderException> {
assertFailsWith<EncoderException> {
channel.writeOutbound(EmptyPacket)
}
@ -106,7 +106,7 @@ object Rs2EncoderTest {
}
}
assertThrows<EncoderException> {
assertFailsWith<EncoderException> {
channel.writeOutbound(FixedPacket(0x11223344))
}
}

@ -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<DecoderException> {
assertFailsWith<DecoderException> {
channel.writeInbound("Hello, world!")
}
}

@ -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<DecoderException> {
assertFailsWith<DecoderException> {
channel.writeInbound(wrappedBuffer(8, 0, 0, 0))
}
}

@ -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<DecoderException> {
assertFailsWith<DecoderException> {
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<DecoderException> {
assertFailsWith<DecoderException> {
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<DecoderException> {
assertFailsWith<DecoderException> {
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<DecoderException> {
assertFailsWith<DecoderException> {
channel.writeInbound(read("invalid-block-trailer.dat"))
}
}

@ -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<EncoderException> {
assertFailsWith<EncoderException> {
channel.writeOutbound(Js5Response(true, 2, 3, Unpooled.EMPTY_BUFFER))
}
}

@ -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<Int>(), list)
assertThrows<NoSuchElementException> {
assertFailsWith<NoSuchElementException> {
list.removeFirst()
}
}

Loading…
Cancel
Save