From 4ccebc7ef818432f142fe828532978061a0b79c9 Mon Sep 17 00:00:00 2001 From: Graham Date: Sat, 6 Feb 2021 20:52:27 +0000 Subject: [PATCH] Replace assertThrows with assertFailsWith Signed-off-by: Graham --- .../openrs2/cache/DiskStoreZipWriterTest.kt | 26 +++++++++---------- .../org/openrs2/cache/Js5MasterIndexTest.kt | 6 ++--- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cache/src/test/kotlin/org/openrs2/cache/DiskStoreZipWriterTest.kt b/cache/src/test/kotlin/org/openrs2/cache/DiskStoreZipWriterTest.kt index 65e3a9911e..f7e90f53d5 100644 --- a/cache/src/test/kotlin/org/openrs2/cache/DiskStoreZipWriterTest.kt +++ b/cache/src/test/kotlin/org/openrs2/cache/DiskStoreZipWriterTest.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.recursiveEquals @@ -12,6 +11,7 @@ import java.nio.file.Files import java.nio.file.Path import java.util.zip.ZipOutputStream import kotlin.test.Test +import kotlin.test.assertFailsWith import kotlin.test.assertTrue object DiskStoreZipWriterTest { @@ -21,7 +21,7 @@ object DiskStoreZipWriterTest { fun testBounds() { DiskStoreZipWriter(ZipOutputStream(OutputStream.nullOutputStream())).use { store -> // create - assertThrows { + assertFailsWith { store.create(-1) } @@ -30,12 +30,12 @@ object DiskStoreZipWriterTest { store.create(254) store.create(255) - assertThrows { + assertFailsWith { store.create(256) } // write archive - assertThrows { + assertFailsWith { store.write(-1, 0, Unpooled.EMPTY_BUFFER) } @@ -44,12 +44,12 @@ object DiskStoreZipWriterTest { store.write(254, 0, Unpooled.EMPTY_BUFFER) store.write(255, 0, Unpooled.EMPTY_BUFFER) - assertThrows { + assertFailsWith { store.write(256, 0, Unpooled.EMPTY_BUFFER) } // write group - assertThrows { + assertFailsWith { store.write(0, -1, Unpooled.EMPTY_BUFFER) } @@ -61,31 +61,31 @@ object DiskStoreZipWriterTest { @Test fun testUnsupported() { DiskStoreZipWriter(ZipOutputStream(OutputStream.nullOutputStream())).use { store -> - assertThrows { + assertFailsWith { store.exists(0) } - assertThrows { + assertFailsWith { store.exists(0, 0) } - assertThrows { + assertFailsWith { store.list() } - assertThrows { + assertFailsWith { store.list(0) } - assertThrows { + assertFailsWith { store.read(0, 0) } - assertThrows { + assertFailsWith { store.remove(0) } - assertThrows { + assertFailsWith { store.remove(0, 0) } } diff --git a/cache/src/test/kotlin/org/openrs2/cache/Js5MasterIndexTest.kt b/cache/src/test/kotlin/org/openrs2/cache/Js5MasterIndexTest.kt index 119b68d79c..6ae4916ca1 100644 --- a/cache/src/test/kotlin/org/openrs2/cache/Js5MasterIndexTest.kt +++ b/cache/src/test/kotlin/org/openrs2/cache/Js5MasterIndexTest.kt @@ -2,11 +2,11 @@ package org.openrs2.cache import io.netty.buffer.ByteBufAllocator import io.netty.buffer.Unpooled -import org.junit.jupiter.api.assertThrows import org.openrs2.buffer.use import java.nio.file.Path import kotlin.test.Test import kotlin.test.assertEquals +import kotlin.test.assertFailsWith object Js5MasterIndexTest { private val ROOT = Path.of(FlatFileStoreTest::class.java.getResource("master-index").toURI()) @@ -63,7 +63,7 @@ object Js5MasterIndexTest { assertEquals(decodedOriginal, index) } - assertThrows { + assertFailsWith { Unpooled.wrappedBuffer(byteArrayOf(0)).use { buf -> Js5MasterIndex.read(buf, MasterIndexFormat.ORIGINAL) } @@ -88,7 +88,7 @@ object Js5MasterIndexTest { assertEquals(decodedVersioned, index) } - assertThrows { + assertFailsWith { Unpooled.wrappedBuffer(byteArrayOf(0, 0, 0, 0)).use { buf -> Js5MasterIndex.read(buf, MasterIndexFormat.VERSIONED) }