Revert "WIP"

This reverts commit c09b0f57631905a7b9cca32be5516853e4263ac0.
This commit is contained in:
Arjen Poutsma
2024-05-16 14:10:45 +02:00
parent 14861024d5
commit 67d2b2566e
5 changed files with 40 additions and 111 deletions

View File

@@ -117,14 +117,13 @@ class FormHttpMessageConverterTests {
assertCanWrite(MULTIPART_RELATED);
}
@SuppressWarnings("unchecked")
@Test
void readMultiValueForm() throws Exception {
void readForm() throws Exception {
String body = "name+1=value+1&name+2=value+2%2B1&name+2=value+2%2B2&name+3";
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes(StandardCharsets.ISO_8859_1));
inputMessage.getHeaders().setContentType(
new MediaType("application", "x-www-form-urlencoded", StandardCharsets.ISO_8859_1));
MultiValueMap<String, String> result = (MultiValueMap<String, String>) this.converter.read(null, inputMessage);
MultiValueMap<String, String> result = this.converter.read(null, inputMessage);
assertThat(result).as("Invalid result").hasSize(3);
assertThat(result.getFirst("name 1")).as("Invalid result").isEqualTo("value 1");
@@ -133,21 +132,6 @@ class FormHttpMessageConverterTests {
assertThat(result.getFirst("name 3")).as("Invalid result").isNull();
}
@SuppressWarnings("unchecked")
@Test
void readSingleValueForm() throws Exception {
String body = "name+1=value+1&name+2=value+2&name+3";
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes(StandardCharsets.ISO_8859_1));
inputMessage.getHeaders().setContentType(
new MediaType("application", "x-www-form-urlencoded", StandardCharsets.ISO_8859_1));
Map<String, String> result = (Map<String, String>) this.converter.read((Class<? extends Map<String, ?>>) Map.class, inputMessage);
assertThat(result).as("Invalid result").hasSize(3);
assertThat(result.get("name 1")).as("Invalid result").isEqualTo("value 1");
assertThat(result.get("name 2")).as("Invalid result").isEqualTo("value 2");
assertThat(result.get("name 3")).as("Invalid result").isNull();
}
@Test
void writeForm() throws IOException {
MultiValueMap<String, String> body = new LinkedMultiValueMap<>();