Replace assertThrows with assertFailsWith

Signed-off-by: Graham <gpe@openrs2.org>
bzip2
Graham 4 years ago
parent 8fcf7cae46
commit 4ccebc7ef8
  1. 26
      cache/src/test/kotlin/org/openrs2/cache/DiskStoreZipWriterTest.kt
  2. 6
      cache/src/test/kotlin/org/openrs2/cache/Js5MasterIndexTest.kt

@ -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.recursiveEquals import org.openrs2.util.io.recursiveEquals
@ -12,6 +11,7 @@ import java.nio.file.Files
import java.nio.file.Path import java.nio.file.Path
import java.util.zip.ZipOutputStream import java.util.zip.ZipOutputStream
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertFailsWith
import kotlin.test.assertTrue import kotlin.test.assertTrue
object DiskStoreZipWriterTest { object DiskStoreZipWriterTest {
@ -21,7 +21,7 @@ object DiskStoreZipWriterTest {
fun testBounds() { fun testBounds() {
DiskStoreZipWriter(ZipOutputStream(OutputStream.nullOutputStream())).use { store -> DiskStoreZipWriter(ZipOutputStream(OutputStream.nullOutputStream())).use { store ->
// create // create
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.create(-1) store.create(-1)
} }
@ -30,12 +30,12 @@ object DiskStoreZipWriterTest {
store.create(254) store.create(254)
store.create(255) store.create(255)
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.create(256) store.create(256)
} }
// write archive // write archive
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.write(-1, 0, Unpooled.EMPTY_BUFFER) store.write(-1, 0, Unpooled.EMPTY_BUFFER)
} }
@ -44,12 +44,12 @@ object DiskStoreZipWriterTest {
store.write(254, 0, Unpooled.EMPTY_BUFFER) store.write(254, 0, Unpooled.EMPTY_BUFFER)
store.write(255, 0, Unpooled.EMPTY_BUFFER) store.write(255, 0, Unpooled.EMPTY_BUFFER)
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.write(256, 0, Unpooled.EMPTY_BUFFER) store.write(256, 0, Unpooled.EMPTY_BUFFER)
} }
// write group // write group
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
store.write(0, -1, Unpooled.EMPTY_BUFFER) store.write(0, -1, Unpooled.EMPTY_BUFFER)
} }
@ -61,31 +61,31 @@ object DiskStoreZipWriterTest {
@Test @Test
fun testUnsupported() { fun testUnsupported() {
DiskStoreZipWriter(ZipOutputStream(OutputStream.nullOutputStream())).use { store -> DiskStoreZipWriter(ZipOutputStream(OutputStream.nullOutputStream())).use { store ->
assertThrows<UnsupportedOperationException> { assertFailsWith<UnsupportedOperationException> {
store.exists(0) store.exists(0)
} }
assertThrows<UnsupportedOperationException> { assertFailsWith<UnsupportedOperationException> {
store.exists(0, 0) store.exists(0, 0)
} }
assertThrows<UnsupportedOperationException> { assertFailsWith<UnsupportedOperationException> {
store.list() store.list()
} }
assertThrows<UnsupportedOperationException> { assertFailsWith<UnsupportedOperationException> {
store.list(0) store.list(0)
} }
assertThrows<UnsupportedOperationException> { assertFailsWith<UnsupportedOperationException> {
store.read(0, 0) store.read(0, 0)
} }
assertThrows<UnsupportedOperationException> { assertFailsWith<UnsupportedOperationException> {
store.remove(0) store.remove(0)
} }
assertThrows<UnsupportedOperationException> { assertFailsWith<UnsupportedOperationException> {
store.remove(0, 0) store.remove(0, 0)
} }
} }

@ -2,11 +2,11 @@ package org.openrs2.cache
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.use import org.openrs2.buffer.use
import java.nio.file.Path import java.nio.file.Path
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
object Js5MasterIndexTest { object Js5MasterIndexTest {
private val ROOT = Path.of(FlatFileStoreTest::class.java.getResource("master-index").toURI()) private val ROOT = Path.of(FlatFileStoreTest::class.java.getResource("master-index").toURI())
@ -63,7 +63,7 @@ object Js5MasterIndexTest {
assertEquals(decodedOriginal, index) assertEquals(decodedOriginal, index)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
Unpooled.wrappedBuffer(byteArrayOf(0)).use { buf -> Unpooled.wrappedBuffer(byteArrayOf(0)).use { buf ->
Js5MasterIndex.read(buf, MasterIndexFormat.ORIGINAL) Js5MasterIndex.read(buf, MasterIndexFormat.ORIGINAL)
} }
@ -88,7 +88,7 @@ object Js5MasterIndexTest {
assertEquals(decodedVersioned, index) assertEquals(decodedVersioned, index)
} }
assertThrows<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
Unpooled.wrappedBuffer(byteArrayOf(0, 0, 0, 0)).use { buf -> Unpooled.wrappedBuffer(byteArrayOf(0, 0, 0, 0)).use { buf ->
Js5MasterIndex.read(buf, MasterIndexFormat.VERSIONED) Js5MasterIndex.read(buf, MasterIndexFormat.VERSIONED)
} }

Loading…
Cancel
Save