Remove HttpHeaders#asMultiValueMap usages from Kotlin tests

Closes gh-34327
This commit is contained in:
Sébastien Deleuze
2025-01-27 15:57:35 +01:00
parent 36cd069c6e
commit db3c2b39b1
3 changed files with 18 additions and 35 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -170,8 +170,7 @@ class KotlinSerializationCborHttpMessageConverterTests {
this.converter.write(serializableBean, null, outputMessage)
@Suppress("DEPRECATION")
assertThat(outputMessage.headers.asMultiValueMap()).containsEntry("Content-Type", listOf("application/cbor"))
assertThat(outputMessage.headers.containsHeaderValue("Content-Type", "application/cbor")).isTrue()
assertThat(outputMessage.bodyAsBytes.isNotEmpty()).isTrue()
}
@@ -182,8 +181,7 @@ class KotlinSerializationCborHttpMessageConverterTests {
this.converter.write(serializableBean, null, outputMessage)
@Suppress("DEPRECATION")
assertThat(outputMessage.headers.asMultiValueMap()).containsEntry("Content-Type", listOf("application/cbor"))
assertThat(outputMessage.headers.containsHeaderValue("Content-Type", "application/cbor")).isTrue()
assertThat(outputMessage.bodyAsBytes.isNotEmpty()).isTrue()
}
@@ -193,8 +191,7 @@ class KotlinSerializationCborHttpMessageConverterTests {
this.converter.write(serializableBeanArray, null, outputMessage)
@Suppress("DEPRECATION")
assertThat(outputMessage.headers.asMultiValueMap()).containsEntry("Content-Type", listOf("application/cbor"))
assertThat(outputMessage.headers.containsHeaderValue("Content-Type", "application/cbor")).isTrue()
assertThat(outputMessage.bodyAsBytes.isNotEmpty()).isTrue()
}
@@ -205,8 +202,7 @@ class KotlinSerializationCborHttpMessageConverterTests {
this.converter.write(listOf(serializableBean), ResolvableType.forType(typeOf<List<SerializableBean>>().javaType), null, outputMessage, null)
@Suppress("DEPRECATION")
assertThat(outputMessage.headers.asMultiValueMap()).containsEntry("Content-Type", listOf("application/cbor"))
assertThat(outputMessage.headers.containsHeaderValue("Content-Type", "application/cbor")).isTrue()
assertThat(outputMessage.bodyAsBytes.isNotEmpty()).isTrue()
}

View File

@@ -255,8 +255,7 @@ class KotlinSerializationJsonHttpMessageConverterTests {
val result = outputMessage.getBodyAsString(StandardCharsets.UTF_8)
@Suppress("DEPRECATION")
assertThat(outputMessage.headers.asMultiValueMap()).containsEntry("Content-Type", listOf("application/json"))
assertThat(outputMessage.headers.containsHeaderValue("Content-Type", "application/json")).isTrue()
assertThat(result)
.contains("\"bytes\":[1,2]")
.contains("\"array\":[\"Foo\",\"Bar\"]")
@@ -275,8 +274,7 @@ class KotlinSerializationJsonHttpMessageConverterTests {
val result = outputMessage.getBodyAsString(StandardCharsets.UTF_8)
@Suppress("DEPRECATION")
assertThat(outputMessage.headers.asMultiValueMap()).containsEntry("Content-Type", listOf("application/json"))
assertThat(outputMessage.headers.containsHeaderValue("Content-Type", "application/json")).isTrue()
assertThat(result)
.contains("\"bytes\":[1,2]")
.contains("\"array\":[\"Foo\",\"Bar\"]")
@@ -298,8 +296,7 @@ class KotlinSerializationJsonHttpMessageConverterTests {
val result = outputMessage.getBodyAsString(StandardCharsets.UTF_8)
@Suppress("DEPRECATION")
assertThat(outputMessage.headers.asMultiValueMap()).containsEntry("Content-Type", listOf("application/json"))
assertThat(outputMessage.headers.containsHeaderValue("Content-Type", "application/json")).isTrue()
assertThat(result).isEqualTo(expectedJson)
}
@@ -317,8 +314,7 @@ class KotlinSerializationJsonHttpMessageConverterTests {
val result = outputMessage.getBodyAsString(StandardCharsets.UTF_8)
@Suppress("DEPRECATION")
assertThat(outputMessage.headers.asMultiValueMap()).containsEntry("Content-Type", listOf("application/json"))
assertThat(outputMessage.headers.containsHeaderValue("Content-Type", "application/json")).isTrue()
assertThat(result).isEqualTo(expectedJson)
}
@@ -332,8 +328,7 @@ class KotlinSerializationJsonHttpMessageConverterTests {
val result = outputMessage.getBodyAsString(StandardCharsets.UTF_16BE)
@Suppress("DEPRECATION")
assertThat(outputMessage.headers.asMultiValueMap()).containsEntry("Content-Type", listOf(contentType.toString()))
assertThat(outputMessage.headers.containsHeaderValue("Content-Type", contentType.toString())).isTrue()
assertThat(result).isEqualTo("\"H\u00e9llo W\u00f6rld\"")
}
@@ -369,8 +364,7 @@ class KotlinSerializationJsonHttpMessageConverterTests {
val result = outputMessage.getBodyAsString(StandardCharsets.UTF_8)
@Suppress("DEPRECATION")
assertThat(outputMessage.headers.asMultiValueMap()).containsEntry("Content-Type", listOf("application/json"))
assertThat(outputMessage.headers.containsHeaderValue("Content-Type", "application/json")).isTrue()
assertThat(result).isEqualTo("1.0")
}
@@ -387,8 +381,7 @@ class KotlinSerializationJsonHttpMessageConverterTests {
val result = outputMessage.getBodyAsString(StandardCharsets.UTF_8)
@Suppress("DEPRECATION")
assertThat(outputMessage.headers.asMultiValueMap()).containsEntry("Content-Type", listOf("application/json"))
assertThat(outputMessage.headers.containsHeaderValue("Content-Type", "application/json")).isTrue()
assertThat(result).isEqualTo(expectedJson)
}
@@ -401,8 +394,7 @@ class KotlinSerializationJsonHttpMessageConverterTests {
this.converter.write(value, ResolvableType.forMethodParameter(methodParameter), null, outputMessage, null)
val result = outputMessage.getBodyAsString(StandardCharsets.UTF_8)
@Suppress("DEPRECATION")
assertThat(outputMessage.headers.asMultiValueMap()).containsEntry("Content-Type", listOf("application/json"))
assertThat(outputMessage.headers.containsHeaderValue("Content-Type", "application/json")).isTrue()
assertThat(result).isEqualTo("42")
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -186,8 +186,7 @@ class KotlinSerializationProtobufHttpMessageConverterTests {
this.converter.write(serializableBean, null, outputMessage)
@Suppress("DEPRECATION")
assertThat(outputMessage.headers.asMultiValueMap()).containsEntry("Content-Type", listOf("application/x-protobuf"))
assertThat(outputMessage.headers.containsHeaderValue("Content-Type", "application/x-protobuf")).isTrue()
assertThat(outputMessage.bodyAsBytes.isNotEmpty()).isTrue()
}
@@ -197,9 +196,7 @@ class KotlinSerializationProtobufHttpMessageConverterTests {
val serializableBean = SerializableBean(byteArrayOf(0x1, 0x2), arrayOf("Foo", "Bar"), 42, null, true, 42.0f)
this.converter.write(serializableBean, null, outputMessage)
@Suppress("DEPRECATION")
assertThat(outputMessage.headers.asMultiValueMap()).containsEntry("Content-Type", listOf("application/x-protobuf"))
assertThat(outputMessage.headers.containsHeaderValue("Content-Type", "application/x-protobuf")).isTrue()
assertThat(outputMessage.bodyAsBytes.isNotEmpty()).isTrue()
}
@@ -209,8 +206,7 @@ class KotlinSerializationProtobufHttpMessageConverterTests {
this.converter.write(serializableBeanArray, null, outputMessage)
@Suppress("DEPRECATION")
assertThat(outputMessage.headers.asMultiValueMap()).containsEntry("Content-Type", listOf("application/x-protobuf"))
assertThat(outputMessage.headers.containsHeaderValue("Content-Type", "application/x-protobuf")).isTrue()
assertThat(outputMessage.bodyAsBytes.isNotEmpty()).isTrue()
}
@@ -221,8 +217,7 @@ class KotlinSerializationProtobufHttpMessageConverterTests {
this.converter.write(listOf(serializableBean), ResolvableType.forType(typeOf<List<SerializableBean>>().javaType), null, outputMessage, null)
@Suppress("DEPRECATION")
assertThat(outputMessage.headers.asMultiValueMap()).containsEntry("Content-Type", listOf("application/x-protobuf"))
assertThat(outputMessage.headers.containsHeaderValue("Content-Type", "application/x-protobuf")).isTrue()
assertThat(outputMessage.bodyAsBytes.isNotEmpty()).isTrue()
}