1
0
mirror of https://github.com/square/okhttp.git synced 2025-07-29 17:41:17 +03:00

Switch to assertFailsWith (#8177)

* Switch to assertk.fail

* Use assertFailsWith

* More assertFailsWith

* Use more assertFailsWith

* More assertFailsWith

* More assertFailsWith

* Native image dependencies

* Move JUnit dependency

* Don't lock in a specific implementation class

* Missing finally
This commit is contained in:
Jesse Wilson
2024-01-06 00:31:00 -05:00
committed by GitHub
parent 8ebb4b1f94
commit 23d67c304f
68 changed files with 928 additions and 1411 deletions

View File

@ -24,6 +24,8 @@ dependencies {
testImplementation(libs.squareup.okio.fakefilesystem)
testImplementation(libs.conscrypt.openjdk)
testImplementation(libs.junit)
testImplementation(libs.kotlin.test.common)
testImplementation(libs.kotlin.test.junit)
}
mavenPublishing {

View File

@ -22,6 +22,7 @@ import assertk.assertions.isEqualTo
import assertk.fail
import java.net.InetAddress
import java.net.UnknownHostException
import kotlin.test.assertFailsWith
import okhttp3.AsyncDns.Companion.TYPE_A
import okhttp3.AsyncDns.Companion.TYPE_AAAA
import okhttp3.dnsoverhttps.DnsRecordCodec.decodeAnswers
@ -80,16 +81,15 @@ class DnsRecordCodecTest {
@Test
fun testGoogleDotComDecodingNxdomainFailure() {
try {
assertFailsWith<UnknownHostException> {
decodeAnswers(
hostname = "sdflkhfsdlkjdf.ee",
byteString = ("0000818300010000000100000e7364666c6b686673646c6b6a64660265650000010001c01b" +
"00060001000007070038026e7303746c64c01b0a686f73746d61737465720d6565737469696e7465726e65" +
"74c01b5adb12c100000e10000003840012750000000e10").decodeHex()
)
fail("")
} catch (uhe: UnknownHostException) {
assertThat(uhe.message).isEqualTo("sdflkhfsdlkjdf.ee: NXDOMAIN")
}.also { expected ->
assertThat(expected.message).isEqualTo("sdflkhfsdlkjdf.ee: NXDOMAIN")
}
}
}