Polish
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -28,7 +28,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class HttpEntityTests {
|
||||
class HttpEntityTests {
|
||||
|
||||
@Test
|
||||
void noHeaders() {
|
||||
@@ -104,7 +104,7 @@ public class HttpEntityTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void requestEntity() throws Exception {
|
||||
void requestEntity() {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.TEXT_PLAIN);
|
||||
String body = "foo";
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.http;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.ZoneId;
|
||||
@@ -53,7 +52,7 @@ import static org.assertj.core.api.Assertions.entry;
|
||||
* @author Juergen Hoeller
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
public class HttpHeadersTests {
|
||||
class HttpHeadersTests {
|
||||
|
||||
private final HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
@@ -152,7 +151,7 @@ public class HttpHeadersTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void location() throws URISyntaxException {
|
||||
void location() {
|
||||
URI location = URI.create("https://www.example.com/hotels");
|
||||
headers.setLocation(location);
|
||||
assertThat(headers.getLocation()).as("Invalid Location header").isEqualTo(location);
|
||||
@@ -201,7 +200,7 @@ public class HttpHeadersTests {
|
||||
void ifMatch() {
|
||||
String ifMatch = "\"v2.6\"";
|
||||
headers.setIfMatch(ifMatch);
|
||||
assertThat(headers.getIfMatch()).element(0).as("Invalid If-Match header").isEqualTo(ifMatch);
|
||||
assertThat(headers.getIfMatch()).containsExactly(ifMatch);
|
||||
assertThat(headers.getFirst("If-Match")).as("Invalid If-Match header").isEqualTo("\"v2.6\"");
|
||||
}
|
||||
|
||||
@@ -215,8 +214,7 @@ public class HttpHeadersTests {
|
||||
void ifMatchMultipleHeaders() {
|
||||
headers.add(HttpHeaders.IF_MATCH, "\"v2,0\"");
|
||||
headers.add(HttpHeaders.IF_MATCH, "W/\"v2,1\", \"v2,2\"");
|
||||
assertThat(headers.get(HttpHeaders.IF_MATCH)).element(0).as("Invalid If-Match header").isEqualTo("\"v2,0\"");
|
||||
assertThat(headers.get(HttpHeaders.IF_MATCH)).element(1).as("Invalid If-Match header").isEqualTo("W/\"v2,1\", \"v2,2\"");
|
||||
assertThat(headers.get(HttpHeaders.IF_MATCH)).containsExactly("\"v2,0\"", "W/\"v2,1\", \"v2,2\"");
|
||||
assertThat(headers.getIfMatch()).contains("\"v2,0\"", "W/\"v2,1\"", "\"v2,2\"");
|
||||
}
|
||||
|
||||
@@ -224,7 +222,7 @@ public class HttpHeadersTests {
|
||||
void ifNoneMatch() {
|
||||
String ifNoneMatch = "\"v2.6\"";
|
||||
headers.setIfNoneMatch(ifNoneMatch);
|
||||
assertThat(headers.getIfNoneMatch()).element(0).as("Invalid If-None-Match header").isEqualTo(ifNoneMatch);
|
||||
assertThat(headers.getIfNoneMatch()).containsExactly(ifNoneMatch);
|
||||
assertThat(headers.getFirst("If-None-Match")).as("Invalid If-None-Match header").isEqualTo("\"v2.6\"");
|
||||
}
|
||||
|
||||
@@ -232,7 +230,7 @@ public class HttpHeadersTests {
|
||||
void ifNoneMatchWildCard() {
|
||||
String ifNoneMatch = "*";
|
||||
headers.setIfNoneMatch(ifNoneMatch);
|
||||
assertThat(headers.getIfNoneMatch()).element(0).as("Invalid If-None-Match header").isEqualTo(ifNoneMatch);
|
||||
assertThat(headers.getIfNoneMatch()).containsExactly(ifNoneMatch);
|
||||
assertThat(headers.getFirst("If-None-Match")).as("Invalid If-None-Match header").isEqualTo("*");
|
||||
}
|
||||
|
||||
@@ -492,7 +490,7 @@ public class HttpHeadersTests {
|
||||
}
|
||||
|
||||
@Test // SPR-15603
|
||||
void acceptLanguageWithEmptyValue() throws Exception {
|
||||
void acceptLanguageWithEmptyValue() {
|
||||
this.headers.set(HttpHeaders.ACCEPT_LANGUAGE, "");
|
||||
assertThat(this.headers.getAcceptLanguageAsLocales()).isEqualTo(Collections.emptyList());
|
||||
}
|
||||
@@ -657,7 +655,7 @@ public class HttpHeadersTests {
|
||||
assertThat(headers.containsKey("Alpha")).as("Alpha should have been removed").isFalse();
|
||||
assertThat(headers.containsKey("Bravo")).as("Bravo should be present").isTrue();
|
||||
assertThat(headers.keySet()).containsOnly("Bravo");
|
||||
assertThat(headers.entrySet()).containsOnly(entry("Bravo", Arrays.asList("banana")));
|
||||
assertThat(headers.entrySet()).containsOnly(entry("Bravo", List.of("banana")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -671,7 +669,7 @@ public class HttpHeadersTests {
|
||||
headers.keySet().removeIf(key -> key.equals(headerName));
|
||||
assertThat(headers).isEmpty();
|
||||
headers.add(headerName, headerValue);
|
||||
assertThat(headers.get(headerName)).element(0).isEqualTo(headerValue);
|
||||
assertThat(headers.get(headerName)).containsExactly(headerValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -685,7 +683,7 @@ public class HttpHeadersTests {
|
||||
headers.entrySet().removeIf(entry -> entry.getKey().equals(headerName));
|
||||
assertThat(headers).isEmpty();
|
||||
headers.add(headerName, headerValue);
|
||||
assertThat(headers.get(headerName)).element(0).isEqualTo(headerValue);
|
||||
assertThat(headers.get(headerName)).containsExactly(headerValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -26,7 +26,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class HttpMethodTests {
|
||||
|
||||
@Test
|
||||
public void comparison() {
|
||||
void comparison() {
|
||||
HttpMethod method1 = HttpMethod.valueOf("FOO");
|
||||
HttpMethod method2 = HttpMethod.valueOf("FOO");
|
||||
HttpMethod method3 = HttpMethod.valueOf("BAR");
|
||||
|
||||
@@ -38,63 +38,63 @@ import static org.mockito.Mockito.mock;
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
public class HttpRangeTests {
|
||||
class HttpRangeTests {
|
||||
|
||||
@Test
|
||||
public void invalidFirstPosition() {
|
||||
void invalidFirstPosition() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
HttpRange.createByteRange(-1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invalidLastLessThanFirst() {
|
||||
void invalidLastLessThanFirst() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
HttpRange.createByteRange(10, 9));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invalidSuffixLength() {
|
||||
void invalidSuffixLength() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
HttpRange.createSuffixRange(-1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void byteRange() {
|
||||
void byteRange() {
|
||||
HttpRange range = HttpRange.createByteRange(0, 499);
|
||||
assertThat(range.getRangeStart(1000)).isEqualTo(0);
|
||||
assertThat(range.getRangeEnd(1000)).isEqualTo(499);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void byteRangeWithoutLastPosition() {
|
||||
void byteRangeWithoutLastPosition() {
|
||||
HttpRange range = HttpRange.createByteRange(9500);
|
||||
assertThat(range.getRangeStart(10000)).isEqualTo(9500);
|
||||
assertThat(range.getRangeEnd(10000)).isEqualTo(9999);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void byteRangeOfZeroLength() {
|
||||
void byteRangeOfZeroLength() {
|
||||
HttpRange range = HttpRange.createByteRange(9500, 9500);
|
||||
assertThat(range.getRangeStart(10000)).isEqualTo(9500);
|
||||
assertThat(range.getRangeEnd(10000)).isEqualTo(9500);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void suffixRange() {
|
||||
void suffixRange() {
|
||||
HttpRange range = HttpRange.createSuffixRange(500);
|
||||
assertThat(range.getRangeStart(1000)).isEqualTo(500);
|
||||
assertThat(range.getRangeEnd(1000)).isEqualTo(999);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void suffixRangeShorterThanRepresentation() {
|
||||
void suffixRangeShorterThanRepresentation() {
|
||||
HttpRange range = HttpRange.createSuffixRange(500);
|
||||
assertThat(range.getRangeStart(350)).isEqualTo(0);
|
||||
assertThat(range.getRangeEnd(350)).isEqualTo(349);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseRanges() {
|
||||
void parseRanges() {
|
||||
List<HttpRange> ranges = HttpRange.parseRanges("bytes=0-0,500-,-1");
|
||||
assertThat(ranges).hasSize(3);
|
||||
assertThat(ranges.get(0).getRangeStart(1000)).isEqualTo(0);
|
||||
@@ -106,7 +106,7 @@ public class HttpRangeTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseRangesValidations() {
|
||||
void parseRangesValidations() {
|
||||
|
||||
// 1. At limit..
|
||||
StringBuilder atLimit = new StringBuilder("bytes=0-0");
|
||||
@@ -126,7 +126,7 @@ public class HttpRangeTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rangeToString() {
|
||||
void rangeToString() {
|
||||
List<HttpRange> ranges = new ArrayList<>();
|
||||
ranges.add(HttpRange.createByteRange(0, 499));
|
||||
ranges.add(HttpRange.createByteRange(9500));
|
||||
@@ -135,7 +135,7 @@ public class HttpRangeTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toResourceRegion() {
|
||||
void toResourceRegion() {
|
||||
byte[] bytes = "Spring Framework".getBytes(StandardCharsets.UTF_8);
|
||||
ByteArrayResource resource = new ByteArrayResource(bytes);
|
||||
HttpRange range = HttpRange.createByteRange(0, 5);
|
||||
@@ -146,7 +146,7 @@ public class HttpRangeTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toResourceRegionInputStreamResource() {
|
||||
void toResourceRegionInputStreamResource() {
|
||||
InputStreamResource resource = mock();
|
||||
HttpRange range = HttpRange.createByteRange(0, 9);
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
@@ -154,7 +154,7 @@ public class HttpRangeTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toResourceRegionIllegalLength() {
|
||||
void toResourceRegionIllegalLength() {
|
||||
ByteArrayResource resource = mock();
|
||||
given(resource.contentLength()).willReturn(-1L);
|
||||
HttpRange range = HttpRange.createByteRange(0, 9);
|
||||
@@ -162,7 +162,7 @@ public class HttpRangeTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toResourceRegionExceptionLength() throws IOException {
|
||||
void toResourceRegionExceptionLength() throws IOException {
|
||||
InputStreamResource resource = mock();
|
||||
given(resource.contentLength()).willThrow(IOException.class);
|
||||
HttpRange range = HttpRange.createByteRange(0, 9);
|
||||
@@ -178,7 +178,7 @@ public class HttpRangeTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toResourceRegionsValidations() {
|
||||
void toResourceRegionsValidations() {
|
||||
byte[] bytes = "12345".getBytes(StandardCharsets.UTF_8);
|
||||
ByteArrayResource resource = new ByteArrayResource(bytes);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -25,10 +25,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class MediaTypeFactoryTests {
|
||||
class MediaTypeFactoryTests {
|
||||
|
||||
@Test
|
||||
public void getMediaType() {
|
||||
void getMediaType() {
|
||||
assertThat(MediaTypeFactory.getMediaType("file.xml")).contains(MediaType.APPLICATION_XML);
|
||||
assertThat(MediaTypeFactory.getMediaType("file.js")).contains(MediaType.parseMediaType("application/javascript"));
|
||||
assertThat(MediaTypeFactory.getMediaType("file.css")).contains(MediaType.parseMediaType("text/css"));
|
||||
@@ -36,7 +36,7 @@ public class MediaTypeFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nullParameter() {
|
||||
void nullParameter() {
|
||||
assertThat(MediaTypeFactory.getMediaType((String) null)).isNotPresent();
|
||||
assertThat(MediaTypeFactory.getMediaType((Resource) null)).isNotPresent();
|
||||
assertThat(MediaTypeFactory.getMediaTypes(null)).isEmpty();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -40,35 +40,35 @@ import static org.assertj.core.api.Assertions.within;
|
||||
* @author Juergen Hoeller
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
public class MediaTypeTests {
|
||||
class MediaTypeTests {
|
||||
|
||||
@Test
|
||||
public void testToString() throws Exception {
|
||||
void testToString() {
|
||||
MediaType mediaType = new MediaType("text", "plain", 0.7);
|
||||
String result = mediaType.toString();
|
||||
assertThat(result).as("Invalid toString() returned").isEqualTo("text/plain;q=0.7");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void slashInType() {
|
||||
void slashInType() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
new MediaType("text/plain"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void slashInSubtype() {
|
||||
void slashInSubtype() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
new MediaType("text", "/"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDefaultQualityValue() {
|
||||
void getDefaultQualityValue() {
|
||||
MediaType mediaType = new MediaType("text", "plain");
|
||||
assertThat(mediaType.getQualityValue()).as("Invalid quality value").isCloseTo(1D, within(0D));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseMediaType() throws Exception {
|
||||
void parseMediaType() {
|
||||
String s = "audio/*; q=0.2";
|
||||
MediaType mediaType = MediaType.parseMediaType(s);
|
||||
assertThat(mediaType.getType()).as("Invalid type").isEqualTo("audio");
|
||||
@@ -77,73 +77,73 @@ public class MediaTypeTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseMediaTypeNoSubtype() {
|
||||
void parseMediaTypeNoSubtype() {
|
||||
assertThatExceptionOfType(InvalidMediaTypeException.class).isThrownBy(() ->
|
||||
MediaType.parseMediaType("audio"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseMediaTypeNoSubtypeSlash() {
|
||||
void parseMediaTypeNoSubtypeSlash() {
|
||||
assertThatExceptionOfType(InvalidMediaTypeException.class).isThrownBy(() ->
|
||||
MediaType.parseMediaType("audio/"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseMediaTypeTypeRange() {
|
||||
void parseMediaTypeTypeRange() {
|
||||
assertThatExceptionOfType(InvalidMediaTypeException.class).isThrownBy(() ->
|
||||
MediaType.parseMediaType("*/json"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseMediaTypeIllegalType() {
|
||||
void parseMediaTypeIllegalType() {
|
||||
assertThatExceptionOfType(InvalidMediaTypeException.class).isThrownBy(() ->
|
||||
MediaType.parseMediaType("audio(/basic"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseMediaTypeIllegalSubtype() {
|
||||
void parseMediaTypeIllegalSubtype() {
|
||||
assertThatExceptionOfType(InvalidMediaTypeException.class).isThrownBy(() ->
|
||||
MediaType.parseMediaType("audio/basic)"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseMediaTypeEmptyParameterAttribute() {
|
||||
void parseMediaTypeEmptyParameterAttribute() {
|
||||
assertThatExceptionOfType(InvalidMediaTypeException.class).isThrownBy(() ->
|
||||
MediaType.parseMediaType("audio/*;=value"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseMediaTypeEmptyParameterValue() {
|
||||
void parseMediaTypeEmptyParameterValue() {
|
||||
assertThatExceptionOfType(InvalidMediaTypeException.class).isThrownBy(() ->
|
||||
MediaType.parseMediaType("audio/*;attr="));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseMediaTypeIllegalParameterAttribute() {
|
||||
void parseMediaTypeIllegalParameterAttribute() {
|
||||
assertThatExceptionOfType(InvalidMediaTypeException.class).isThrownBy(() ->
|
||||
MediaType.parseMediaType("audio/*;attr<=value"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseMediaTypeIllegalParameterValue() {
|
||||
void parseMediaTypeIllegalParameterValue() {
|
||||
assertThatExceptionOfType(InvalidMediaTypeException.class).isThrownBy(() ->
|
||||
MediaType.parseMediaType("audio/*;attr=v>alue"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseMediaTypeIllegalQualityFactor() {
|
||||
void parseMediaTypeIllegalQualityFactor() {
|
||||
assertThatExceptionOfType(InvalidMediaTypeException.class).isThrownBy(() ->
|
||||
MediaType.parseMediaType("audio/basic;q=1.1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseMediaTypeIllegalCharset() {
|
||||
void parseMediaTypeIllegalCharset() {
|
||||
assertThatExceptionOfType(InvalidMediaTypeException.class).isThrownBy(() ->
|
||||
MediaType.parseMediaType("text/html; charset=foo-bar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseURLConnectionMediaType() throws Exception {
|
||||
void parseURLConnectionMediaType() {
|
||||
String s = "*; q=.2";
|
||||
MediaType mediaType = MediaType.parseMediaType(s);
|
||||
assertThat(mediaType.getType()).as("Invalid type").isEqualTo("*");
|
||||
@@ -152,7 +152,7 @@ public class MediaTypeTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseMediaTypes() throws Exception {
|
||||
void parseMediaTypes() {
|
||||
String s = "text/plain; q=0.5, text/html, text/x-dvi; q=0.8, text/x-c";
|
||||
List<MediaType> mediaTypes = MediaType.parseMediaTypes(s);
|
||||
assertThat(mediaTypes).as("No media types returned").isNotNull();
|
||||
@@ -171,7 +171,7 @@ public class MediaTypeTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void compareTo() {
|
||||
void compareTo() {
|
||||
MediaType audioBasic = new MediaType("audio", "basic");
|
||||
MediaType audio = new MediaType("audio");
|
||||
MediaType audioWave = new MediaType("audio", "wave");
|
||||
@@ -206,7 +206,7 @@ public class MediaTypeTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void compareToConsistentWithEquals() {
|
||||
void compareToConsistentWithEquals() {
|
||||
MediaType m1 = MediaType.parseMediaType("text/html; q=0.7; charset=iso-8859-1");
|
||||
MediaType m2 = MediaType.parseMediaType("text/html; charset=iso-8859-1; q=0.7");
|
||||
|
||||
@@ -222,7 +222,7 @@ public class MediaTypeTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void compareToCaseSensitivity() {
|
||||
void compareToCaseSensitivity() {
|
||||
MediaType m1 = new MediaType("audio", "basic");
|
||||
MediaType m2 = new MediaType("Audio", "Basic");
|
||||
assertThat(m1.compareTo(m2)).as("Invalid comparison result").isEqualTo(0);
|
||||
@@ -280,7 +280,7 @@ public class MediaTypeTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void specificityComparator() throws Exception {
|
||||
void specificityComparator() {
|
||||
MediaType audioBasic = new MediaType("audio", "basic");
|
||||
MediaType audioWave = new MediaType("audio", "wave");
|
||||
MediaType audio = new MediaType("audio");
|
||||
@@ -388,7 +388,7 @@ public class MediaTypeTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void qualityComparator() throws Exception {
|
||||
void qualityComparator() {
|
||||
MediaType audioBasic = new MediaType("audio", "basic");
|
||||
MediaType audioWave = new MediaType("audio", "wave");
|
||||
MediaType audio = new MediaType("audio");
|
||||
@@ -495,7 +495,7 @@ public class MediaTypeTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithConversionService() {
|
||||
void testWithConversionService() {
|
||||
ConversionService conversionService = new DefaultConversionService();
|
||||
assertThat(conversionService.canConvert(String.class, MediaType.class)).isTrue();
|
||||
MediaType mediaType = MediaType.parseMediaType("application/xml");
|
||||
@@ -503,7 +503,7 @@ public class MediaTypeTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isConcrete() {
|
||||
void isConcrete() {
|
||||
assertThat(MediaType.TEXT_PLAIN.isConcrete()).as("text/plain not concrete").isTrue();
|
||||
assertThat(MediaType.ALL.isConcrete()).as("*/* concrete").isFalse();
|
||||
assertThat(new MediaType("text", "*").isConcrete()).as("text/* concrete").isFalse();
|
||||
@@ -518,7 +518,7 @@ public class MediaTypeTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sortBySpecificity() {
|
||||
void sortBySpecificity() {
|
||||
MediaType audioBasic = new MediaType("audio", "basic");
|
||||
MediaType audio = new MediaType("audio");
|
||||
MediaType audio03 = new MediaType("audio", "*", 0.3);
|
||||
|
||||
@@ -28,10 +28,10 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class ResponseCookieTests {
|
||||
class ResponseCookieTests {
|
||||
|
||||
@Test
|
||||
public void basic() {
|
||||
void basic() {
|
||||
|
||||
assertThat(ResponseCookie.from("id", null).build().toString()).isEqualTo("id=");
|
||||
assertThat(ResponseCookie.from("id", "1fWa").build().toString()).isEqualTo("id=1fWa");
|
||||
@@ -46,7 +46,7 @@ public class ResponseCookieTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nameChecks() {
|
||||
void nameChecks() {
|
||||
|
||||
Arrays.asList("id", "i.d.", "i-d", "+id", "i*d", "i$d", "#id")
|
||||
.forEach(name -> ResponseCookie.from(name, "value").build());
|
||||
@@ -57,7 +57,7 @@ public class ResponseCookieTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void valueChecks() {
|
||||
void valueChecks() {
|
||||
|
||||
Arrays.asList("1fWa", "", null, "1f=Wa", "1f-Wa", "1f/Wa", "1.f.W.a.")
|
||||
.forEach(value -> ResponseCookie.from("id", value).build());
|
||||
@@ -68,7 +68,7 @@ public class ResponseCookieTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void domainChecks() {
|
||||
void domainChecks() {
|
||||
|
||||
Arrays.asList("abc", "abc.org", "abc-def.org", "abc3.org", ".abc.org")
|
||||
.forEach(domain -> ResponseCookie.from("n", "v").domain(domain).build());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -45,7 +45,7 @@ public abstract class AbstractMockWebServerTests {
|
||||
new MediaType("text", "plain", Collections.singletonMap("charset", "UTF-8"));
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
void setUp() throws Exception {
|
||||
this.server = new MockWebServer();
|
||||
this.server.setDispatcher(new TestDispatcher());
|
||||
this.server.start();
|
||||
@@ -54,13 +54,13 @@ public abstract class AbstractMockWebServerTests {
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void tearDown() throws Exception {
|
||||
void tearDown() throws Exception {
|
||||
this.server.shutdown();
|
||||
}
|
||||
|
||||
protected class TestDispatcher extends Dispatcher {
|
||||
@Override
|
||||
public MockResponse dispatch(RecordedRequest request) throws InterruptedException {
|
||||
public MockResponse dispatch(RecordedRequest request) {
|
||||
try {
|
||||
if (request.getPath().equals("/echo")) {
|
||||
assertThat(request.getHeader("Host"))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.http.client;
|
||||
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -43,7 +44,7 @@ class BufferingClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryT
|
||||
request.getHeaders().add(headerName, headerValue1);
|
||||
String headerValue2 = "value2";
|
||||
request.getHeaders().add(headerName, headerValue2);
|
||||
byte[] body = "Hello World".getBytes("UTF-8");
|
||||
byte[] body = "Hello World".getBytes(StandardCharsets.UTF_8);
|
||||
request.getHeaders().setContentLength(body.length);
|
||||
FileCopyUtils.copy(body, request.getBody());
|
||||
try (ClientHttpResponse response = request.execute()) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -101,7 +101,7 @@ class InterceptingClientHttpRequestFactoryTests {
|
||||
|
||||
requestMock = new MockClientHttpRequest() {
|
||||
@Override
|
||||
protected ClientHttpResponse executeInternal() throws IOException {
|
||||
protected ClientHttpResponse executeInternal() {
|
||||
List<String> headerValues = getHeaders().get(headerName);
|
||||
assertThat(headerValues).hasSize(2);
|
||||
assertThat(headerValues).element(0).isEqualTo(headerValue);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -23,7 +23,7 @@ import org.springframework.http.HttpMethod;
|
||||
/**
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class InterceptingStreamingHttpComponentsTests extends AbstractHttpRequestFactoryTests {
|
||||
class InterceptingStreamingHttpComponentsTests extends AbstractHttpRequestFactoryTests {
|
||||
|
||||
@Override
|
||||
protected ClientHttpRequestFactory createRequestFactory() {
|
||||
@@ -33,7 +33,7 @@ public class InterceptingStreamingHttpComponentsTests extends AbstractHttpReques
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void httpMethods() throws Exception {
|
||||
void httpMethods() throws Exception {
|
||||
super.httpMethods();
|
||||
assertHttpMethod("patch", HttpMethod.PATCH);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
/**
|
||||
* @author Marten Deinum
|
||||
*/
|
||||
public class JdkClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTests {
|
||||
class JdkClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTests {
|
||||
|
||||
@Nullable
|
||||
private static String originalPropertyValue;
|
||||
@@ -61,13 +61,13 @@ public class JdkClientHttpRequestFactoryTests extends AbstractHttpRequestFactory
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void httpMethods() throws Exception {
|
||||
void httpMethods() throws Exception {
|
||||
super.httpMethods();
|
||||
assertHttpMethod("patch", HttpMethod.PATCH);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customizeDisallowedHeaders() throws IOException {
|
||||
void customizeDisallowedHeaders() throws IOException {
|
||||
ClientHttpRequest request = this.factory.createRequest(URI.create(this.baseUrl + "/status/299"), HttpMethod.PUT);
|
||||
request.getHeaders().set("Expect", "299");
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -23,7 +23,7 @@ import org.springframework.http.HttpMethod;
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class JettyClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTests {
|
||||
class JettyClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTests {
|
||||
|
||||
@Override
|
||||
protected ClientHttpRequestFactory createRequestFactory() {
|
||||
@@ -32,7 +32,7 @@ public class JettyClientHttpRequestFactoryTests extends AbstractHttpRequestFacto
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void httpMethods() throws Exception {
|
||||
void httpMethods() throws Exception {
|
||||
super.httpMethods();
|
||||
assertHttpMethod("patch", HttpMethod.PATCH);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -35,10 +35,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class MultipartBodyBuilderTests {
|
||||
class MultipartBodyBuilderTests {
|
||||
|
||||
@Test
|
||||
public void builder() {
|
||||
void builder() {
|
||||
|
||||
MultipartBodyBuilder builder = new MultipartBodyBuilder();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -23,7 +23,7 @@ import org.springframework.http.HttpMethod;
|
||||
/**
|
||||
* @author Roy Clarkson
|
||||
*/
|
||||
public class OkHttp3ClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTests {
|
||||
class OkHttp3ClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTests {
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
@Override
|
||||
@@ -33,7 +33,7 @@ public class OkHttp3ClientHttpRequestFactoryTests extends AbstractHttpRequestFac
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void httpMethods() throws Exception {
|
||||
void httpMethods() throws Exception {
|
||||
super.httpMethods();
|
||||
assertHttpMethod("patch", HttpMethod.PATCH);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2023-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -29,7 +29,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Arjen Poutsma
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
public class ReactorNettyClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTests {
|
||||
class ReactorNettyClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTests {
|
||||
|
||||
@Override
|
||||
protected ClientHttpRequestFactory createRequestFactory() {
|
||||
@@ -38,7 +38,7 @@ public class ReactorNettyClientHttpRequestFactoryTests extends AbstractHttpReque
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void httpMethods() throws Exception {
|
||||
void httpMethods() throws Exception {
|
||||
super.httpMethods();
|
||||
assertHttpMethod("patch", HttpMethod.PATCH);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -47,14 +47,14 @@ public class SimpleClientHttpRequestFactoryTests extends AbstractHttpRequestFact
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void httpMethods() throws Exception {
|
||||
void httpMethods() throws Exception {
|
||||
super.httpMethods();
|
||||
assertThatExceptionOfType(ProtocolException.class).isThrownBy(() ->
|
||||
assertHttpMethod("patch", HttpMethod.PATCH));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void prepareConnectionWithRequestBody() throws Exception {
|
||||
void prepareConnectionWithRequestBody() throws Exception {
|
||||
URI uri = new URI("https://example.com");
|
||||
testRequestBodyAllowed(uri, "GET", false);
|
||||
testRequestBodyAllowed(uri, "HEAD", false);
|
||||
@@ -72,7 +72,7 @@ public class SimpleClientHttpRequestFactoryTests extends AbstractHttpRequestFact
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteWithoutBodyDoesNotRaiseException() throws Exception {
|
||||
void deleteWithoutBodyDoesNotRaiseException() throws Exception {
|
||||
HttpURLConnection connection = new TestHttpURLConnection(new URL("https://example.com"));
|
||||
((SimpleClientHttpRequestFactory) this.factory).prepareConnection(connection, "DELETE");
|
||||
SimpleClientHttpRequest request = new SimpleClientHttpRequest(connection, 4096);
|
||||
@@ -125,7 +125,7 @@ public class SimpleClientHttpRequestFactoryTests extends AbstractHttpRequestFact
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect() throws IOException {
|
||||
public void connect() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -138,7 +138,7 @@ public class SimpleClientHttpRequestFactoryTests extends AbstractHttpRequestFact
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream() throws IOException {
|
||||
public InputStream getInputStream() {
|
||||
return new ByteArrayInputStream(new byte[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -39,7 +39,7 @@ import static org.mockito.Mockito.verify;
|
||||
* @author Brian Clozel
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class SimpleClientHttpResponseTests {
|
||||
class SimpleClientHttpResponseTests {
|
||||
|
||||
private final HttpURLConnection connection = mock();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -59,7 +59,7 @@ import static org.junit.jupiter.api.Named.named;
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class ClientHttpConnectorTests {
|
||||
class ClientHttpConnectorTests {
|
||||
|
||||
private static final int BUF_SIZE = 1024;
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
public class ReactorResourceFactoryTests {
|
||||
class ReactorResourceFactoryTests {
|
||||
|
||||
private final ReactorResourceFactory resourceFactory = new ReactorResourceFactory();
|
||||
|
||||
@@ -156,7 +156,7 @@ public class ReactorResourceFactoryTests {
|
||||
|
||||
this.resourceFactory.destroy();
|
||||
|
||||
// Not managed (destroy has no impact)..
|
||||
// Not managed (destroy has no impact)
|
||||
verifyNoMoreInteractions(this.connectionProvider, this.loopResources);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -35,11 +35,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
public class InterceptingHttpAccessorTests {
|
||||
class InterceptingHttpAccessorTests {
|
||||
|
||||
@Test
|
||||
public void getInterceptors() {
|
||||
@SuppressWarnings("resource")
|
||||
void getInterceptors() {
|
||||
TestInterceptingHttpAccessor accessor = new TestInterceptingHttpAccessor();
|
||||
List<ClientHttpRequestInterceptor> interceptors = Arrays.asList(
|
||||
new SecondClientHttpRequestInterceptor(),
|
||||
@@ -55,12 +54,12 @@ public class InterceptingHttpAccessorTests {
|
||||
}
|
||||
|
||||
|
||||
private class TestInterceptingHttpAccessor extends InterceptingHttpAccessor {
|
||||
private static class TestInterceptingHttpAccessor extends InterceptingHttpAccessor {
|
||||
}
|
||||
|
||||
|
||||
@Order(1)
|
||||
private class FirstClientHttpRequestInterceptor implements ClientHttpRequestInterceptor {
|
||||
private static class FirstClientHttpRequestInterceptor implements ClientHttpRequestInterceptor {
|
||||
|
||||
@Override
|
||||
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) {
|
||||
@@ -69,7 +68,7 @@ public class InterceptingHttpAccessorTests {
|
||||
}
|
||||
|
||||
|
||||
private class SecondClientHttpRequestInterceptor implements ClientHttpRequestInterceptor, Ordered {
|
||||
private static class SecondClientHttpRequestInterceptor implements ClientHttpRequestInterceptor, Ordered {
|
||||
|
||||
@Override
|
||||
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) {
|
||||
@@ -83,7 +82,7 @@ public class InterceptingHttpAccessorTests {
|
||||
}
|
||||
|
||||
|
||||
private class ThirdClientHttpRequestInterceptor implements ClientHttpRequestInterceptor {
|
||||
private static class ThirdClientHttpRequestInterceptor implements ClientHttpRequestInterceptor {
|
||||
|
||||
@Override
|
||||
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -53,13 +53,13 @@ import org.springframework.web.testfixture.xml.Pojo;
|
||||
* Test scenarios for data buffer leaks.
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class CancelWithoutDemandCodecTests {
|
||||
class CancelWithoutDemandCodecTests {
|
||||
|
||||
private final LeakAwareDataBufferFactory bufferFactory = new LeakAwareDataBufferFactory();
|
||||
|
||||
|
||||
@AfterEach
|
||||
public void tearDown() throws Exception {
|
||||
void tearDown() {
|
||||
this.bufferFactory.checkForLeaks();
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public class CancelWithoutDemandCodecTests {
|
||||
MediaType.APPLICATION_JSON, Collections.emptyMap());
|
||||
|
||||
BaseSubscriber<DataBuffer> subscriber = new ZeroDemandSubscriber();
|
||||
flux.subscribe(subscriber); // Assume sync execution (e.g. encoding with Flux.just)..
|
||||
flux.subscribe(subscriber); // Assume sync execution (e.g. encoding with Flux.just)
|
||||
subscriber.cancel();
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public class CancelWithoutDemandCodecTests {
|
||||
MediaType.APPLICATION_XML, Collections.emptyMap());
|
||||
|
||||
BaseSubscriber<DataBuffer> subscriber = new ZeroDemandSubscriber();
|
||||
flux.subscribe(subscriber); // Assume sync execution (e.g. encoding with Flux.just)..
|
||||
flux.subscribe(subscriber); // Assume sync execution (e.g. encoding with Flux.just)
|
||||
subscriber.cancel();
|
||||
}
|
||||
|
||||
@@ -110,12 +110,12 @@ public class CancelWithoutDemandCodecTests {
|
||||
MediaType.APPLICATION_PROTOBUF, Collections.emptyMap());
|
||||
|
||||
BaseSubscriber<DataBuffer> subscriber = new ZeroDemandSubscriber();
|
||||
flux.subscribe(subscriber); // Assume sync execution (e.g. encoding with Flux.just)..
|
||||
flux.subscribe(subscriber); // Assume sync execution (e.g. encoding with Flux.just)
|
||||
subscriber.cancel();
|
||||
}
|
||||
|
||||
@Test // gh-22731
|
||||
public void cancelWithProtobufDecoder() throws InterruptedException {
|
||||
public void cancelWithProtobufDecoder() {
|
||||
ProtobufDecoder decoder = new ProtobufDecoder();
|
||||
|
||||
Mono<DataBuffer> input = Mono.fromCallable(() -> {
|
||||
@@ -187,7 +187,7 @@ public class CancelWithoutDemandCodecTests {
|
||||
public Mono<Void> writeWith(Publisher<? extends DataBuffer> body) {
|
||||
Flux<? extends DataBuffer> flux = Flux.from(body);
|
||||
BaseSubscriber<DataBuffer> subscriber = new ZeroDemandSubscriber();
|
||||
flux.subscribe(subscriber); // Assume sync execution (e.g. encoding with Flux.just)..
|
||||
flux.subscribe(subscriber); // Assume sync execution (e.g. encoding with Flux.just)
|
||||
subscriber.cancel();
|
||||
return Mono.empty();
|
||||
}
|
||||
@@ -196,7 +196,7 @@ public class CancelWithoutDemandCodecTests {
|
||||
public Mono<Void> writeAndFlushWith(Publisher<? extends Publisher<? extends DataBuffer>> body) {
|
||||
Flux<? extends DataBuffer> flux = Flux.from(body).concatMap(Flux::from);
|
||||
BaseSubscriber<DataBuffer> subscriber = new ZeroDemandSubscriber();
|
||||
flux.subscribe(subscriber); // Assume sync execution (e.g. encoding with Flux.just)..
|
||||
flux.subscribe(subscriber); // Assume sync execution (e.g. encoding with Flux.just)
|
||||
subscriber.cancel();
|
||||
return Mono.empty();
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ class EncoderHttpMessageWriterTests {
|
||||
void isStreamingMediaType() throws InvocationTargetException, IllegalAccessException {
|
||||
configureEncoder(TEXT_HTML);
|
||||
MediaType streamingMediaType = new MediaType(TEXT_PLAIN, Collections.singletonMap("streaming", "true"));
|
||||
given(this.encoder.getStreamingMediaTypes()).willReturn(Arrays.asList(streamingMediaType));
|
||||
given(this.encoder.getStreamingMediaTypes()).willReturn(List.of(streamingMediaType));
|
||||
|
||||
HttpMessageWriter<String> writer = new EncoderHttpMessageWriter<>(this.encoder);
|
||||
Method method = ReflectionUtils.findMethod(writer.getClass(), "isStreamingMediaType", MediaType.class);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -41,13 +41,13 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
/**
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
public class FormHttpMessageReaderTests extends AbstractLeakCheckingTests {
|
||||
class FormHttpMessageReaderTests extends AbstractLeakCheckingTests {
|
||||
|
||||
private final FormHttpMessageReader reader = new FormHttpMessageReader();
|
||||
|
||||
|
||||
@Test
|
||||
public void canRead() {
|
||||
void canRead() {
|
||||
assertThat(this.reader.canRead(
|
||||
ResolvableType.forClassWithGenerics(MultiValueMap.class, String.class, String.class),
|
||||
MediaType.APPLICATION_FORM_URLENCODED)).isTrue();
|
||||
@@ -74,7 +74,7 @@ public class FormHttpMessageReaderTests extends AbstractLeakCheckingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readFormAsMono() {
|
||||
void readFormAsMono() {
|
||||
String body = "name+1=value+1&name+2=value+2%2B1&name+2=value+2%2B2&name+3";
|
||||
MockServerHttpRequest request = request(body);
|
||||
MultiValueMap<String, String> result = this.reader.readMono(null, request, null).block();
|
||||
@@ -82,14 +82,12 @@ public class FormHttpMessageReaderTests extends AbstractLeakCheckingTests {
|
||||
assertThat(result).as("Invalid result").hasSize(3);
|
||||
assertThat(result.getFirst("name 1")).as("Invalid result").isEqualTo("value 1");
|
||||
List<String> values = result.get("name 2");
|
||||
assertThat(values).as("Invalid result").hasSize(2);
|
||||
assertThat(values).element(0).as("Invalid result").isEqualTo("value 2+1");
|
||||
assertThat(values).element(1).as("Invalid result").isEqualTo("value 2+2");
|
||||
assertThat(values).as("Invalid result").containsExactly("value 2+1", "value 2+2");
|
||||
assertThat(result.getFirst("name 3")).as("Invalid result").isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readFormAsFlux() {
|
||||
void readFormAsFlux() {
|
||||
String body = "name+1=value+1&name+2=value+2%2B1&name+2=value+2%2B2&name+3";
|
||||
MockServerHttpRequest request = request(body);
|
||||
MultiValueMap<String, String> result = this.reader.read(null, request, null).single().block();
|
||||
@@ -97,14 +95,12 @@ public class FormHttpMessageReaderTests extends AbstractLeakCheckingTests {
|
||||
assertThat(result).as("Invalid result").hasSize(3);
|
||||
assertThat(result.getFirst("name 1")).as("Invalid result").isEqualTo("value 1");
|
||||
List<String> values = result.get("name 2");
|
||||
assertThat(values).as("Invalid result").hasSize(2);
|
||||
assertThat(values).element(0).as("Invalid result").isEqualTo("value 2+1");
|
||||
assertThat(values).element(1).as("Invalid result").isEqualTo("value 2+2");
|
||||
assertThat(values).as("Invalid result").containsExactly("value 2+1", "value 2+2");
|
||||
assertThat(result.getFirst("name 3")).as("Invalid result").isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readFormError() {
|
||||
void readFormError() {
|
||||
DataBuffer fooBuffer = stringBuffer("name=value");
|
||||
Flux<DataBuffer> body =
|
||||
Flux.just(fooBuffer).concatWith(Flux.error(new RuntimeException()));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -39,13 +39,13 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
/**
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
public class FormHttpMessageWriterTests extends AbstractLeakCheckingTests {
|
||||
class FormHttpMessageWriterTests extends AbstractLeakCheckingTests {
|
||||
|
||||
private final FormHttpMessageWriter writer = new FormHttpMessageWriter();
|
||||
|
||||
|
||||
@Test
|
||||
public void canWrite() {
|
||||
void canWrite() {
|
||||
assertThat(this.writer.canWrite(
|
||||
ResolvableType.forClassWithGenerics(MultiValueMap.class, String.class, String.class),
|
||||
MediaType.APPLICATION_FORM_URLENCODED)).isTrue();
|
||||
@@ -73,7 +73,7 @@ public class FormHttpMessageWriterTests extends AbstractLeakCheckingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeForm() {
|
||||
void writeForm() {
|
||||
MultiValueMap<String, String> body = new LinkedMultiValueMap<>();
|
||||
body.set("name 1", "value 1");
|
||||
body.add("name 2", "value 2+1");
|
||||
|
||||
@@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class ResourceHttpMessageReaderTests extends AbstractLeakCheckingTests {
|
||||
class ResourceHttpMessageReaderTests extends AbstractLeakCheckingTests {
|
||||
|
||||
private final ResourceHttpMessageReader reader = new ResourceHttpMessageReader();
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ import static org.springframework.web.testfixture.http.server.reactive.MockServe
|
||||
* @author Brian Clozel
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class ResourceHttpMessageWriterTests {
|
||||
class ResourceHttpMessageWriterTests {
|
||||
|
||||
private static final Map<String, Object> HINTS = Collections.emptyMap();
|
||||
|
||||
@@ -63,13 +63,13 @@ public class ResourceHttpMessageWriterTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void getWritableMediaTypes() throws Exception {
|
||||
public void getWritableMediaTypes() {
|
||||
assertThat((List) this.writer.getWritableMediaTypes())
|
||||
.containsExactlyInAnyOrder(MimeTypeUtils.APPLICATION_OCTET_STREAM, MimeTypeUtils.ALL);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeResourceServer() throws Exception {
|
||||
void writeResourceServer() {
|
||||
|
||||
testWrite(get("/").build());
|
||||
|
||||
@@ -82,7 +82,7 @@ public class ResourceHttpMessageWriterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeResourceClient() throws Exception {
|
||||
void writeResourceClient() {
|
||||
|
||||
MockClientHttpRequest request = new MockClientHttpRequest(HttpMethod.GET, "/");
|
||||
Mono<Void> mono = this.writer.write(this.input, ResolvableType.forClass(Resource.class), TEXT_PLAIN, request, HINTS);
|
||||
@@ -97,7 +97,7 @@ public class ResourceHttpMessageWriterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeSingleRegion() throws Exception {
|
||||
void writeSingleRegion() {
|
||||
|
||||
testWrite(get("/").range(of(0, 5)).build());
|
||||
|
||||
@@ -109,7 +109,7 @@ public class ResourceHttpMessageWriterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeMultipleRegions() throws Exception {
|
||||
void writeMultipleRegions() {
|
||||
|
||||
testWrite(get("/").range(of(0,5), of(7,15), of(17,20), of(22,38)).build());
|
||||
|
||||
@@ -148,7 +148,7 @@ public class ResourceHttpMessageWriterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invalidRange() throws Exception {
|
||||
void invalidRange() {
|
||||
|
||||
testWrite(get("/").header(HttpHeaders.RANGE, "invalid").build());
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*/
|
||||
class ServerSentEventHttpMessageReaderTests extends AbstractLeakCheckingTests {
|
||||
|
||||
private Jackson2JsonDecoder jsonDecoder = new Jackson2JsonDecoder();
|
||||
private final Jackson2JsonDecoder jsonDecoder = new Jackson2JsonDecoder();
|
||||
|
||||
private ServerSentEventHttpMessageReader reader = new ServerSentEventHttpMessageReader(this.jsonDecoder);
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ import static org.springframework.http.MediaType.APPLICATION_JSON;
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
public class Jackson2CborDecoderTests extends AbstractDecoderTests<Jackson2CborDecoder> {
|
||||
class Jackson2CborDecoderTests extends AbstractDecoderTests<Jackson2CborDecoder> {
|
||||
|
||||
private static final MimeType CBOR_MIME_TYPE = new MimeType("application", "cbor");
|
||||
|
||||
@@ -56,7 +56,7 @@ public class Jackson2CborDecoderTests extends AbstractDecoderTests<Jackson2CborD
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void canDecode() {
|
||||
protected void canDecode() {
|
||||
assertThat(decoder.canDecode(ResolvableType.forClass(Pojo.class), CBOR_MIME_TYPE)).isTrue();
|
||||
assertThat(decoder.canDecode(ResolvableType.forClass(Pojo.class), null)).isTrue();
|
||||
|
||||
@@ -66,7 +66,7 @@ public class Jackson2CborDecoderTests extends AbstractDecoderTests<Jackson2CborD
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void decode() {
|
||||
protected void decode() {
|
||||
Flux<DataBuffer> input = Flux.just(this.pojo1, this.pojo2)
|
||||
.map(this::writeObject)
|
||||
.flatMap(this::dataBuffer);
|
||||
@@ -90,7 +90,7 @@ public class Jackson2CborDecoderTests extends AbstractDecoderTests<Jackson2CborD
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void decodeToMono() {
|
||||
protected void decodeToMono() {
|
||||
List<Pojo> expected = Arrays.asList(pojo1, pojo2);
|
||||
|
||||
Flux<DataBuffer> input = Flux.just(expected)
|
||||
|
||||
@@ -43,7 +43,7 @@ import static org.springframework.http.MediaType.APPLICATION_XML;
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
public class Jackson2CborEncoderTests extends AbstractLeakCheckingTests {
|
||||
class Jackson2CborEncoderTests extends AbstractLeakCheckingTests {
|
||||
|
||||
private static final MimeType CBOR_MIME_TYPE = new MimeType("application", "cbor");
|
||||
|
||||
@@ -66,7 +66,7 @@ public class Jackson2CborEncoderTests extends AbstractLeakCheckingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canEncode() {
|
||||
void canEncode() {
|
||||
ResolvableType pojoType = ResolvableType.forClass(Pojo.class);
|
||||
assertThat(this.encoder.canEncode(pojoType, CBOR_MIME_TYPE)).isTrue();
|
||||
assertThat(this.encoder.canEncode(pojoType, null)).isTrue();
|
||||
@@ -76,7 +76,7 @@ public class Jackson2CborEncoderTests extends AbstractLeakCheckingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canNotEncode() {
|
||||
void canNotEncode() {
|
||||
assertThat(this.encoder.canEncode(ResolvableType.forClass(String.class), null)).isFalse();
|
||||
assertThat(this.encoder.canEncode(ResolvableType.forClass(Pojo.class), APPLICATION_XML)).isFalse();
|
||||
|
||||
@@ -85,14 +85,14 @@ public class Jackson2CborEncoderTests extends AbstractLeakCheckingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void encode() {
|
||||
void encode() {
|
||||
Pojo value = new Pojo("foo", "bar");
|
||||
DataBuffer result = encoder.encodeValue(value, this.bufferFactory, ResolvableType.forClass(Pojo.class), CBOR_MIME_TYPE, null);
|
||||
pojoConsumer(value).accept(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void encodeStream() {
|
||||
void encodeStream() {
|
||||
Pojo pojo1 = new Pojo("foo", "bar");
|
||||
Pojo pojo2 = new Pojo("foofoo", "barbar");
|
||||
Pojo pojo3 = new Pojo("foofoofoo", "barbarbar");
|
||||
|
||||
@@ -62,7 +62,7 @@ import static org.springframework.http.codec.json.Jackson2CodecSupport.JSON_VIEW
|
||||
* @author Sebastien Deleuze
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class Jackson2JsonDecoderTests extends AbstractDecoderTests<Jackson2JsonDecoder> {
|
||||
class Jackson2JsonDecoderTests extends AbstractDecoderTests<Jackson2JsonDecoder> {
|
||||
|
||||
private final Pojo pojo1 = new Pojo("f1", "b1");
|
||||
|
||||
@@ -94,7 +94,7 @@ public class Jackson2JsonDecoderTests extends AbstractDecoderTests<Jackson2JsonD
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canDecodeWithObjectMapperRegistrationForType() {
|
||||
void canDecodeWithObjectMapperRegistrationForType() {
|
||||
MediaType halJsonMediaType = MediaType.parseMediaType("application/hal+json");
|
||||
MediaType halFormsJsonMediaType = MediaType.parseMediaType("application/prs.hal-forms+json");
|
||||
|
||||
@@ -124,7 +124,7 @@ public class Jackson2JsonDecoderTests extends AbstractDecoderTests<Jackson2JsonD
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decodableMimeTypesIsImmutable() {
|
||||
void decodableMimeTypesIsImmutable() {
|
||||
MimeType textJavascript = new MimeType("text", "javascript", StandardCharsets.UTF_8);
|
||||
Jackson2JsonDecoder decoder = new Jackson2JsonDecoder(new ObjectMapper(), textJavascript);
|
||||
|
||||
@@ -133,7 +133,7 @@ public class Jackson2JsonDecoderTests extends AbstractDecoderTests<Jackson2JsonD
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decodableMimeTypesWithObjectMapperRegistration() {
|
||||
void decodableMimeTypesWithObjectMapperRegistration() {
|
||||
MimeType mimeType1 = MediaType.parseMediaType("application/hal+json");
|
||||
MimeType mimeType2 = new MimeType("text", "javascript", StandardCharsets.UTF_8);
|
||||
|
||||
@@ -146,7 +146,7 @@ public class Jackson2JsonDecoderTests extends AbstractDecoderTests<Jackson2JsonD
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void decode() {
|
||||
protected void decode() {
|
||||
Flux<DataBuffer> input = Flux.concat(
|
||||
stringBuffer("[{\"bar\":\"b1\",\"foo\":\"f1\"},"),
|
||||
stringBuffer("{\"bar\":\"b2\",\"foo\":\"f2\"}]"));
|
||||
@@ -159,7 +159,7 @@ public class Jackson2JsonDecoderTests extends AbstractDecoderTests<Jackson2JsonD
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void decodeToMono() {
|
||||
protected void decodeToMono() {
|
||||
Flux<DataBuffer> input = Flux.concat(
|
||||
stringBuffer("[{\"bar\":\"b1\",\"foo\":\"f1\"},"),
|
||||
stringBuffer("{\"bar\":\"b2\",\"foo\":\"f2\"}]"));
|
||||
@@ -174,14 +174,14 @@ public class Jackson2JsonDecoderTests extends AbstractDecoderTests<Jackson2JsonD
|
||||
|
||||
|
||||
@Test
|
||||
public void decodeEmptyArrayToFlux() {
|
||||
void decodeEmptyArrayToFlux() {
|
||||
Flux<DataBuffer> input = Flux.from(stringBuffer("[]"));
|
||||
|
||||
testDecode(input, Pojo.class, StepVerifier.LastStep::verifyComplete);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fieldLevelJsonView() {
|
||||
void fieldLevelJsonView() {
|
||||
Flux<DataBuffer> input = Flux.from(stringBuffer(
|
||||
"{\"withView1\" : \"with\", \"withView2\" : \"with\", \"withoutView\" : \"without\"}"));
|
||||
|
||||
@@ -198,7 +198,7 @@ public class Jackson2JsonDecoderTests extends AbstractDecoderTests<Jackson2JsonD
|
||||
}
|
||||
|
||||
@Test
|
||||
public void classLevelJsonView() {
|
||||
void classLevelJsonView() {
|
||||
Flux<DataBuffer> input = Flux.from(stringBuffer(
|
||||
"{\"withView1\" : \"with\", \"withView2\" : \"with\", \"withoutView\" : \"without\"}"));
|
||||
|
||||
@@ -216,7 +216,7 @@ public class Jackson2JsonDecoderTests extends AbstractDecoderTests<Jackson2JsonD
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invalidData() {
|
||||
void invalidData() {
|
||||
Flux<DataBuffer> input = Flux.from(stringBuffer("{\"foofoo\": \"foofoo\", \"barbar\": \"barbar\""));
|
||||
testDecode(input, Pojo.class, step -> step.verifyError(DecodingException.class));
|
||||
}
|
||||
@@ -243,7 +243,7 @@ public class Jackson2JsonDecoderTests extends AbstractDecoderTests<Jackson2JsonD
|
||||
}
|
||||
|
||||
@Test
|
||||
public void codecException() {
|
||||
void codecException() {
|
||||
Flux<DataBuffer> input = Flux.from(stringBuffer("["));
|
||||
ResolvableType elementType = ResolvableType.forClass(BeanWithNoDefaultConstructor.class);
|
||||
Flux<Object> flux = new Jackson2JsonDecoder().decode(input, elementType, null, Collections.emptyMap());
|
||||
@@ -261,7 +261,7 @@ public class Jackson2JsonDecoderTests extends AbstractDecoderTests<Jackson2JsonD
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bigDecimalFlux() {
|
||||
void bigDecimalFlux() {
|
||||
Flux<DataBuffer> input = stringBuffer("[ 1E+2 ]").flux();
|
||||
|
||||
testDecode(input, BigDecimal.class, step -> step
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -56,7 +56,7 @@ import static org.springframework.http.codec.json.Jackson2CodecSupport.JSON_VIEW
|
||||
/**
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
public class Jackson2JsonEncoderTests extends AbstractEncoderTests<Jackson2JsonEncoder> {
|
||||
class Jackson2JsonEncoderTests extends AbstractEncoderTests<Jackson2JsonEncoder> {
|
||||
|
||||
public Jackson2JsonEncoderTests() {
|
||||
super(new Jackson2JsonEncoder());
|
||||
@@ -111,7 +111,7 @@ public class Jackson2JsonEncoderTests extends AbstractEncoderTests<Jackson2JsonE
|
||||
}
|
||||
|
||||
@Test
|
||||
public void encodableMimeTypesIsImmutable() {
|
||||
void encodableMimeTypesIsImmutable() {
|
||||
MimeType textJavascript = new MimeType("text", "javascript", StandardCharsets.UTF_8);
|
||||
Jackson2JsonEncoder encoder = new Jackson2JsonEncoder(new ObjectMapper(), textJavascript);
|
||||
|
||||
@@ -120,7 +120,7 @@ public class Jackson2JsonEncoderTests extends AbstractEncoderTests<Jackson2JsonE
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canNotEncode() {
|
||||
void canNotEncode() {
|
||||
assertThat(this.encoder.canEncode(ResolvableType.forClass(String.class), null)).isFalse();
|
||||
assertThat(this.encoder.canEncode(ResolvableType.forClass(Pojo.class), APPLICATION_XML)).isFalse();
|
||||
|
||||
@@ -129,7 +129,7 @@ public class Jackson2JsonEncoderTests extends AbstractEncoderTests<Jackson2JsonE
|
||||
}
|
||||
|
||||
@Test
|
||||
public void encodeNonStream() {
|
||||
void encodeNonStream() {
|
||||
Flux<Pojo> input = Flux.just(
|
||||
new Pojo("foo", "bar"),
|
||||
new Pojo("foofoo", "barbar"),
|
||||
@@ -145,7 +145,7 @@ public class Jackson2JsonEncoderTests extends AbstractEncoderTests<Jackson2JsonE
|
||||
}
|
||||
|
||||
@Test
|
||||
public void encodeNonStreamEmpty() {
|
||||
void encodeNonStreamEmpty() {
|
||||
testEncode(Flux.empty(), Pojo.class, step -> step
|
||||
.consumeNextWith(expectString("["))
|
||||
.consumeNextWith(expectString("]"))
|
||||
@@ -164,7 +164,7 @@ public class Jackson2JsonEncoderTests extends AbstractEncoderTests<Jackson2JsonE
|
||||
}
|
||||
|
||||
@Test
|
||||
public void encodeWithType() {
|
||||
void encodeWithType() {
|
||||
Flux<ParentClass> input = Flux.just(new Foo(), new Bar());
|
||||
|
||||
testEncode(input, ParentClass.class, step -> step
|
||||
@@ -195,7 +195,7 @@ public class Jackson2JsonEncoderTests extends AbstractEncoderTests<Jackson2JsonE
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fieldLevelJsonView() {
|
||||
void fieldLevelJsonView() {
|
||||
JacksonViewBean bean = new JacksonViewBean();
|
||||
bean.setWithView1("with");
|
||||
bean.setWithView2("with");
|
||||
@@ -212,7 +212,7 @@ public class Jackson2JsonEncoderTests extends AbstractEncoderTests<Jackson2JsonE
|
||||
}
|
||||
|
||||
@Test
|
||||
public void classLevelJsonView() {
|
||||
void classLevelJsonView() {
|
||||
JacksonViewBean bean = new JacksonViewBean();
|
||||
bean.setWithView1("with");
|
||||
bean.setWithView2("with");
|
||||
@@ -229,7 +229,7 @@ public class Jackson2JsonEncoderTests extends AbstractEncoderTests<Jackson2JsonE
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jacksonValue() {
|
||||
void jacksonValue() {
|
||||
JacksonViewBean bean = new JacksonViewBean();
|
||||
bean.setWithView1("with");
|
||||
bean.setWithView2("with");
|
||||
@@ -287,7 +287,7 @@ public class Jackson2JsonEncoderTests extends AbstractEncoderTests<Jackson2JsonE
|
||||
}
|
||||
|
||||
@Test
|
||||
public void encodeAscii() {
|
||||
void encodeAscii() {
|
||||
Mono<Object> input = Mono.just(new Pojo("foo", "bar"));
|
||||
MimeType mimeType = new MimeType("application", "json", StandardCharsets.US_ASCII);
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ import static org.springframework.http.MediaType.APPLICATION_JSON;
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
public class Jackson2SmileDecoderTests extends AbstractDecoderTests<Jackson2SmileDecoder> {
|
||||
class Jackson2SmileDecoderTests extends AbstractDecoderTests<Jackson2SmileDecoder> {
|
||||
|
||||
private static final MimeType SMILE_MIME_TYPE = new MimeType("application", "x-jackson-smile");
|
||||
private static final MimeType STREAM_SMILE_MIME_TYPE = new MimeType("application", "stream+x-jackson-smile");
|
||||
@@ -56,7 +56,7 @@ public class Jackson2SmileDecoderTests extends AbstractDecoderTests<Jackson2Smil
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void canDecode() {
|
||||
protected void canDecode() {
|
||||
assertThat(decoder.canDecode(ResolvableType.forClass(Pojo.class), SMILE_MIME_TYPE)).isTrue();
|
||||
assertThat(decoder.canDecode(ResolvableType.forClass(Pojo.class), STREAM_SMILE_MIME_TYPE)).isTrue();
|
||||
assertThat(decoder.canDecode(ResolvableType.forClass(Pojo.class), null)).isTrue();
|
||||
@@ -67,7 +67,7 @@ public class Jackson2SmileDecoderTests extends AbstractDecoderTests<Jackson2Smil
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void decode() {
|
||||
protected void decode() {
|
||||
Flux<DataBuffer> input = Flux.just(this.pojo1, this.pojo2)
|
||||
.map(this::writeObject)
|
||||
.flatMap(this::dataBuffer);
|
||||
@@ -91,7 +91,7 @@ public class Jackson2SmileDecoderTests extends AbstractDecoderTests<Jackson2Smil
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void decodeToMono() {
|
||||
protected void decodeToMono() {
|
||||
List<Pojo> expected = Arrays.asList(pojo1, pojo2);
|
||||
|
||||
Flux<DataBuffer> input = Flux.just(expected)
|
||||
|
||||
@@ -46,7 +46,7 @@ import static org.springframework.http.MediaType.APPLICATION_XML;
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
public class Jackson2SmileEncoderTests extends AbstractEncoderTests<Jackson2SmileEncoder> {
|
||||
class Jackson2SmileEncoderTests extends AbstractEncoderTests<Jackson2SmileEncoder> {
|
||||
|
||||
private static final MimeType SMILE_MIME_TYPE = new MimeType("application", "x-jackson-smile");
|
||||
private static final MimeType STREAM_SMILE_MIME_TYPE = new MimeType("application", "stream+x-jackson-smile");
|
||||
@@ -62,7 +62,7 @@ public class Jackson2SmileEncoderTests extends AbstractEncoderTests<Jackson2Smil
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void canEncode() {
|
||||
protected void canEncode() {
|
||||
ResolvableType pojoType = ResolvableType.forClass(Pojo.class);
|
||||
assertThat(this.encoder.canEncode(pojoType, SMILE_MIME_TYPE)).isTrue();
|
||||
assertThat(this.encoder.canEncode(pojoType, STREAM_SMILE_MIME_TYPE)).isTrue();
|
||||
@@ -73,7 +73,7 @@ public class Jackson2SmileEncoderTests extends AbstractEncoderTests<Jackson2Smil
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canNotEncode() {
|
||||
void canNotEncode() {
|
||||
assertThat(this.encoder.canEncode(ResolvableType.forClass(String.class), null)).isFalse();
|
||||
assertThat(this.encoder.canEncode(ResolvableType.forClass(Pojo.class), APPLICATION_XML)).isFalse();
|
||||
|
||||
@@ -83,7 +83,7 @@ public class Jackson2SmileEncoderTests extends AbstractEncoderTests<Jackson2Smil
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void encode() {
|
||||
protected void encode() {
|
||||
List<Pojo> list = Arrays.asList(
|
||||
new Pojo("foo", "bar"),
|
||||
new Pojo("foofoo", "barbar"),
|
||||
@@ -108,13 +108,13 @@ public class Jackson2SmileEncoderTests extends AbstractEncoderTests<Jackson2Smil
|
||||
}
|
||||
|
||||
@Test
|
||||
public void encodeError() {
|
||||
void encodeError() {
|
||||
Mono<Pojo> input = Mono.error(new InputException());
|
||||
testEncode(input, Pojo.class, step -> step.expectError(InputException.class).verify());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void encodeAsStream() {
|
||||
void encodeAsStream() {
|
||||
Pojo pojo1 = new Pojo("foo", "bar");
|
||||
Pojo pojo2 = new Pojo("foofoo", "barbar");
|
||||
Pojo pojo3 = new Pojo("foofoofoo", "barbarbar");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -54,7 +54,7 @@ import static org.assertj.core.api.Assertions.fail;
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class Jackson2TokenizerTests extends AbstractLeakCheckingTests {
|
||||
class Jackson2TokenizerTests extends AbstractLeakCheckingTests {
|
||||
|
||||
private JsonFactory jsonFactory;
|
||||
|
||||
@@ -62,14 +62,14 @@ public class Jackson2TokenizerTests extends AbstractLeakCheckingTests {
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void createParser() {
|
||||
void createParser() {
|
||||
this.jsonFactory = new JsonFactory();
|
||||
this.objectMapper = new ObjectMapper(this.jsonFactory);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void doNotTokenizeArrayElements() {
|
||||
void doNotTokenizeArrayElements() {
|
||||
testTokenize(
|
||||
singletonList("{\"foo\": \"foofoo\", \"bar\": \"barbar\"}"),
|
||||
singletonList("{\"foo\": \"foofoo\", \"bar\": \"barbar\"}"), false);
|
||||
@@ -118,7 +118,7 @@ public class Jackson2TokenizerTests extends AbstractLeakCheckingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void tokenizeArrayElements() {
|
||||
void tokenizeArrayElements() {
|
||||
testTokenize(
|
||||
singletonList("{\"foo\": \"foofoo\", \"bar\": \"barbar\"}"),
|
||||
singletonList("{\"foo\": \"foofoo\", \"bar\": \"barbar\"}"), true);
|
||||
@@ -251,7 +251,7 @@ public class Jackson2TokenizerTests extends AbstractLeakCheckingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLimit() {
|
||||
void testLimit() {
|
||||
List<String> source = asList(
|
||||
"[",
|
||||
"{", "\"id\":1,\"name\":\"Dan\"", "},",
|
||||
@@ -272,7 +272,7 @@ public class Jackson2TokenizerTests extends AbstractLeakCheckingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLimitTokenized() {
|
||||
void testLimitTokenized() {
|
||||
|
||||
List<String> source = asList(
|
||||
"[",
|
||||
@@ -298,7 +298,7 @@ public class Jackson2TokenizerTests extends AbstractLeakCheckingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void errorInStream() {
|
||||
void errorInStream() {
|
||||
DataBuffer buffer = stringBuffer("{\"id\":1,\"name\":");
|
||||
Flux<DataBuffer> source = Flux.just(buffer).concatWith(Flux.error(new RuntimeException()));
|
||||
Flux<TokenBuffer> result = Jackson2Tokenizer.tokenize(source, this.jsonFactory, this.objectMapper, true,
|
||||
@@ -321,7 +321,7 @@ public class Jackson2TokenizerTests extends AbstractLeakCheckingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void useBigDecimalForFloats() {
|
||||
void useBigDecimalForFloats() {
|
||||
Flux<DataBuffer> source = Flux.just(stringBuffer("1E+2"));
|
||||
Flux<TokenBuffer> tokens = Jackson2Tokenizer.tokenize(
|
||||
source, this.jsonFactory, this.objectMapper, false, true, -1);
|
||||
@@ -344,7 +344,7 @@ public class Jackson2TokenizerTests extends AbstractLeakCheckingTests {
|
||||
|
||||
// gh-31747
|
||||
@Test
|
||||
public void compositeNettyBuffer() {
|
||||
void compositeNettyBuffer() {
|
||||
ByteBufAllocator allocator = UnpooledByteBufAllocator.DEFAULT;
|
||||
ByteBuf firstByteBuf = allocator.buffer();
|
||||
firstByteBuf.writeBytes("{\"foo\": \"foofoo\"".getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -24,6 +24,7 @@ import com.fasterxml.jackson.databind.ObjectWriter;
|
||||
import com.fasterxml.jackson.dataformat.csv.CsvMapper;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.test.StepVerifier.LastStep;
|
||||
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.core.testfixture.codec.AbstractEncoderTests;
|
||||
@@ -70,7 +71,7 @@ class JacksonCsvEncoderTests extends AbstractEncoderTests<org.springframework.ht
|
||||
// this test did not fail directly but logged a NullPointerException dropped by the reactive pipeline
|
||||
void encodeEmptyFlux() {
|
||||
Flux<Object> input = Flux.empty();
|
||||
testEncode(input, Pojo.class, step -> step.verifyComplete());
|
||||
testEncode(input, Pojo.class, LastStep::verifyComplete);
|
||||
}
|
||||
|
||||
static class JacksonCsvEncoder extends AbstractJackson2Encoder {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -435,7 +435,6 @@ class DefaultPartHttpMessageReaderTests {
|
||||
@interface ParameterizedDefaultPartHttpMessageReaderTest {
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
static Stream<Arguments> messageReaders() {
|
||||
DefaultPartHttpMessageReader inMemory = new DefaultPartHttpMessageReader();
|
||||
inMemory.setMaxInMemorySize(1000);
|
||||
|
||||
@@ -56,7 +56,7 @@ import static org.mockito.Mockito.mock;
|
||||
* @author Sebastien Deleuze
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class MultipartHttpMessageWriterTests extends AbstractLeakCheckingTests {
|
||||
class MultipartHttpMessageWriterTests extends AbstractLeakCheckingTests {
|
||||
|
||||
private final MultipartHttpMessageWriter writer =
|
||||
new MultipartHttpMessageWriter(ClientCodecConfigurer.create().getWriters());
|
||||
@@ -65,7 +65,7 @@ public class MultipartHttpMessageWriterTests extends AbstractLeakCheckingTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void canWrite() {
|
||||
void canWrite() {
|
||||
assertThat(this.writer.canWrite(
|
||||
ResolvableType.forClassWithGenerics(MultiValueMap.class, String.class, Object.class),
|
||||
MediaType.MULTIPART_FORM_DATA)).isTrue();
|
||||
@@ -88,7 +88,7 @@ public class MultipartHttpMessageWriterTests extends AbstractLeakCheckingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeMultipartFormData() throws Exception {
|
||||
void writeMultipartFormData() throws Exception {
|
||||
Resource logo = new ClassPathResource("/org/springframework/http/converter/logo.jpg");
|
||||
Resource utf8 = new ClassPathResource("/org/springframework/http/converter/logo.jpg") {
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -59,13 +59,13 @@ class PartEventHttpMessageReaderTests {
|
||||
private final PartEventHttpMessageReader reader = new PartEventHttpMessageReader();
|
||||
|
||||
@Test
|
||||
public void canRead() {
|
||||
void canRead() {
|
||||
assertThat(this.reader.canRead(forClass(PartEvent.class), MediaType.MULTIPART_FORM_DATA)).isTrue();
|
||||
assertThat(this.reader.canRead(forClass(PartEvent.class), null)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simple() {
|
||||
void simple() {
|
||||
MockServerHttpRequest request = createRequest(
|
||||
new ClassPathResource("simple.multipart", getClass()), "simple-boundary");
|
||||
|
||||
@@ -79,7 +79,7 @@ class PartEventHttpMessageReaderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noHeaders() {
|
||||
void noHeaders() {
|
||||
MockServerHttpRequest request = createRequest(
|
||||
new ClassPathResource("no-header.multipart", getClass()), "boundary");
|
||||
Flux<PartEvent> result = this.reader.read(forClass(PartEvent.class), request, emptyMap());
|
||||
@@ -90,7 +90,7 @@ class PartEventHttpMessageReaderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noEndBoundary() {
|
||||
void noEndBoundary() {
|
||||
MockServerHttpRequest request = createRequest(
|
||||
new ClassPathResource("no-end-boundary.multipart", getClass()), "boundary");
|
||||
|
||||
@@ -102,7 +102,7 @@ class PartEventHttpMessageReaderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void garbage() {
|
||||
void garbage() {
|
||||
MockServerHttpRequest request = createRequest(
|
||||
new ClassPathResource("garbage-1.multipart", getClass()), "boundary");
|
||||
|
||||
@@ -115,7 +115,7 @@ class PartEventHttpMessageReaderTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void noEndHeader() {
|
||||
void noEndHeader() {
|
||||
MockServerHttpRequest request = createRequest(
|
||||
new ClassPathResource("no-end-header.multipart", getClass()), "boundary");
|
||||
Flux<PartEvent> result = this.reader.read(forClass(PartEvent.class), request, emptyMap());
|
||||
@@ -126,7 +126,7 @@ class PartEventHttpMessageReaderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noEndBody() {
|
||||
void noEndBody() {
|
||||
MockServerHttpRequest request = createRequest(
|
||||
new ClassPathResource("no-end-body.multipart", getClass()), "boundary");
|
||||
Flux<PartEvent> result = this.reader.read(forClass(PartEvent.class), request, emptyMap());
|
||||
@@ -137,7 +137,7 @@ class PartEventHttpMessageReaderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noBody() {
|
||||
void noBody() {
|
||||
MockServerHttpRequest request = createRequest(
|
||||
new ClassPathResource("no-body.multipart", getClass()), "boundary");
|
||||
Flux<PartEvent> result = this.reader.read(forClass(PartEvent.class), request, emptyMap());
|
||||
@@ -150,7 +150,7 @@ class PartEventHttpMessageReaderTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void cancel() {
|
||||
void cancel() {
|
||||
MockServerHttpRequest request = createRequest(
|
||||
new ClassPathResource("simple.multipart", getClass()), "simple-boundary");
|
||||
Flux<PartEvent> result = this.reader.read(forClass(PartEvent.class), request, emptyMap());
|
||||
@@ -164,7 +164,7 @@ class PartEventHttpMessageReaderTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void firefox() {
|
||||
void firefox() {
|
||||
|
||||
MockServerHttpRequest request = createRequest(new ClassPathResource("firefox.multipart", getClass()),
|
||||
"---------------------------18399284482060392383840973206");
|
||||
@@ -186,7 +186,7 @@ class PartEventHttpMessageReaderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void chrome() {
|
||||
void chrome() {
|
||||
|
||||
MockServerHttpRequest request = createRequest(new ClassPathResource("chrome.multipart", getClass()),
|
||||
"----WebKitFormBoundaryEveBLvRT65n21fwU");
|
||||
@@ -207,7 +207,7 @@ class PartEventHttpMessageReaderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void safari() {
|
||||
void safari() {
|
||||
|
||||
MockServerHttpRequest request = createRequest(new ClassPathResource("safari.multipart", getClass()),
|
||||
"----WebKitFormBoundaryG8fJ50opQOML0oGD");
|
||||
@@ -275,7 +275,7 @@ class PartEventHttpMessageReaderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void utf8Headers() {
|
||||
void utf8Headers() {
|
||||
MockServerHttpRequest request = createRequest(
|
||||
new ClassPathResource("utf8.multipart", getClass()), "\"simple-boundary\"");
|
||||
|
||||
@@ -288,7 +288,7 @@ class PartEventHttpMessageReaderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void exceedHeaderLimit() {
|
||||
void exceedHeaderLimit() {
|
||||
Flux<DataBuffer> body = DataBufferUtils
|
||||
.readByteChannel((new ClassPathResource("files.multipart", getClass()))::readableChannel, bufferFactory,
|
||||
282);
|
||||
|
||||
@@ -43,7 +43,7 @@ import static org.springframework.http.codec.multipart.MultipartHttpMessageWrite
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class PartEventHttpMessageWriterTests extends AbstractLeakCheckingTests {
|
||||
class PartEventHttpMessageWriterTests extends AbstractLeakCheckingTests {
|
||||
|
||||
private final PartEventHttpMessageWriter writer = new PartEventHttpMessageWriter();
|
||||
|
||||
@@ -51,7 +51,7 @@ public class PartEventHttpMessageWriterTests extends AbstractLeakCheckingTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void canWrite() {
|
||||
void canWrite() {
|
||||
assertThat(this.writer.canWrite(ResolvableType.forClass(PartEvent.class), MediaType.MULTIPART_FORM_DATA)).isTrue();
|
||||
assertThat(this.writer.canWrite(ResolvableType.forClass(FilePartEvent.class), MediaType.MULTIPART_FORM_DATA)).isTrue();
|
||||
assertThat(this.writer.canWrite(ResolvableType.forClass(FormPartEvent.class), MediaType.MULTIPART_FORM_DATA)).isTrue();
|
||||
|
||||
@@ -43,7 +43,7 @@ import static org.springframework.http.codec.multipart.MultipartHttpMessageWrite
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 5.3
|
||||
*/
|
||||
public class PartHttpMessageWriterTests extends AbstractLeakCheckingTests {
|
||||
class PartHttpMessageWriterTests extends AbstractLeakCheckingTests {
|
||||
|
||||
private final PartHttpMessageWriter writer = new PartHttpMessageWriter();
|
||||
|
||||
@@ -51,7 +51,7 @@ public class PartHttpMessageWriterTests extends AbstractLeakCheckingTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void canWrite() {
|
||||
void canWrite() {
|
||||
assertThat(this.writer.canWrite(ResolvableType.forClass(Part.class), MediaType.MULTIPART_FORM_DATA)).isTrue();
|
||||
assertThat(this.writer.canWrite(ResolvableType.forClass(Part.class), MediaType.MULTIPART_MIXED)).isTrue();
|
||||
assertThat(this.writer.canWrite(ResolvableType.forClass(Part.class), MediaType.MULTIPART_RELATED)).isTrue();
|
||||
|
||||
@@ -45,7 +45,7 @@ import static org.springframework.core.io.buffer.DataBufferUtils.release;
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
public class ProtobufDecoderTests extends AbstractDecoderTests<ProtobufDecoder> {
|
||||
class ProtobufDecoderTests extends AbstractDecoderTests<ProtobufDecoder> {
|
||||
|
||||
private final SecondMsg secondMsg = SecondMsg.newBuilder().setBlah(123).build();
|
||||
|
||||
@@ -61,7 +61,7 @@ public class ProtobufDecoderTests extends AbstractDecoderTests<ProtobufDecoder>
|
||||
|
||||
|
||||
@Test
|
||||
public void extensionRegistryNull() {
|
||||
void extensionRegistryNull() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new ProtobufDecoder(null));
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ public class ProtobufDecoderTests extends AbstractDecoderTests<ProtobufDecoder>
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decodeChunksToMono() {
|
||||
void decodeChunksToMono() {
|
||||
byte[] full = this.testMsg1.toByteArray();
|
||||
byte[] chunk1 = Arrays.copyOfRange(full, 0, full.length / 2);
|
||||
byte[] chunk2 = Arrays.copyOfRange(full, chunk1.length, full.length);
|
||||
@@ -211,7 +211,7 @@ public class ProtobufDecoderTests extends AbstractDecoderTests<ProtobufDecoder>
|
||||
}
|
||||
|
||||
@Test
|
||||
public void exceedMaxSize() {
|
||||
void exceedMaxSize() {
|
||||
this.decoder.setMaxMessageSize(1);
|
||||
Mono<DataBuffer> input = dataBuffer(this.testMsg1);
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ import static org.springframework.core.ResolvableType.forClass;
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
public class ProtobufEncoderTests extends AbstractEncoderTests<ProtobufEncoder> {
|
||||
class ProtobufEncoderTests extends AbstractEncoderTests<ProtobufEncoder> {
|
||||
|
||||
private static final MimeType PROTOBUF_MIME_TYPE = new MimeType("application", "x-protobuf");
|
||||
|
||||
@@ -58,7 +58,7 @@ public class ProtobufEncoderTests extends AbstractEncoderTests<ProtobufEncoder>
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void canEncode() {
|
||||
protected void canEncode() {
|
||||
assertThat(this.encoder.canEncode(forClass(Msg.class), null)).isTrue();
|
||||
assertThat(this.encoder.canEncode(forClass(Msg.class), PROTOBUF_MIME_TYPE)).isTrue();
|
||||
assertThat(this.encoder.canEncode(forClass(Msg.class), MediaType.APPLICATION_OCTET_STREAM)).isTrue();
|
||||
@@ -68,7 +68,7 @@ public class ProtobufEncoderTests extends AbstractEncoderTests<ProtobufEncoder>
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void encode() {
|
||||
protected void encode() {
|
||||
Mono<Message> input = Mono.just(this.msg1);
|
||||
|
||||
testEncodeAll(input, Msg.class, step -> step
|
||||
@@ -88,7 +88,7 @@ public class ProtobufEncoderTests extends AbstractEncoderTests<ProtobufEncoder>
|
||||
}
|
||||
|
||||
@Test
|
||||
public void encodeStream() {
|
||||
void encodeStream() {
|
||||
Flux<Message> input = Flux.just(this.msg1, this.msg2);
|
||||
|
||||
testEncodeAll(input, Msg.class, step -> step
|
||||
|
||||
@@ -86,7 +86,7 @@ import static org.springframework.core.ResolvableType.forClass;
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class ClientCodecConfigurerTests {
|
||||
class ClientCodecConfigurerTests {
|
||||
|
||||
private final ClientCodecConfigurer configurer = new DefaultClientCodecConfigurer();
|
||||
|
||||
@@ -94,7 +94,7 @@ public class ClientCodecConfigurerTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void defaultReaders() {
|
||||
void defaultReaders() {
|
||||
List<HttpMessageReader<?>> readers = this.configurer.getReaders();
|
||||
assertThat(readers).hasSize(20);
|
||||
assertThat(getNextDecoder(readers).getClass()).isEqualTo(ByteArrayDecoder.class);
|
||||
@@ -121,7 +121,7 @@ public class ClientCodecConfigurerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultWriters() {
|
||||
void defaultWriters() {
|
||||
List<HttpMessageWriter<?>> writers = this.configurer.getWriters();
|
||||
assertThat(writers).hasSize(18);
|
||||
assertThat(getNextEncoder(writers).getClass()).isEqualTo(ByteArrayEncoder.class);
|
||||
@@ -145,7 +145,7 @@ public class ClientCodecConfigurerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jackson2CodecCustomization() {
|
||||
void jackson2CodecCustomization() {
|
||||
Jackson2JsonDecoder decoder = new Jackson2JsonDecoder();
|
||||
Jackson2JsonEncoder encoder = new Jackson2JsonEncoder();
|
||||
this.configurer.defaultCodecs().jackson2JsonDecoder(decoder);
|
||||
@@ -166,7 +166,7 @@ public class ClientCodecConfigurerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void objectMapperCustomization() {
|
||||
void objectMapperCustomization() {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
this.configurer.defaultCodecs().configureDefaultCodec(codec -> {
|
||||
if (codec instanceof Jackson2CodecSupport) {
|
||||
@@ -188,7 +188,7 @@ public class ClientCodecConfigurerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void maxInMemorySize() {
|
||||
void maxInMemorySize() {
|
||||
int size = 99;
|
||||
this.configurer.defaultCodecs().maxInMemorySize(size);
|
||||
List<HttpMessageReader<?>> readers = this.configurer.getReaders();
|
||||
@@ -220,7 +220,7 @@ public class ClientCodecConfigurerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void enableLoggingRequestDetails() {
|
||||
void enableLoggingRequestDetails() {
|
||||
this.configurer.defaultCodecs().enableLoggingRequestDetails(true);
|
||||
|
||||
List<HttpMessageWriter<?>> writers = this.configurer.getWriters();
|
||||
@@ -233,7 +233,7 @@ public class ClientCodecConfigurerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clonedConfigurer() {
|
||||
void clonedConfigurer() {
|
||||
ClientCodecConfigurer clone = this.configurer.clone();
|
||||
|
||||
Jackson2JsonDecoder jackson2Decoder = new Jackson2JsonDecoder();
|
||||
@@ -269,7 +269,7 @@ public class ClientCodecConfigurerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cloneShouldNotBeImpactedByChangesToOriginal() {
|
||||
void cloneShouldNotBeImpactedByChangesToOriginal() {
|
||||
|
||||
ClientCodecConfigurer clone = this.configurer.clone();
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ import static org.springframework.core.ResolvableType.forClass;
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class ServerCodecConfigurerTests {
|
||||
class ServerCodecConfigurerTests {
|
||||
|
||||
private final ServerCodecConfigurer configurer = new DefaultServerCodecConfigurer();
|
||||
|
||||
@@ -92,7 +92,7 @@ public class ServerCodecConfigurerTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void defaultReaders() {
|
||||
void defaultReaders() {
|
||||
List<HttpMessageReader<?>> readers = this.configurer.getReaders();
|
||||
assertThat(readers).hasSize(19);
|
||||
assertThat(getNextDecoder(readers).getClass()).isEqualTo(ByteArrayDecoder.class);
|
||||
@@ -117,7 +117,7 @@ public class ServerCodecConfigurerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultWriters() {
|
||||
void defaultWriters() {
|
||||
List<HttpMessageWriter<?>> writers = this.configurer.getWriters();
|
||||
assertThat(writers).hasSize(19);
|
||||
assertThat(getNextEncoder(writers).getClass()).isEqualTo(ByteArrayEncoder.class);
|
||||
@@ -142,7 +142,7 @@ public class ServerCodecConfigurerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jackson2EncoderOverride() {
|
||||
void jackson2EncoderOverride() {
|
||||
Jackson2JsonDecoder decoder = new Jackson2JsonDecoder();
|
||||
Jackson2JsonEncoder encoder = new Jackson2JsonEncoder();
|
||||
this.configurer.defaultCodecs().jackson2JsonDecoder(decoder);
|
||||
@@ -159,7 +159,7 @@ public class ServerCodecConfigurerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void maxInMemorySize() {
|
||||
void maxInMemorySize() {
|
||||
int size = 99;
|
||||
this.configurer.defaultCodecs().maxInMemorySize(size);
|
||||
|
||||
@@ -190,7 +190,7 @@ public class ServerCodecConfigurerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void maxInMemorySizeWithCustomCodecs() {
|
||||
void maxInMemorySizeWithCustomCodecs() {
|
||||
|
||||
int size = 99;
|
||||
this.configurer.defaultCodecs().maxInMemorySize(size);
|
||||
@@ -212,7 +212,7 @@ public class ServerCodecConfigurerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void enableRequestLoggingDetails() {
|
||||
void enableRequestLoggingDetails() {
|
||||
this.configurer.defaultCodecs().enableLoggingRequestDetails(true);
|
||||
|
||||
List<HttpMessageReader<?>> readers = this.configurer.getReaders();
|
||||
@@ -226,7 +226,7 @@ public class ServerCodecConfigurerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void enableRequestLoggingDetailsWithCustomCodecs() {
|
||||
void enableRequestLoggingDetailsWithCustomCodecs() {
|
||||
|
||||
this.configurer.registerDefaults(false);
|
||||
this.configurer.defaultCodecs().enableLoggingRequestDetails(true);
|
||||
@@ -241,7 +241,7 @@ public class ServerCodecConfigurerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cloneConfigurer() {
|
||||
void cloneConfigurer() {
|
||||
ServerCodecConfigurer clone = this.configurer.clone();
|
||||
|
||||
MultipartHttpMessageReader reader = new MultipartHttpMessageReader(new DefaultPartHttpMessageReader());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class Jaxb2HelperTests {
|
||||
|
||||
@Test
|
||||
public void toExpectedQName() {
|
||||
void toExpectedQName() {
|
||||
assertThat(Jaxb2Helper.toQNames(Pojo.class)).containsExactly(new QName("pojo"));
|
||||
assertThat(Jaxb2Helper.toQNames(TypePojo.class)).containsExactly(new QName("pojo"));
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -46,7 +46,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
/**
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
public class Jaxb2XmlDecoderTests extends AbstractLeakCheckingTests {
|
||||
class Jaxb2XmlDecoderTests extends AbstractLeakCheckingTests {
|
||||
|
||||
private static final String POJO_ROOT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
|
||||
"<pojo>" +
|
||||
@@ -76,7 +76,7 @@ public class Jaxb2XmlDecoderTests extends AbstractLeakCheckingTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void canDecode() {
|
||||
void canDecode() {
|
||||
assertThat(this.decoder.canDecode(ResolvableType.forClass(Pojo.class),
|
||||
MediaType.APPLICATION_XML)).isTrue();
|
||||
assertThat(this.decoder.canDecode(ResolvableType.forClass(Pojo.class),
|
||||
@@ -90,7 +90,7 @@ public class Jaxb2XmlDecoderTests extends AbstractLeakCheckingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void splitOneBranches() {
|
||||
void splitOneBranches() {
|
||||
Flux<XMLEvent> xmlEvents = this.xmlEventDecoder.decode(toDataBufferMono(POJO_ROOT), null, null, HINTS);
|
||||
Flux<List<XMLEvent>> result = Jaxb2Helper.split(xmlEvents, Set.of(new QName("pojo")));
|
||||
|
||||
@@ -111,7 +111,7 @@ public class Jaxb2XmlDecoderTests extends AbstractLeakCheckingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void splitMultipleBranches() {
|
||||
void splitMultipleBranches() {
|
||||
Flux<XMLEvent> xmlEvents = this.xmlEventDecoder.decode(toDataBufferMono(POJO_CHILD), null, null, HINTS);
|
||||
Flux<List<XMLEvent>> result = Jaxb2Helper.split(xmlEvents, Set.of(new QName("pojo")));
|
||||
|
||||
@@ -159,7 +159,7 @@ public class Jaxb2XmlDecoderTests extends AbstractLeakCheckingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decodeSingleXmlRootElement() {
|
||||
void decodeSingleXmlRootElement() {
|
||||
Mono<DataBuffer> source = toDataBufferMono(POJO_ROOT);
|
||||
Mono<Object> output = this.decoder.decodeToMono(source, ResolvableType.forClass(Pojo.class), null, HINTS);
|
||||
|
||||
@@ -170,7 +170,7 @@ public class Jaxb2XmlDecoderTests extends AbstractLeakCheckingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decodeSingleXmlTypeElement() {
|
||||
void decodeSingleXmlTypeElement() {
|
||||
Mono<DataBuffer> source = toDataBufferMono(POJO_ROOT);
|
||||
Mono<Object> output = this.decoder.decodeToMono(source, ResolvableType.forClass(TypePojo.class), null, HINTS);
|
||||
|
||||
@@ -181,7 +181,7 @@ public class Jaxb2XmlDecoderTests extends AbstractLeakCheckingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decodeMultipleXmlRootElement() {
|
||||
void decodeMultipleXmlRootElement() {
|
||||
Mono<DataBuffer> source = toDataBufferMono(POJO_CHILD);
|
||||
Flux<Object> output = this.decoder.decode(source, ResolvableType.forClass(Pojo.class), null, HINTS);
|
||||
|
||||
@@ -193,7 +193,7 @@ public class Jaxb2XmlDecoderTests extends AbstractLeakCheckingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decodeMultipleXmlTypeElement() {
|
||||
void decodeMultipleXmlTypeElement() {
|
||||
Mono<DataBuffer> source = toDataBufferMono(POJO_CHILD);
|
||||
Flux<Object> output = this.decoder.decode(source, ResolvableType.forClass(TypePojo.class), null, HINTS);
|
||||
|
||||
@@ -205,7 +205,7 @@ public class Jaxb2XmlDecoderTests extends AbstractLeakCheckingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decodeXmlSeeAlso() {
|
||||
void decodeXmlSeeAlso() {
|
||||
Mono<DataBuffer> source = toDataBufferMono(POJO_CHILD);
|
||||
Flux<Object> output = this.decoder.decode(source, ResolvableType.forClass(Parent.class), null, HINTS);
|
||||
|
||||
@@ -218,7 +218,7 @@ public class Jaxb2XmlDecoderTests extends AbstractLeakCheckingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decodeError() {
|
||||
void decodeError() {
|
||||
Flux<DataBuffer> source = Flux.concat(
|
||||
toDataBufferMono("<pojo>"),
|
||||
Flux.error(new RuntimeException()));
|
||||
@@ -240,7 +240,7 @@ public class Jaxb2XmlDecoderTests extends AbstractLeakCheckingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decodeNonUtf8() {
|
||||
void decodeNonUtf8() {
|
||||
String xml = "<pojo>" +
|
||||
"<foo>føø</foo>" +
|
||||
"<bar>bär</bar>" +
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -46,7 +46,7 @@ import static org.springframework.core.io.buffer.DataBufferUtils.release;
|
||||
* @author Sebastien Deleuze
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class Jaxb2XmlEncoderTests extends AbstractEncoderTests<Jaxb2XmlEncoder> {
|
||||
class Jaxb2XmlEncoderTests extends AbstractEncoderTests<Jaxb2XmlEncoder> {
|
||||
|
||||
public Jaxb2XmlEncoderTests() {
|
||||
super(new Jaxb2XmlEncoder());
|
||||
@@ -54,7 +54,7 @@ public class Jaxb2XmlEncoderTests extends AbstractEncoderTests<Jaxb2XmlEncoder>
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void canEncode() {
|
||||
protected void canEncode() {
|
||||
assertThat(this.encoder.canEncode(forClass(Pojo.class), MediaType.APPLICATION_XML)).isTrue();
|
||||
assertThat(this.encoder.canEncode(forClass(Pojo.class), MediaType.TEXT_XML)).isTrue();
|
||||
assertThat(this.encoder.canEncode(forClass(Pojo.class), new MediaType("application", "foo+xml"))).isTrue();
|
||||
@@ -69,7 +69,7 @@ public class Jaxb2XmlEncoderTests extends AbstractEncoderTests<Jaxb2XmlEncoder>
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void encode() {
|
||||
protected void encode() {
|
||||
Mono<Pojo> input = Mono.just(new Pojo("foofoo", "barbar"));
|
||||
|
||||
testEncode(input, Pojo.class, step -> step
|
||||
@@ -80,7 +80,7 @@ public class Jaxb2XmlEncoderTests extends AbstractEncoderTests<Jaxb2XmlEncoder>
|
||||
}
|
||||
|
||||
@Test
|
||||
public void encodeJaxbElement() {
|
||||
void encodeJaxbElement() {
|
||||
Mono<JAXBElement<Pojo>> input = Mono.just(new JAXBElement<>(new QName("baz"), Pojo.class,
|
||||
new Pojo("foofoo", "barbar")));
|
||||
|
||||
@@ -92,13 +92,13 @@ public class Jaxb2XmlEncoderTests extends AbstractEncoderTests<Jaxb2XmlEncoder>
|
||||
}
|
||||
|
||||
@Test
|
||||
public void encodeError() {
|
||||
void encodeError() {
|
||||
Flux<Pojo> input = Flux.error(RuntimeException::new);
|
||||
testEncode(input, Pojo.class, step -> step.expectError(RuntimeException.class).verify());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void encodeElementsWithCommonType() {
|
||||
void encodeElementsWithCommonType() {
|
||||
Mono<Container> input = Mono.just(new Container());
|
||||
|
||||
testEncode(input, Pojo.class, step -> step
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class XmlEventDecoderTests extends AbstractLeakCheckingTests {
|
||||
class XmlEventDecoderTests extends AbstractLeakCheckingTests {
|
||||
|
||||
private static final String XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
|
||||
"<pojo>" +
|
||||
@@ -43,11 +43,11 @@ public class XmlEventDecoderTests extends AbstractLeakCheckingTests {
|
||||
"<bar>barbar</bar>" +
|
||||
"</pojo>";
|
||||
|
||||
private XmlEventDecoder decoder = new XmlEventDecoder();
|
||||
private final XmlEventDecoder decoder = new XmlEventDecoder();
|
||||
|
||||
|
||||
@Test
|
||||
public void toXMLEventsAalto() {
|
||||
void toXMLEventsAalto() {
|
||||
|
||||
Flux<XMLEvent> events =
|
||||
this.decoder.decode(stringBufferMono(XML), null, null, Collections.emptyMap());
|
||||
@@ -67,7 +67,7 @@ public class XmlEventDecoderTests extends AbstractLeakCheckingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toXMLEventsNonAalto() {
|
||||
void toXMLEventsNonAalto() {
|
||||
decoder.useAalto = false;
|
||||
|
||||
Flux<XMLEvent> events =
|
||||
@@ -89,7 +89,7 @@ public class XmlEventDecoderTests extends AbstractLeakCheckingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toXMLEventsWithLimit() {
|
||||
void toXMLEventsWithLimit() {
|
||||
|
||||
this.decoder.setMaxInMemorySize(6);
|
||||
|
||||
@@ -111,7 +111,7 @@ public class XmlEventDecoderTests extends AbstractLeakCheckingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decodeErrorAalto() {
|
||||
void decodeErrorAalto() {
|
||||
Flux<DataBuffer> source = Flux.concat(
|
||||
stringBufferMono("<pojo>"),
|
||||
Flux.error(new RuntimeException()));
|
||||
@@ -127,7 +127,7 @@ public class XmlEventDecoderTests extends AbstractLeakCheckingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decodeErrorNonAalto() {
|
||||
void decodeErrorNonAalto() {
|
||||
decoder.useAalto = false;
|
||||
|
||||
Flux<DataBuffer> source = Flux.concat(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -28,30 +28,30 @@ import org.springframework.web.testfixture.http.MockHttpOutputMessage;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/** @author Arjen Poutsma */
|
||||
public class ByteArrayHttpMessageConverterTests {
|
||||
class ByteArrayHttpMessageConverterTests {
|
||||
|
||||
private ByteArrayHttpMessageConverter converter;
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
void setUp() {
|
||||
converter = new ByteArrayHttpMessageConverter();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void canRead() {
|
||||
void canRead() {
|
||||
assertThat(converter.canRead(byte[].class, new MediaType("application", "octet-stream"))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canWrite() {
|
||||
void canWrite() {
|
||||
assertThat(converter.canWrite(byte[].class, new MediaType("application", "octet-stream"))).isTrue();
|
||||
assertThat(converter.canWrite(byte[].class, MediaType.ALL)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void read() throws IOException {
|
||||
void read() throws IOException {
|
||||
byte[] body = new byte[]{0x1, 0x2};
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body);
|
||||
inputMessage.getHeaders().setContentType(new MediaType("application", "octet-stream"));
|
||||
@@ -60,7 +60,7 @@ public class ByteArrayHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readWithContentLengthHeaderSet() throws IOException {
|
||||
void readWithContentLengthHeaderSet() throws IOException {
|
||||
byte[] body = new byte[]{0x1, 0x2, 0x3, 0x4, 0x5};
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body);
|
||||
inputMessage.getHeaders().setContentType(new MediaType("application", "octet-stream"));
|
||||
@@ -70,7 +70,7 @@ public class ByteArrayHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void write() throws IOException {
|
||||
void write() throws IOException {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
byte[] body = new byte[]{0x1, 0x2};
|
||||
converter.write(body, null, outputMessage);
|
||||
@@ -80,7 +80,7 @@ public class ByteArrayHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void repeatableWrites() throws IOException {
|
||||
void repeatableWrites() throws IOException {
|
||||
MockHttpOutputMessage outputMessage1 = new MockHttpOutputMessage();
|
||||
byte[] body = new byte[]{0x1, 0x2};
|
||||
assertThat(converter.supportsRepeatableWrites(body)).isTrue();
|
||||
|
||||
@@ -64,13 +64,13 @@ import static org.springframework.http.MediaType.TEXT_XML;
|
||||
* @author Sam Brannen
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
public class FormHttpMessageConverterTests {
|
||||
class FormHttpMessageConverterTests {
|
||||
|
||||
private final FormHttpMessageConverter converter = new AllEncompassingFormHttpMessageConverter();
|
||||
|
||||
|
||||
@Test
|
||||
public void canRead() {
|
||||
void canRead() {
|
||||
assertCanRead(MultiValueMap.class, null);
|
||||
assertCanRead(APPLICATION_FORM_URLENCODED);
|
||||
|
||||
@@ -79,7 +79,7 @@ public class FormHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cannotReadMultipart() {
|
||||
void cannotReadMultipart() {
|
||||
// Without custom multipart types supported
|
||||
asssertCannotReadMultipart();
|
||||
|
||||
@@ -88,7 +88,7 @@ public class FormHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canWrite() {
|
||||
void canWrite() {
|
||||
assertCanWrite(APPLICATION_FORM_URLENCODED);
|
||||
assertCanWrite(MULTIPART_FORM_DATA);
|
||||
assertCanWrite(MULTIPART_MIXED);
|
||||
@@ -99,7 +99,7 @@ public class FormHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setSupportedMediaTypes() {
|
||||
void setSupportedMediaTypes() {
|
||||
this.converter.setSupportedMediaTypes(List.of(MULTIPART_FORM_DATA));
|
||||
assertCannotWrite(MULTIPART_MIXED);
|
||||
|
||||
@@ -108,7 +108,7 @@ public class FormHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addSupportedMediaTypes() {
|
||||
void addSupportedMediaTypes() {
|
||||
this.converter.setSupportedMediaTypes(List.of(MULTIPART_FORM_DATA));
|
||||
assertCannotWrite(MULTIPART_MIXED);
|
||||
|
||||
@@ -117,7 +117,7 @@ public class FormHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readForm() 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(
|
||||
@@ -127,14 +127,12 @@ public class FormHttpMessageConverterTests {
|
||||
assertThat(result).as("Invalid result").hasSize(3);
|
||||
assertThat(result.getFirst("name 1")).as("Invalid result").isEqualTo("value 1");
|
||||
List<String> values = result.get("name 2");
|
||||
assertThat(values).as("Invalid result").hasSize(2);
|
||||
assertThat(values).element(0).as("Invalid result").isEqualTo("value 2+1");
|
||||
assertThat(values).element(1).as("Invalid result").isEqualTo("value 2+2");
|
||||
assertThat(values).as("Invalid result").containsExactly("value 2+1", "value 2+2");
|
||||
assertThat(result.getFirst("name 3")).as("Invalid result").isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeForm() throws IOException {
|
||||
void writeForm() throws IOException {
|
||||
MultiValueMap<String, String> body = new LinkedMultiValueMap<>();
|
||||
body.set("name 1", "value 1");
|
||||
body.add("name 2", "value 2+1");
|
||||
@@ -152,7 +150,7 @@ public class FormHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeMultipart() throws Exception {
|
||||
void writeMultipart() throws Exception {
|
||||
|
||||
MultiValueMap<String, Object> parts = new LinkedMultiValueMap<>();
|
||||
parts.add("name 1", "value 1");
|
||||
@@ -230,7 +228,7 @@ public class FormHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeMultipartWithSourceHttpMessageConverter() throws Exception {
|
||||
void writeMultipartWithSourceHttpMessageConverter() throws Exception {
|
||||
|
||||
converter.setPartConverters(List.of(
|
||||
new StringHttpMessageConverter(),
|
||||
@@ -356,7 +354,7 @@ public class FormHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeMultipartCharset() throws Exception {
|
||||
void writeMultipartCharset() throws Exception {
|
||||
MultiValueMap<String, Object> parts = new LinkedMultiValueMap<>();
|
||||
Resource logo = new ClassPathResource("/org/springframework/http/converter/logo.jpg");
|
||||
parts.add("logo", logo);
|
||||
@@ -436,7 +434,7 @@ public class FormHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream() throws IOException {
|
||||
public InputStream getInputStream() {
|
||||
return new ByteArrayInputStream(body);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.springframework.http.converter;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.HttpInputMessage;
|
||||
@@ -32,11 +30,11 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Arjen Poutsma
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class HttpMessageConverterTests {
|
||||
class HttpMessageConverterTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void canRead() {
|
||||
void canRead() {
|
||||
MediaType mediaType = new MediaType("foo", "bar");
|
||||
HttpMessageConverter<MyType> converter = new MyHttpMessageConverter<>(mediaType);
|
||||
|
||||
@@ -46,7 +44,7 @@ public class HttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canReadWithWildcardSubtype() {
|
||||
void canReadWithWildcardSubtype() {
|
||||
MediaType mediaType = new MediaType("foo");
|
||||
HttpMessageConverter<MyType> converter = new MyHttpMessageConverter<>(mediaType);
|
||||
|
||||
@@ -56,7 +54,7 @@ public class HttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canWrite() {
|
||||
void canWrite() {
|
||||
MediaType mediaType = new MediaType("foo", "bar");
|
||||
HttpMessageConverter<MyType> converter = new MyHttpMessageConverter<>(mediaType);
|
||||
|
||||
@@ -66,7 +64,7 @@ public class HttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canWriteWithWildcardInSupportedSubtype() {
|
||||
void canWriteWithWildcardInSupportedSubtype() {
|
||||
MediaType mediaType = new MediaType("foo");
|
||||
HttpMessageConverter<MyType> converter = new MyHttpMessageConverter<>(mediaType);
|
||||
|
||||
@@ -89,13 +87,13 @@ public class HttpMessageConverterTests {
|
||||
|
||||
@Override
|
||||
protected T readInternal(Class<? extends T> clazz, HttpInputMessage inputMessage)
|
||||
throws IOException, HttpMessageNotReadableException {
|
||||
throws HttpMessageNotReadableException {
|
||||
throw new AssertionError("Not expected");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeInternal(T t, HttpOutputMessage outputMessage)
|
||||
throws IOException, HttpMessageNotWritableException {
|
||||
throws HttpMessageNotWritableException {
|
||||
throw new AssertionError("Not expected");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -43,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
||||
* @author <a href="mailto:dmitry.katsubo@gmail.com">Dmitry Katsubo</a>
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class ObjectToStringHttpMessageConverterTests {
|
||||
class ObjectToStringHttpMessageConverterTests {
|
||||
|
||||
private ObjectToStringHttpMessageConverter converter;
|
||||
|
||||
@@ -53,7 +53,7 @@ public class ObjectToStringHttpMessageConverterTests {
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
void setup() {
|
||||
ConversionService conversionService = new DefaultConversionService();
|
||||
this.converter = new ObjectToStringHttpMessageConverter(conversionService);
|
||||
|
||||
@@ -63,7 +63,7 @@ public class ObjectToStringHttpMessageConverterTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void canRead() {
|
||||
void canRead() {
|
||||
assertThat(this.converter.canRead(Math.class, null)).isFalse();
|
||||
assertThat(this.converter.canRead(Resource.class, null)).isFalse();
|
||||
|
||||
@@ -76,7 +76,7 @@ public class ObjectToStringHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canWrite() {
|
||||
void canWrite() {
|
||||
assertThat(this.converter.canWrite(Math.class, null)).isFalse();
|
||||
assertThat(this.converter.canWrite(Resource.class, null)).isFalse();
|
||||
|
||||
@@ -91,14 +91,14 @@ public class ObjectToStringHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultCharset() throws IOException {
|
||||
void defaultCharset() throws IOException {
|
||||
this.converter.write(5, null, response);
|
||||
|
||||
assertThat(servletResponse.getCharacterEncoding()).isEqualTo("ISO-8859-1");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultCharsetModified() throws IOException {
|
||||
void defaultCharsetModified() throws IOException {
|
||||
ConversionService cs = new DefaultConversionService();
|
||||
ObjectToStringHttpMessageConverter converter = new ObjectToStringHttpMessageConverter(cs, StandardCharsets.UTF_16);
|
||||
converter.write((byte) 31, null, this.response);
|
||||
@@ -107,7 +107,7 @@ public class ObjectToStringHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeAcceptCharset() throws IOException {
|
||||
void writeAcceptCharset() throws IOException {
|
||||
this.converter.setWriteAcceptCharset(true);
|
||||
this.converter.write(new Date(), null, this.response);
|
||||
|
||||
@@ -115,7 +115,7 @@ public class ObjectToStringHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeAcceptCharsetTurnedOff() throws IOException {
|
||||
void writeAcceptCharsetTurnedOff() throws IOException {
|
||||
this.converter.setWriteAcceptCharset(false);
|
||||
this.converter.write(new Date(), null, this.response);
|
||||
|
||||
@@ -123,7 +123,7 @@ public class ObjectToStringHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void read() throws IOException {
|
||||
void read() throws IOException {
|
||||
Short shortValue = (short) 781;
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
request.setContentType(MediaType.TEXT_PLAIN_VALUE);
|
||||
@@ -134,19 +134,19 @@ public class ObjectToStringHttpMessageConverterTests {
|
||||
request = new MockHttpServletRequest();
|
||||
request.setContentType(MediaType.TEXT_PLAIN_VALUE);
|
||||
request.setCharacterEncoding("UTF-16");
|
||||
request.setContent(floatValue.toString().getBytes("UTF-16"));
|
||||
request.setContent(floatValue.toString().getBytes(StandardCharsets.UTF_16));
|
||||
assertThat(this.converter.read(Float.class, new ServletServerHttpRequest(request))).isEqualTo(floatValue);
|
||||
|
||||
Long longValue = 55819182821331L;
|
||||
request = new MockHttpServletRequest();
|
||||
request.setContentType(MediaType.TEXT_PLAIN_VALUE);
|
||||
request.setCharacterEncoding("UTF-8");
|
||||
request.setContent(longValue.toString().getBytes("UTF-8"));
|
||||
request.setContent(longValue.toString().getBytes(StandardCharsets.UTF_8));
|
||||
assertThat(this.converter.read(Long.class, new ServletServerHttpRequest(request))).isEqualTo(longValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void write() throws IOException {
|
||||
void write() throws IOException {
|
||||
this.converter.write((byte) -8, null, this.response);
|
||||
|
||||
assertThat(this.servletResponse.getCharacterEncoding()).isEqualTo("ISO-8859-1");
|
||||
@@ -156,7 +156,7 @@ public class ObjectToStringHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeUtf16() throws IOException {
|
||||
void writeUtf16() throws IOException {
|
||||
MediaType contentType = new MediaType("text", "plain", StandardCharsets.UTF_16);
|
||||
this.converter.write(958, contentType, this.response);
|
||||
|
||||
@@ -168,7 +168,7 @@ public class ObjectToStringHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConversionServiceRequired() {
|
||||
void testConversionServiceRequired() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
new ObjectToStringHttpMessageConverter(null));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -45,24 +45,24 @@ import static org.mockito.Mockito.mock;
|
||||
* @author Kazuki Shimizu
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
public class ResourceHttpMessageConverterTests {
|
||||
class ResourceHttpMessageConverterTests {
|
||||
|
||||
private final ResourceHttpMessageConverter converter = new ResourceHttpMessageConverter();
|
||||
|
||||
|
||||
@Test
|
||||
public void canReadResource() {
|
||||
void canReadResource() {
|
||||
assertThat(converter.canRead(Resource.class, new MediaType("application", "octet-stream"))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canWriteResource() {
|
||||
void canWriteResource() {
|
||||
assertThat(converter.canWrite(Resource.class, new MediaType("application", "octet-stream"))).isTrue();
|
||||
assertThat(converter.canWrite(Resource.class, MediaType.ALL)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReadImageResource() throws IOException {
|
||||
void shouldReadImageResource() throws IOException {
|
||||
byte[] body = FileCopyUtils.copyToByteArray(getClass().getResourceAsStream("logo.jpg"));
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body);
|
||||
inputMessage.getHeaders().setContentType(MediaType.IMAGE_JPEG);
|
||||
@@ -101,7 +101,7 @@ public class ResourceHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldWriteImageResource() throws IOException {
|
||||
void shouldWriteImageResource() throws IOException {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
Resource body = new ClassPathResource("logo.jpg", getClass());
|
||||
converter.write(body, null, outputMessage);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -44,12 +44,12 @@ import static org.mockito.Mockito.mock;
|
||||
*
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
public class ResourceRegionHttpMessageConverterTests {
|
||||
class ResourceRegionHttpMessageConverterTests {
|
||||
|
||||
private final ResourceRegionHttpMessageConverter converter = new ResourceRegionHttpMessageConverter();
|
||||
|
||||
@Test
|
||||
public void canReadResource() {
|
||||
void canReadResource() {
|
||||
assertThat(converter.canRead(Resource.class, MediaType.APPLICATION_OCTET_STREAM)).isFalse();
|
||||
assertThat(converter.canRead(Resource.class, MediaType.ALL)).isFalse();
|
||||
assertThat(converter.canRead(List.class, MediaType.APPLICATION_OCTET_STREAM)).isFalse();
|
||||
@@ -57,14 +57,14 @@ public class ResourceRegionHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canWriteResource() {
|
||||
void canWriteResource() {
|
||||
assertThat(converter.canWrite(ResourceRegion.class, null, MediaType.APPLICATION_OCTET_STREAM)).isTrue();
|
||||
assertThat(converter.canWrite(ResourceRegion.class, null, MediaType.ALL)).isTrue();
|
||||
assertThat(converter.canWrite(Object.class, null, MediaType.ALL)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canWriteResourceCollection() {
|
||||
void canWriteResourceCollection() {
|
||||
Type resourceRegionList = new ParameterizedTypeReference<List<ResourceRegion>>() {}.getType();
|
||||
assertThat(converter.canWrite(resourceRegionList, null, MediaType.APPLICATION_OCTET_STREAM)).isTrue();
|
||||
assertThat(converter.canWrite(resourceRegionList, null, MediaType.ALL)).isTrue();
|
||||
@@ -76,7 +76,7 @@ public class ResourceRegionHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldWritePartialContentByteRange() throws Exception {
|
||||
void shouldWritePartialContentByteRange() throws Exception {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
Resource body = new ClassPathResource("byterangeresource.txt", getClass());
|
||||
ResourceRegion region = HttpRange.createByteRange(0, 5).toResourceRegion(body);
|
||||
@@ -85,13 +85,12 @@ public class ResourceRegionHttpMessageConverterTests {
|
||||
HttpHeaders headers = outputMessage.getHeaders();
|
||||
assertThat(headers.getContentType()).isEqualTo(MediaType.TEXT_PLAIN);
|
||||
assertThat(headers.getContentLength()).isEqualTo(6L);
|
||||
assertThat(headers.get(HttpHeaders.CONTENT_RANGE)).hasSize(1);
|
||||
assertThat(headers.get(HttpHeaders.CONTENT_RANGE)).element(0).isEqualTo("bytes 0-5/39");
|
||||
assertThat(headers.get(HttpHeaders.CONTENT_RANGE)).containsExactly("bytes 0-5/39");
|
||||
assertThat(outputMessage.getBodyAsString(StandardCharsets.UTF_8)).isEqualTo("Spring");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldWritePartialContentByteRangeNoEnd() throws Exception {
|
||||
void shouldWritePartialContentByteRangeNoEnd() throws Exception {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
Resource body = new ClassPathResource("byterangeresource.txt", getClass());
|
||||
ResourceRegion region = HttpRange.createByteRange(7).toResourceRegion(body);
|
||||
@@ -100,13 +99,12 @@ public class ResourceRegionHttpMessageConverterTests {
|
||||
HttpHeaders headers = outputMessage.getHeaders();
|
||||
assertThat(headers.getContentType()).isEqualTo(MediaType.TEXT_PLAIN);
|
||||
assertThat(headers.getContentLength()).isEqualTo(32L);
|
||||
assertThat(headers.get(HttpHeaders.CONTENT_RANGE)).hasSize(1);
|
||||
assertThat(headers.get(HttpHeaders.CONTENT_RANGE)).element(0).isEqualTo("bytes 7-38/39");
|
||||
assertThat(headers.get(HttpHeaders.CONTENT_RANGE)).containsExactly("bytes 7-38/39");
|
||||
assertThat(outputMessage.getBodyAsString(StandardCharsets.UTF_8)).isEqualTo("Framework test resource content.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void partialContentMultipleByteRanges() throws Exception {
|
||||
void partialContentMultipleByteRanges() throws Exception {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
Resource body = new ClassPathResource("byterangeresource.txt", getClass());
|
||||
List<HttpRange> rangeList = HttpRange.parseRanges("bytes=0-5,7-15,17-20,22-38");
|
||||
@@ -145,7 +143,7 @@ public class ResourceRegionHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void partialContentMultipleByteRangesInRandomOrderAndOverlapping() throws Exception {
|
||||
void partialContentMultipleByteRangesInRandomOrderAndOverlapping() throws Exception {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
Resource body = new ClassPathResource("byterangeresource.txt", getClass());
|
||||
List<HttpRange> rangeList = HttpRange.parseRanges("bytes=7-15,0-5,17-20,20-29");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -172,7 +172,7 @@ class StringHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void repeatableWrites() throws IOException {
|
||||
void repeatableWrites() throws IOException {
|
||||
MockHttpOutputMessage outputMessage1 = new MockHttpOutputMessage();
|
||||
String body = "Hello World";
|
||||
assertThat(converter.supportsRepeatableWrites(body)).isTrue();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -42,7 +42,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class AtomFeedHttpMessageConverterTests {
|
||||
class AtomFeedHttpMessageConverterTests {
|
||||
|
||||
private static final MediaType ATOM_XML_UTF8 =
|
||||
new MediaType(MediaType.APPLICATION_ATOM_XML, StandardCharsets.UTF_8);
|
||||
@@ -52,25 +52,25 @@ public class AtomFeedHttpMessageConverterTests {
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
void setUp() {
|
||||
converter = new AtomFeedHttpMessageConverter();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void canRead() {
|
||||
void canRead() {
|
||||
assertThat(converter.canRead(Feed.class, MediaType.APPLICATION_ATOM_XML)).isTrue();
|
||||
assertThat(converter.canRead(Feed.class, ATOM_XML_UTF8)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canWrite() {
|
||||
void canWrite() {
|
||||
assertThat(converter.canWrite(Feed.class, MediaType.APPLICATION_ATOM_XML)).isTrue();
|
||||
assertThat(converter.canWrite(Feed.class, ATOM_XML_UTF8)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void read() throws IOException {
|
||||
void read() throws IOException {
|
||||
InputStream inputStream = getClass().getResourceAsStream("atom.xml");
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(inputStream);
|
||||
inputMessage.getHeaders().setContentType(ATOM_XML_UTF8);
|
||||
@@ -90,7 +90,7 @@ public class AtomFeedHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void write() throws IOException {
|
||||
void write() throws IOException {
|
||||
Feed feed = new Feed("atom_1.0");
|
||||
feed.setTitle("title");
|
||||
|
||||
@@ -122,7 +122,7 @@ public class AtomFeedHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeOtherCharset() throws IOException {
|
||||
void writeOtherCharset() throws IOException {
|
||||
Feed feed = new Feed("atom_1.0");
|
||||
feed.setTitle("title");
|
||||
String encoding = "ISO-8859-1";
|
||||
@@ -137,7 +137,7 @@ public class AtomFeedHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeOtherContentTypeParameters() throws IOException {
|
||||
void writeOtherContentTypeParameters() throws IOException {
|
||||
MockHttpOutputMessage message = new MockHttpOutputMessage();
|
||||
MediaType contentType = new MediaType("application", "atom+xml", singletonMap("type", "feed"));
|
||||
converter.write(new Feed("atom_1.0"), contentType, message);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class RssChannelHttpMessageConverterTests {
|
||||
class RssChannelHttpMessageConverterTests {
|
||||
|
||||
private static final MediaType RSS_XML_UTF8 = new MediaType(MediaType.APPLICATION_RSS_XML, StandardCharsets.UTF_8);
|
||||
|
||||
@@ -46,7 +46,7 @@ public class RssChannelHttpMessageConverterTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void canReadAndWrite() {
|
||||
void canReadAndWrite() {
|
||||
assertThat(converter.canRead(Channel.class, MediaType.APPLICATION_RSS_XML)).isTrue();
|
||||
assertThat(converter.canRead(Channel.class, RSS_XML_UTF8)).isTrue();
|
||||
|
||||
@@ -55,7 +55,7 @@ public class RssChannelHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void read() throws IOException {
|
||||
void read() throws IOException {
|
||||
InputStream inputStream = getClass().getResourceAsStream("rss.xml");
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(inputStream);
|
||||
inputMessage.getHeaders().setContentType(RSS_XML_UTF8);
|
||||
@@ -75,7 +75,7 @@ public class RssChannelHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void write() throws IOException {
|
||||
void write() throws IOException {
|
||||
Channel channel = new Channel("rss_2.0");
|
||||
channel.setTitle("title");
|
||||
channel.setLink("https://example.com");
|
||||
@@ -108,7 +108,7 @@ public class RssChannelHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeOtherCharset() throws IOException {
|
||||
void writeOtherCharset() throws IOException {
|
||||
Channel channel = new Channel("rss_2.0");
|
||||
channel.setTitle("title");
|
||||
channel.setLink("https://example.com");
|
||||
@@ -129,7 +129,7 @@ public class RssChannelHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeOtherContentTypeParameters() throws IOException {
|
||||
void writeOtherContentTypeParameters() throws IOException {
|
||||
Channel channel = new Channel("rss_2.0");
|
||||
channel.setTitle("title");
|
||||
channel.setLink("https://example.com");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -37,7 +37,7 @@ class GsonFactoryBeanTests {
|
||||
|
||||
|
||||
@Test
|
||||
void serializeNulls() throws Exception {
|
||||
void serializeNulls() {
|
||||
this.factory.setSerializeNulls(true);
|
||||
this.factory.afterPropertiesSet();
|
||||
Gson gson = this.factory.getObject();
|
||||
@@ -47,7 +47,7 @@ class GsonFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void serializeNullsFalse() throws Exception {
|
||||
void serializeNullsFalse() {
|
||||
this.factory.setSerializeNulls(false);
|
||||
this.factory.afterPropertiesSet();
|
||||
Gson gson = this.factory.getObject();
|
||||
@@ -57,7 +57,7 @@ class GsonFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void prettyPrinting() throws Exception {
|
||||
void prettyPrinting() {
|
||||
this.factory.setPrettyPrinting(true);
|
||||
this.factory.afterPropertiesSet();
|
||||
Gson gson = this.factory.getObject();
|
||||
@@ -67,7 +67,7 @@ class GsonFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void prettyPrintingFalse() throws Exception {
|
||||
void prettyPrintingFalse() {
|
||||
this.factory.setPrettyPrinting(false);
|
||||
this.factory.afterPropertiesSet();
|
||||
Gson gson = this.factory.getObject();
|
||||
@@ -78,7 +78,7 @@ class GsonFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void disableHtmlEscaping() throws Exception {
|
||||
void disableHtmlEscaping() {
|
||||
this.factory.setDisableHtmlEscaping(true);
|
||||
this.factory.afterPropertiesSet();
|
||||
Gson gson = this.factory.getObject();
|
||||
@@ -89,7 +89,7 @@ class GsonFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void disableHtmlEscapingFalse() throws Exception {
|
||||
void disableHtmlEscapingFalse() {
|
||||
this.factory.setDisableHtmlEscaping(false);
|
||||
this.factory.afterPropertiesSet();
|
||||
Gson gson = this.factory.getObject();
|
||||
@@ -100,7 +100,7 @@ class GsonFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void customizeDateFormatPattern() throws Exception {
|
||||
void customizeDateFormatPattern() {
|
||||
this.factory.setDateFormatPattern(DATE_FORMAT);
|
||||
this.factory.afterPropertiesSet();
|
||||
Gson gson = this.factory.getObject();
|
||||
@@ -117,7 +117,7 @@ class GsonFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void customizeDateFormatNone() throws Exception {
|
||||
void customizeDateFormatNone() {
|
||||
this.factory.afterPropertiesSet();
|
||||
Gson gson = this.factory.getObject();
|
||||
DateBean bean = new DateBean();
|
||||
@@ -134,7 +134,7 @@ class GsonFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void base64EncodeByteArrays() throws Exception {
|
||||
void base64EncodeByteArrays() {
|
||||
this.factory.setBase64EncodeByteArrays(true);
|
||||
this.factory.afterPropertiesSet();
|
||||
Gson gson = this.factory.getObject();
|
||||
@@ -145,7 +145,7 @@ class GsonFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void base64EncodeByteArraysDisableHtmlEscaping() throws Exception {
|
||||
void base64EncodeByteArraysDisableHtmlEscaping() {
|
||||
this.factory.setBase64EncodeByteArrays(true);
|
||||
this.factory.setDisableHtmlEscaping(true);
|
||||
this.factory.afterPropertiesSet();
|
||||
@@ -157,7 +157,7 @@ class GsonFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void base64EncodeByteArraysFalse() throws Exception {
|
||||
void base64EncodeByteArraysFalse() {
|
||||
this.factory.setBase64EncodeByteArrays(false);
|
||||
this.factory.afterPropertiesSet();
|
||||
Gson gson = this.factory.getObject();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -45,31 +45,31 @@ import static org.assertj.core.api.Assertions.within;
|
||||
* @author Roy Clarkson
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class GsonHttpMessageConverterTests {
|
||||
class GsonHttpMessageConverterTests {
|
||||
|
||||
private final GsonHttpMessageConverter converter = new GsonHttpMessageConverter();
|
||||
|
||||
|
||||
@Test
|
||||
public void canRead() {
|
||||
void canRead() {
|
||||
assertThat(this.converter.canRead(MyBean.class, new MediaType("application", "json"))).isTrue();
|
||||
assertThat(this.converter.canRead(Map.class, new MediaType("application", "json"))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canWrite() {
|
||||
void canWrite() {
|
||||
assertThat(this.converter.canWrite(MyBean.class, new MediaType("application", "json"))).isTrue();
|
||||
assertThat(this.converter.canWrite(Map.class, new MediaType("application", "json"))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canReadAndWriteMicroformats() {
|
||||
void canReadAndWriteMicroformats() {
|
||||
assertThat(this.converter.canRead(MyBean.class, new MediaType("application", "vnd.test-micro-type+json"))).isTrue();
|
||||
assertThat(this.converter.canWrite(MyBean.class, new MediaType("application", "vnd.test-micro-type+json"))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readTyped() throws IOException {
|
||||
void readTyped() throws IOException {
|
||||
String body = "{\"bytes\":[1,2],\"array\":[\"Foo\",\"Bar\"]," +
|
||||
"\"number\":42,\"string\":\"Foo\",\"bool\":true,\"fraction\":42.0}";
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes(StandardCharsets.UTF_8));
|
||||
@@ -90,7 +90,7 @@ public class GsonHttpMessageConverterTests {
|
||||
public void readUntyped() throws IOException {
|
||||
String body = "{\"bytes\":[1,2],\"array\":[\"Foo\",\"Bar\"]," +
|
||||
"\"number\":42,\"string\":\"Foo\",\"bool\":true,\"fraction\":42.0}";
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes("UTF-8"));
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes(StandardCharsets.UTF_8));
|
||||
inputMessage.getHeaders().setContentType(new MediaType("application", "json"));
|
||||
HashMap<String, Object> result = (HashMap<String, Object>) this.converter.read(HashMap.class, inputMessage);
|
||||
assertThat(result.get("string")).isEqualTo("Foo");
|
||||
@@ -113,7 +113,7 @@ public class GsonHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void write() throws IOException {
|
||||
void write() throws IOException {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
MyBean body = new MyBean();
|
||||
body.setString("Foo");
|
||||
@@ -136,7 +136,7 @@ public class GsonHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeWithBaseType() throws IOException {
|
||||
void writeWithBaseType() throws IOException {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
MyBean body = new MyBean();
|
||||
body.setString("Foo");
|
||||
@@ -159,7 +159,7 @@ public class GsonHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeUTF16() throws IOException {
|
||||
void writeUTF16() throws IOException {
|
||||
MediaType contentType = new MediaType("application", "json", StandardCharsets.UTF_16BE);
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
String body = "H\u00e9llo W\u00f6rld";
|
||||
@@ -169,7 +169,7 @@ public class GsonHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readInvalidJson() throws IOException {
|
||||
void readInvalidJson() {
|
||||
String body = "FooBar";
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes(StandardCharsets.UTF_8));
|
||||
inputMessage.getHeaders().setContentType(new MediaType("application", "json"));
|
||||
@@ -259,7 +259,7 @@ public class GsonHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void prefixJson() throws IOException {
|
||||
void prefixJson() throws IOException {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
this.converter.setPrefixJson(true);
|
||||
this.converter.writeInternal("foo", null, outputMessage);
|
||||
@@ -267,7 +267,7 @@ public class GsonHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void prefixJsonCustom() throws IOException {
|
||||
void prefixJsonCustom() throws IOException {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
this.converter.setJsonPrefix(")))");
|
||||
this.converter.writeInternal("foo", null, outputMessage);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.springframework.http.converter.json;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -278,21 +278,25 @@ class Jackson2ObjectMapperBuilderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void wellKnownModules() throws JsonProcessingException, UnsupportedEncodingException {
|
||||
void wellKnownModules() throws JsonProcessingException {
|
||||
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().build();
|
||||
|
||||
Path file = Paths.get("foo");
|
||||
assertThat(new String(objectMapper.writeValueAsBytes(file), "UTF-8")).endsWith("foo\"");
|
||||
assertThat(new String(objectMapper.writeValueAsBytes(file), StandardCharsets.UTF_8))
|
||||
.endsWith("foo\"");
|
||||
|
||||
Optional<String> optional = Optional.of("test");
|
||||
assertThat(new String(objectMapper.writeValueAsBytes(optional), "UTF-8")).isEqualTo("\"test\"");
|
||||
assertThat(new String(objectMapper.writeValueAsBytes(optional), StandardCharsets.UTF_8))
|
||||
.isEqualTo("\"test\"");
|
||||
|
||||
|
||||
assertThatCode(() -> objectMapper.readValue("{\"x\":1,\"y\":2}", ParameterModuleDto.class)).doesNotThrowAnyException();
|
||||
assertThatCode(() -> objectMapper.readValue("{\"x\":1,\"y\":2}", ParameterModuleDto.class))
|
||||
.doesNotThrowAnyException();
|
||||
|
||||
// Kotlin module
|
||||
IntRange range = new IntRange(1, 3);
|
||||
assertThat(new String(objectMapper.writeValueAsBytes(range), "UTF-8")).isEqualTo("{\"start\":1,\"end\":3}");
|
||||
assertThat(new String(objectMapper.writeValueAsBytes(range), StandardCharsets.UTF_8))
|
||||
.isEqualTo("{\"start\":1,\"end\":3}");
|
||||
}
|
||||
|
||||
@Test // gh-22576
|
||||
@@ -744,7 +748,7 @@ class Jackson2ObjectMapperBuilderTests {
|
||||
|
||||
static class FooSerializer extends JsonSerializer<Foo> {
|
||||
@Override
|
||||
public void serialize(Foo value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
||||
public void serialize(Foo value, JsonGenerator gen, SerializerProvider serializers) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -755,7 +759,7 @@ class Jackson2ObjectMapperBuilderTests {
|
||||
|
||||
static class BarSerializer extends JsonSerializer<Bar> {
|
||||
@Override
|
||||
public void serialize(Bar value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
||||
public void serialize(Bar value, JsonGenerator gen, SerializerProvider serializers) {
|
||||
}
|
||||
@Override
|
||||
public Class<Bar> handledType() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -83,13 +83,13 @@ public class Jackson2ObjectMapperFactoryBeanTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void unknownFeature() {
|
||||
void unknownFeature() {
|
||||
this.factory.setFeaturesToEnable(Boolean.TRUE);
|
||||
assertThatIllegalArgumentException().isThrownBy(this.factory::afterPropertiesSet);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void booleanSetters() {
|
||||
void booleanSetters() {
|
||||
this.factory.setAutoDetectFields(false);
|
||||
this.factory.setAutoDetectGettersSetters(false);
|
||||
this.factory.setDefaultViewInclusion(false);
|
||||
@@ -110,34 +110,34 @@ public class Jackson2ObjectMapperFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultSerializationInclusion() {
|
||||
void defaultSerializationInclusion() {
|
||||
this.factory.afterPropertiesSet();
|
||||
assertThat(this.factory.getObject().getSerializationConfig().getSerializationInclusion()).isSameAs(Include.ALWAYS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nonNullSerializationInclusion() {
|
||||
void nonNullSerializationInclusion() {
|
||||
this.factory.setSerializationInclusion(Include.NON_NULL);
|
||||
this.factory.afterPropertiesSet();
|
||||
assertThat(this.factory.getObject().getSerializationConfig().getSerializationInclusion()).isSameAs(Include.NON_NULL);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nonDefaultSerializationInclusion() {
|
||||
void nonDefaultSerializationInclusion() {
|
||||
this.factory.setSerializationInclusion(Include.NON_DEFAULT);
|
||||
this.factory.afterPropertiesSet();
|
||||
assertThat(this.factory.getObject().getSerializationConfig().getSerializationInclusion()).isSameAs(Include.NON_DEFAULT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nonEmptySerializationInclusion() {
|
||||
void nonEmptySerializationInclusion() {
|
||||
this.factory.setSerializationInclusion(Include.NON_EMPTY);
|
||||
this.factory.afterPropertiesSet();
|
||||
assertThat(this.factory.getObject().getSerializationConfig().getSerializationInclusion()).isSameAs(Include.NON_EMPTY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setDateFormat() {
|
||||
void setDateFormat() {
|
||||
this.factory.setDateFormat(this.dateFormat);
|
||||
this.factory.afterPropertiesSet();
|
||||
|
||||
@@ -146,7 +146,7 @@ public class Jackson2ObjectMapperFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setSimpleDateFormat() {
|
||||
void setSimpleDateFormat() {
|
||||
this.factory.setSimpleDateFormat(DATE_FORMAT);
|
||||
this.factory.afterPropertiesSet();
|
||||
|
||||
@@ -155,7 +155,7 @@ public class Jackson2ObjectMapperFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setLocale() {
|
||||
void setLocale() {
|
||||
this.factory.setLocale(Locale.FRENCH);
|
||||
this.factory.afterPropertiesSet();
|
||||
|
||||
@@ -164,7 +164,7 @@ public class Jackson2ObjectMapperFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setTimeZone() {
|
||||
void setTimeZone() {
|
||||
TimeZone timeZone = TimeZone.getTimeZone("Europe/Paris");
|
||||
|
||||
this.factory.setTimeZone(timeZone);
|
||||
@@ -175,7 +175,7 @@ public class Jackson2ObjectMapperFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setTimeZoneWithInvalidZoneId() {
|
||||
void setTimeZoneWithInvalidZoneId() {
|
||||
this.factory.setTimeZone(TimeZone.getTimeZone("bogusZoneId"));
|
||||
this.factory.afterPropertiesSet();
|
||||
|
||||
@@ -185,7 +185,7 @@ public class Jackson2ObjectMapperFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setModules() {
|
||||
void setModules() {
|
||||
NumberSerializer serializer = new NumberSerializer(Integer.class);
|
||||
SimpleModule module = new SimpleModule();
|
||||
module.addSerializer(Integer.class, serializer);
|
||||
@@ -199,7 +199,7 @@ public class Jackson2ObjectMapperFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleSetup() {
|
||||
void simpleSetup() {
|
||||
this.factory.afterPropertiesSet();
|
||||
|
||||
assertThat(this.factory.getObject()).isNotNull();
|
||||
@@ -208,7 +208,7 @@ public class Jackson2ObjectMapperFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void undefinedObjectType() {
|
||||
void undefinedObjectType() {
|
||||
assertThat(this.factory.getObjectType()).isNull();
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ public class Jackson2ObjectMapperFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void propertyNamingStrategy() {
|
||||
void propertyNamingStrategy() {
|
||||
PropertyNamingStrategy strategy = new PropertyNamingStrategy.SnakeCaseStrategy();
|
||||
this.factory.setPropertyNamingStrategy(strategy);
|
||||
this.factory.afterPropertiesSet();
|
||||
@@ -231,7 +231,7 @@ public class Jackson2ObjectMapperFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setMixIns() {
|
||||
void setMixIns() {
|
||||
Class<?> target = String.class;
|
||||
Class<?> mixinSource = Object.class;
|
||||
Map<Class<?>, Class<?>> mixIns = new HashMap<>();
|
||||
@@ -248,7 +248,7 @@ public class Jackson2ObjectMapperFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setFilters() throws JsonProcessingException {
|
||||
void setFilters() throws JsonProcessingException {
|
||||
this.factory.setFilters(new SimpleFilterProvider().setFailOnUnknownId(false));
|
||||
this.factory.afterPropertiesSet();
|
||||
ObjectMapper objectMapper = this.factory.getObject();
|
||||
@@ -260,7 +260,7 @@ public class Jackson2ObjectMapperFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void completeSetup() {
|
||||
void completeSetup() {
|
||||
NopAnnotationIntrospector annotationIntrospector = NopAnnotationIntrospector.instance;
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
@@ -324,7 +324,7 @@ public class Jackson2ObjectMapperFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setObjectMapper() {
|
||||
void setObjectMapper() {
|
||||
this.factory.setObjectMapper(new XmlMapper());
|
||||
this.factory.afterPropertiesSet();
|
||||
|
||||
@@ -334,7 +334,7 @@ public class Jackson2ObjectMapperFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setCreateXmlMapper() {
|
||||
void setCreateXmlMapper() {
|
||||
this.factory.setCreateXmlMapper(true);
|
||||
this.factory.afterPropertiesSet();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -45,31 +45,31 @@ import static org.assertj.core.api.Assertions.within;
|
||||
* @author Juergen Hoeller
|
||||
* @since 5.0
|
||||
*/
|
||||
public class JsonbHttpMessageConverterTests {
|
||||
class JsonbHttpMessageConverterTests {
|
||||
|
||||
private final JsonbHttpMessageConverter converter = new JsonbHttpMessageConverter();
|
||||
|
||||
|
||||
@Test
|
||||
public void canRead() {
|
||||
void canRead() {
|
||||
assertThat(this.converter.canRead(MyBean.class, new MediaType("application", "json"))).isTrue();
|
||||
assertThat(this.converter.canRead(Map.class, new MediaType("application", "json"))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canWrite() {
|
||||
void canWrite() {
|
||||
assertThat(this.converter.canWrite(MyBean.class, new MediaType("application", "json"))).isTrue();
|
||||
assertThat(this.converter.canWrite(Map.class, new MediaType("application", "json"))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canReadAndWriteMicroformats() {
|
||||
void canReadAndWriteMicroformats() {
|
||||
assertThat(this.converter.canRead(MyBean.class, new MediaType("application", "vnd.test-micro-type+json"))).isTrue();
|
||||
assertThat(this.converter.canWrite(MyBean.class, new MediaType("application", "vnd.test-micro-type+json"))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readTyped() throws IOException {
|
||||
void readTyped() throws IOException {
|
||||
String body = "{\"bytes\":[1,2],\"array\":[\"Foo\",\"Bar\"]," +
|
||||
"\"number\":42,\"string\":\"Foo\",\"bool\":true,\"fraction\":42.0}";
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes(StandardCharsets.UTF_8));
|
||||
@@ -113,7 +113,7 @@ public class JsonbHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void write() throws IOException {
|
||||
void write() throws IOException {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
MyBean body = new MyBean();
|
||||
body.setString("Foo");
|
||||
@@ -136,7 +136,7 @@ public class JsonbHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeWithBaseType() throws IOException {
|
||||
void writeWithBaseType() throws IOException {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
MyBean body = new MyBean();
|
||||
body.setString("Foo");
|
||||
@@ -159,7 +159,7 @@ public class JsonbHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeUTF16() throws IOException {
|
||||
void writeUTF16() throws IOException {
|
||||
MediaType contentType = new MediaType("application", "json", StandardCharsets.UTF_16BE);
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
String body = "H\u00e9llo W\u00f6rld";
|
||||
@@ -169,7 +169,7 @@ public class JsonbHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readInvalidJson() {
|
||||
void readInvalidJson() {
|
||||
String body = "FooBar";
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes(StandardCharsets.UTF_8));
|
||||
inputMessage.getHeaders().setContentType(new MediaType("application", "json"));
|
||||
@@ -258,7 +258,7 @@ public class JsonbHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void prefixJson() throws IOException {
|
||||
void prefixJson() throws IOException {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
this.converter.setPrefixJson(true);
|
||||
this.converter.writeInternal("foo", null, outputMessage);
|
||||
@@ -266,7 +266,7 @@ public class JsonbHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void prefixJsonCustom() throws IOException {
|
||||
void prefixJsonCustom() throws IOException {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
this.converter.setJsonPrefix(")))");
|
||||
this.converter.writeInternal("foo", null, outputMessage);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -61,7 +61,7 @@ import static org.assertj.core.api.Assertions.within;
|
||||
* @author Sebastien Deleuze
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class MappingJackson2HttpMessageConverterTests {
|
||||
class MappingJackson2HttpMessageConverterTests {
|
||||
|
||||
protected static final String NEWLINE_SYSTEM_PROPERTY = System.lineSeparator();
|
||||
|
||||
@@ -69,7 +69,7 @@ public class MappingJackson2HttpMessageConverterTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void canRead() {
|
||||
void canRead() {
|
||||
assertThat(converter.canRead(MyBean.class, new MediaType("application", "json"))).isTrue();
|
||||
assertThat(converter.canRead(Map.class, new MediaType("application", "json"))).isTrue();
|
||||
assertThat(converter.canRead(MyBean.class, new MediaType("application", "json", StandardCharsets.UTF_8))).isTrue();
|
||||
@@ -78,7 +78,7 @@ public class MappingJackson2HttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canReadWithObjectMapperRegistrationForType() {
|
||||
void canReadWithObjectMapperRegistrationForType() {
|
||||
MediaType halJsonMediaType = MediaType.parseMediaType("application/hal+json");
|
||||
MediaType halFormsJsonMediaType = MediaType.parseMediaType("application/prs.hal-forms+json");
|
||||
|
||||
@@ -99,7 +99,7 @@ public class MappingJackson2HttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canWrite() {
|
||||
void canWrite() {
|
||||
assertThat(converter.canWrite(MyBean.class, new MediaType("application", "json"))).isTrue();
|
||||
assertThat(converter.canWrite(Map.class, new MediaType("application", "json"))).isTrue();
|
||||
assertThat(converter.canWrite(MyBean.class, new MediaType("application", "json", StandardCharsets.UTF_8))).isTrue();
|
||||
@@ -114,7 +114,7 @@ public class MappingJackson2HttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSupportedMediaTypes() {
|
||||
void getSupportedMediaTypes() {
|
||||
MediaType[] defaultMediaTypes = {MediaType.APPLICATION_JSON, MediaType.parseMediaType("application/*+json")};
|
||||
assertThat(converter.getSupportedMediaTypes()).containsExactly(defaultMediaTypes);
|
||||
assertThat(converter.getSupportedMediaTypes(MyBean.class)).containsExactly(defaultMediaTypes);
|
||||
@@ -130,7 +130,7 @@ public class MappingJackson2HttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readTyped() throws IOException {
|
||||
void readTyped() throws IOException {
|
||||
String body = "{" +
|
||||
"\"bytes\":\"AQI=\"," +
|
||||
"\"array\":[\"Foo\",\"Bar\"]," +
|
||||
@@ -174,7 +174,7 @@ public class MappingJackson2HttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void write() throws IOException {
|
||||
void write() throws IOException {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
MyBean body = new MyBean();
|
||||
body.setString("Foo");
|
||||
@@ -196,7 +196,7 @@ public class MappingJackson2HttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeWithBaseType() throws IOException {
|
||||
void writeWithBaseType() throws IOException {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
MyBean body = new MyBean();
|
||||
body.setString("Foo");
|
||||
@@ -218,7 +218,7 @@ public class MappingJackson2HttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeUTF16() throws IOException {
|
||||
void writeUTF16() throws IOException {
|
||||
MediaType contentType = new MediaType("application", "json", StandardCharsets.UTF_16BE);
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
String body = "H\u00e9llo W\u00f6rld";
|
||||
@@ -228,7 +228,7 @@ public class MappingJackson2HttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readInvalidJson() throws IOException {
|
||||
void readInvalidJson() {
|
||||
String body = "FooBar";
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes(StandardCharsets.UTF_8));
|
||||
inputMessage.getHeaders().setContentType(new MediaType("application", "json"));
|
||||
@@ -237,7 +237,7 @@ public class MappingJackson2HttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readValidJsonWithUnknownProperty() throws IOException {
|
||||
void readValidJsonWithUnknownProperty() throws IOException {
|
||||
String body = "{\"string\":\"string\",\"unknownProperty\":\"value\"}";
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes(StandardCharsets.UTF_8));
|
||||
inputMessage.getHeaders().setContentType(new MediaType("application", "json"));
|
||||
@@ -349,7 +349,7 @@ public class MappingJackson2HttpMessageConverterTests {
|
||||
|
||||
// gh-24498
|
||||
@Test
|
||||
public void writeOptional() throws IOException {
|
||||
void writeOptional() throws IOException {
|
||||
ParameterizedTypeReference<Optional<MyParent>> optionalParent = new ParameterizedTypeReference<>() {};
|
||||
Optional<MyParent> result = Optional.of(new Impl1());
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
@@ -360,7 +360,7 @@ public class MappingJackson2HttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void prettyPrint() throws Exception {
|
||||
void prettyPrint() throws Exception {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
PrettyPrintBean bean = new PrettyPrintBean();
|
||||
bean.setName("Jason");
|
||||
@@ -374,7 +374,7 @@ public class MappingJackson2HttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void prettyPrintWithSse() throws Exception {
|
||||
void prettyPrintWithSse() throws Exception {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
outputMessage.getHeaders().setContentType(MediaType.TEXT_EVENT_STREAM);
|
||||
PrettyPrintBean bean = new PrettyPrintBean();
|
||||
@@ -388,7 +388,7 @@ public class MappingJackson2HttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void prefixJson() throws Exception {
|
||||
void prefixJson() throws Exception {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
this.converter.setPrefixJson(true);
|
||||
this.converter.writeInternal("foo", null, outputMessage);
|
||||
@@ -397,7 +397,7 @@ public class MappingJackson2HttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void prefixJsonCustom() throws Exception {
|
||||
void prefixJsonCustom() throws Exception {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
this.converter.setJsonPrefix(")))");
|
||||
this.converter.writeInternal("foo", null, outputMessage);
|
||||
@@ -406,7 +406,7 @@ public class MappingJackson2HttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fieldLevelJsonView() throws Exception {
|
||||
void fieldLevelJsonView() throws Exception {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
JacksonViewBean bean = new JacksonViewBean();
|
||||
bean.setWithView1("with");
|
||||
@@ -424,7 +424,7 @@ public class MappingJackson2HttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void classLevelJsonView() throws Exception {
|
||||
void classLevelJsonView() throws Exception {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
JacksonViewBean bean = new JacksonViewBean();
|
||||
bean.setWithView1("with");
|
||||
@@ -442,7 +442,7 @@ public class MappingJackson2HttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filters() throws Exception {
|
||||
void filters() throws Exception {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
JacksonFilteredBean bean = new JacksonFilteredBean();
|
||||
bean.setProperty1("value");
|
||||
@@ -533,7 +533,6 @@ public class MappingJackson2HttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void writeAscii() throws Exception {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
Map<String,Object> body = new HashMap<>();
|
||||
@@ -548,7 +547,7 @@ public class MappingJackson2HttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readWithCustomized() throws IOException {
|
||||
void readWithCustomized() throws IOException {
|
||||
MappingJackson2HttpMessageConverterWithCustomization customizedConverter =
|
||||
new MappingJackson2HttpMessageConverterWithCustomization();
|
||||
String body = "{\"property\":\"Value1\"}";
|
||||
@@ -565,7 +564,7 @@ public class MappingJackson2HttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeWithCustomized() throws IOException {
|
||||
void writeWithCustomized() throws IOException {
|
||||
MappingJackson2HttpMessageConverterWithCustomization customizedConverter =
|
||||
new MappingJackson2HttpMessageConverterWithCustomization();
|
||||
MockHttpOutputMessage outputMessage1 = new MockHttpOutputMessage();
|
||||
@@ -581,7 +580,7 @@ public class MappingJackson2HttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void repeatableWrites() throws IOException {
|
||||
void repeatableWrites() throws IOException {
|
||||
MockHttpOutputMessage outputMessage1 = new MockHttpOutputMessage();
|
||||
MyBean body = new MyBean();
|
||||
body.setString("Foo");
|
||||
@@ -807,7 +806,7 @@ public class MappingJackson2HttpMessageConverterTests {
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME)
|
||||
@JsonSubTypes(value = {@JsonSubTypes.Type(value = Impl1.class),
|
||||
@JsonSubTypes.Type(value = Impl2.class)})
|
||||
public static interface MyParent {
|
||||
public interface MyParent {
|
||||
}
|
||||
|
||||
public static class Impl1 implements MyParent {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -61,7 +61,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
public class SpringHandlerInstantiatorTests {
|
||||
class SpringHandlerInstantiatorTests {
|
||||
|
||||
private SpringHandlerInstantiator instantiator;
|
||||
|
||||
@@ -69,7 +69,7 @@ public class SpringHandlerInstantiatorTests {
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
void setup() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
|
||||
bpp.setBeanFactory(bf);
|
||||
@@ -81,21 +81,21 @@ public class SpringHandlerInstantiatorTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void autowiredSerializer() throws JsonProcessingException {
|
||||
void autowiredSerializer() throws JsonProcessingException {
|
||||
User user = new User("bob");
|
||||
String json = this.objectMapper.writeValueAsString(user);
|
||||
assertThat(json).isEqualTo("{\"username\":\"BOB\"}");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void autowiredDeserializer() throws IOException {
|
||||
void autowiredDeserializer() throws IOException {
|
||||
String json = "{\"username\":\"bob\"}";
|
||||
User user = this.objectMapper.readValue(json, User.class);
|
||||
assertThat(user.getUsername()).isEqualTo("BOB");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void autowiredKeyDeserializer() throws IOException {
|
||||
void autowiredKeyDeserializer() throws IOException {
|
||||
String json = "{\"credentials\":{\"bob\":\"admin\"}}";
|
||||
SecurityRegistry registry = this.objectMapper.readValue(json, SecurityRegistry.class);
|
||||
assertThat(registry.getCredentials()).containsKey("BOB");
|
||||
@@ -103,13 +103,13 @@ public class SpringHandlerInstantiatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void applicationContextAwaretypeResolverBuilder() throws JsonProcessingException {
|
||||
void applicationContextAwaretypeResolverBuilder() throws JsonProcessingException {
|
||||
this.objectMapper.writeValueAsString(new Group());
|
||||
assertThat(CustomTypeResolverBuilder.isAutowiredFiledInitialized).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void applicationContextAwareTypeIdResolver() throws JsonProcessingException {
|
||||
void applicationContextAwareTypeIdResolver() throws JsonProcessingException {
|
||||
this.objectMapper.writeValueAsString(new Group());
|
||||
assertThat(CustomTypeIdResolver.isAutowiredFiledInitialized).isTrue();
|
||||
}
|
||||
@@ -151,7 +151,7 @@ public class SpringHandlerInstantiatorTests {
|
||||
private Capitalizer capitalizer;
|
||||
|
||||
@Override
|
||||
public Object deserializeKey(String key, DeserializationContext context) throws IOException {
|
||||
public Object deserializeKey(String key, DeserializationContext context) {
|
||||
return this.capitalizer.capitalize(key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -126,7 +126,7 @@ class ProtobufHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void defaultContentType() throws Exception {
|
||||
void defaultContentType() {
|
||||
assertThat(this.converter.getDefaultContentType(this.testMsg))
|
||||
.isEqualTo(ProtobufHttpMessageConverter.PROTOBUF);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Juergen Hoeller
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
public class ProtobufJsonFormatHttpMessageConverterTests {
|
||||
class ProtobufJsonFormatHttpMessageConverterTests {
|
||||
|
||||
private final ProtobufHttpMessageConverter converter = new ProtobufJsonFormatHttpMessageConverter(
|
||||
JsonFormat.parser(), JsonFormat.printer());
|
||||
@@ -45,7 +45,7 @@ public class ProtobufJsonFormatHttpMessageConverterTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void canRead() {
|
||||
void canRead() {
|
||||
assertThat(this.converter.canRead(Msg.class, null)).isTrue();
|
||||
assertThat(this.converter.canRead(Msg.class, ProtobufHttpMessageConverter.PROTOBUF)).isTrue();
|
||||
assertThat(this.converter.canRead(Msg.class, MediaType.APPLICATION_JSON)).isTrue();
|
||||
@@ -53,7 +53,7 @@ public class ProtobufJsonFormatHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canWrite() {
|
||||
void canWrite() {
|
||||
assertThat(this.converter.canWrite(Msg.class, null)).isTrue();
|
||||
assertThat(this.converter.canWrite(Msg.class, ProtobufHttpMessageConverter.PROTOBUF)).isTrue();
|
||||
assertThat(this.converter.canWrite(Msg.class, MediaType.APPLICATION_JSON)).isTrue();
|
||||
@@ -61,7 +61,7 @@ public class ProtobufJsonFormatHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void read() throws IOException {
|
||||
void read() throws IOException {
|
||||
byte[] body = this.testMsg.toByteArray();
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body);
|
||||
inputMessage.getHeaders().setContentType(ProtobufHttpMessageConverter.PROTOBUF);
|
||||
@@ -70,7 +70,7 @@ public class ProtobufJsonFormatHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readNoContentType() throws IOException {
|
||||
void readNoContentType() throws IOException {
|
||||
byte[] body = this.testMsg.toByteArray();
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body);
|
||||
Message result = this.converter.read(Msg.class, inputMessage);
|
||||
@@ -78,7 +78,7 @@ public class ProtobufJsonFormatHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void write() throws IOException {
|
||||
void write() throws IOException {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
MediaType contentType = ProtobufHttpMessageConverter.PROTOBUF;
|
||||
this.converter.write(this.testMsg, contentType, outputMessage);
|
||||
@@ -96,12 +96,12 @@ public class ProtobufJsonFormatHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultContentType() throws Exception {
|
||||
void defaultContentType() {
|
||||
assertThat(this.converter.getDefaultContentType(this.testMsg)).isEqualTo(ProtobufHttpMessageConverter.PROTOBUF);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getContentLength() throws Exception {
|
||||
void getContentLength() throws Exception {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
MediaType contentType = ProtobufHttpMessageConverter.PROTOBUF;
|
||||
this.converter.write(this.testMsg, contentType, outputMessage);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -34,28 +34,28 @@ import static org.assertj.core.api.Assertions.within;
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
public class MappingJackson2SmileHttpMessageConverterTests {
|
||||
class MappingJackson2SmileHttpMessageConverterTests {
|
||||
|
||||
private final MappingJackson2SmileHttpMessageConverter converter = new MappingJackson2SmileHttpMessageConverter();
|
||||
private final ObjectMapper mapper = new ObjectMapper(new SmileFactory());
|
||||
|
||||
|
||||
@Test
|
||||
public void canRead() {
|
||||
void canRead() {
|
||||
assertThat(converter.canRead(MyBean.class, new MediaType("application", "x-jackson-smile"))).isTrue();
|
||||
assertThat(converter.canRead(MyBean.class, new MediaType("application", "json"))).isFalse();
|
||||
assertThat(converter.canRead(MyBean.class, new MediaType("application", "xml"))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canWrite() {
|
||||
void canWrite() {
|
||||
assertThat(converter.canWrite(MyBean.class, new MediaType("application", "x-jackson-smile"))).isTrue();
|
||||
assertThat(converter.canWrite(MyBean.class, new MediaType("application", "json"))).isFalse();
|
||||
assertThat(converter.canWrite(MyBean.class, new MediaType("application", "xml"))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void read() throws IOException {
|
||||
void read() throws IOException {
|
||||
MyBean body = new MyBean();
|
||||
body.setString("Foo");
|
||||
body.setNumber(42);
|
||||
@@ -76,7 +76,7 @@ public class MappingJackson2SmileHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void write() throws IOException {
|
||||
void write() throws IOException {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
MyBean body = new MyBean();
|
||||
body.setString("Foo");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -47,7 +47,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
* @author Arjen Poutsma
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class Jaxb2CollectionHttpMessageConverterTests {
|
||||
class Jaxb2CollectionHttpMessageConverterTests {
|
||||
|
||||
private Jaxb2CollectionHttpMessageConverter<?> converter;
|
||||
|
||||
@@ -61,7 +61,7 @@ public class Jaxb2CollectionHttpMessageConverterTests {
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
void setup() {
|
||||
converter = new Jaxb2CollectionHttpMessageConverter<Collection<Object>>();
|
||||
rootElementListType = new ParameterizedTypeReference<List<RootElement>>() {}.getType();
|
||||
rootElementSetType = new ParameterizedTypeReference<Set<RootElement>>() {}.getType();
|
||||
@@ -71,7 +71,7 @@ public class Jaxb2CollectionHttpMessageConverterTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void canRead() {
|
||||
void canRead() {
|
||||
assertThat(converter.canRead(rootElementListType, null, null)).isTrue();
|
||||
assertThat(converter.canRead(rootElementSetType, null, null)).isTrue();
|
||||
assertThat(converter.canRead(typeSetType, null, null)).isTrue();
|
||||
@@ -179,7 +179,7 @@ public class Jaxb2CollectionHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testXmlBomb() throws Exception {
|
||||
void testXmlBomb() {
|
||||
// https://en.wikipedia.org/wiki/Billion_laughs
|
||||
// https://msdn.microsoft.com/en-us/magazine/ee335713.aspx
|
||||
String content = """
|
||||
@@ -218,7 +218,7 @@ public class Jaxb2CollectionHttpMessageConverterTests {
|
||||
@XmlElement
|
||||
public TestType type = new TestType();
|
||||
|
||||
@XmlElement(required=false)
|
||||
@XmlElement(required = false)
|
||||
public String external;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -55,7 +55,7 @@ import static org.xmlunit.diff.DifferenceEvaluators.downgradeDifferencesToEqual;
|
||||
* @author Sebastien Deleuze
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class Jaxb2RootElementHttpMessageConverterTests {
|
||||
class Jaxb2RootElementHttpMessageConverterTests {
|
||||
|
||||
private Jaxb2RootElementHttpMessageConverter converter;
|
||||
|
||||
@@ -65,7 +65,7 @@ public class Jaxb2RootElementHttpMessageConverterTests {
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
void setup() {
|
||||
converter = new Jaxb2RootElementHttpMessageConverter();
|
||||
rootElement = new RootElement();
|
||||
DefaultAopProxyFactory proxyFactory = new DefaultAopProxyFactory();
|
||||
@@ -78,7 +78,7 @@ public class Jaxb2RootElementHttpMessageConverterTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void canRead() {
|
||||
void canRead() {
|
||||
assertThat(converter.canRead(RootElement.class, null))
|
||||
.as("Converter does not support reading @XmlRootElement").isTrue();
|
||||
assertThat(converter.canRead(Type.class, null))
|
||||
@@ -86,7 +86,7 @@ public class Jaxb2RootElementHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canWrite() {
|
||||
void canWrite() {
|
||||
assertThat(converter.canWrite(RootElement.class, null))
|
||||
.as("Converter does not support writing @XmlRootElement").isTrue();
|
||||
assertThat(converter.canWrite(RootElementSubclass.class, null))
|
||||
@@ -98,7 +98,7 @@ public class Jaxb2RootElementHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readXmlRootElement() throws Exception {
|
||||
void readXmlRootElement() throws Exception {
|
||||
byte[] body = "<rootElement><type s=\"Hello World\"/></rootElement>".getBytes(StandardCharsets.UTF_8);
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body);
|
||||
RootElement result = (RootElement) converter.read(RootElement.class, inputMessage);
|
||||
@@ -106,7 +106,7 @@ public class Jaxb2RootElementHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readXmlRootElementSubclass() throws Exception {
|
||||
void readXmlRootElementSubclass() throws Exception {
|
||||
byte[] body = "<rootElement><type s=\"Hello World\"/></rootElement>".getBytes(StandardCharsets.UTF_8);
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body);
|
||||
RootElementSubclass result = (RootElementSubclass) converter.read(RootElementSubclass.class, inputMessage);
|
||||
@@ -114,7 +114,7 @@ public class Jaxb2RootElementHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readXmlType() throws Exception {
|
||||
void readXmlType() throws Exception {
|
||||
byte[] body = "<foo s=\"Hello World\"/>".getBytes(StandardCharsets.UTF_8);
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body);
|
||||
Type result = (Type) converter.read(Type.class, inputMessage);
|
||||
@@ -122,7 +122,7 @@ public class Jaxb2RootElementHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readXmlRootElementExternalEntityDisabled() throws Exception {
|
||||
void readXmlRootElementExternalEntityDisabled() throws Exception {
|
||||
Resource external = new ClassPathResource("external.txt", getClass());
|
||||
String content = "<!DOCTYPE root SYSTEM \"https://192.168.28.42/1.jsp\" [" +
|
||||
" <!ELEMENT external ANY >\n" +
|
||||
@@ -136,7 +136,7 @@ public class Jaxb2RootElementHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readXmlRootElementExternalEntityEnabled() throws Exception {
|
||||
void readXmlRootElementExternalEntityEnabled() throws Exception {
|
||||
Resource external = new ClassPathResource("external.txt", getClass());
|
||||
String content = "<!DOCTYPE root [" +
|
||||
" <!ELEMENT external ANY >\n" +
|
||||
@@ -150,7 +150,7 @@ public class Jaxb2RootElementHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testXmlBomb() throws Exception {
|
||||
void testXmlBomb() throws Exception {
|
||||
// https://en.wikipedia.org/wiki/Billion_laughs
|
||||
// https://msdn.microsoft.com/en-us/magazine/ee335713.aspx
|
||||
String content = """
|
||||
@@ -176,7 +176,7 @@ public class Jaxb2RootElementHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeXmlRootElement() throws Exception {
|
||||
void writeXmlRootElement() throws Exception {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
converter.write(rootElement, null, outputMessage);
|
||||
assertThat(outputMessage.getHeaders().getContentType())
|
||||
@@ -187,7 +187,7 @@ public class Jaxb2RootElementHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeXmlRootElementSubclass() throws Exception {
|
||||
void writeXmlRootElementSubclass() throws Exception {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
converter.write(rootElementCglib, null, outputMessage);
|
||||
assertThat(outputMessage.getHeaders().getContentType())
|
||||
@@ -200,7 +200,7 @@ public class Jaxb2RootElementHttpMessageConverterTests {
|
||||
// SPR-11488
|
||||
|
||||
@Test
|
||||
public void customizeMarshaller() throws Exception {
|
||||
void customizeMarshaller() throws Exception {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
MyJaxb2RootElementHttpMessageConverter myConverter = new MyJaxb2RootElementHttpMessageConverter();
|
||||
myConverter.write(new MyRootElement(new MyCustomElement("a", "b")), null, outputMessage);
|
||||
@@ -210,7 +210,7 @@ public class Jaxb2RootElementHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customizeUnmarshaller() throws Exception {
|
||||
void customizeUnmarshaller() throws Exception {
|
||||
byte[] body = "<myRootElement><element>a|||b</element></myRootElement>".getBytes(StandardCharsets.UTF_8);
|
||||
MyJaxb2RootElementHttpMessageConverter myConverter = new MyJaxb2RootElementHttpMessageConverter();
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -41,13 +41,13 @@ import static org.assertj.core.api.Assertions.within;
|
||||
* @author Sebastien Deleuze
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class MappingJackson2XmlHttpMessageConverterTests {
|
||||
class MappingJackson2XmlHttpMessageConverterTests {
|
||||
|
||||
private final MappingJackson2XmlHttpMessageConverter converter = new MappingJackson2XmlHttpMessageConverter();
|
||||
|
||||
|
||||
@Test
|
||||
public void canRead() {
|
||||
void canRead() {
|
||||
assertThat(converter.canRead(MyBean.class, new MediaType("application", "xml"))).isTrue();
|
||||
assertThat(converter.canRead(MyBean.class, new MediaType("text", "xml"))).isTrue();
|
||||
assertThat(converter.canRead(MyBean.class, new MediaType("application", "soap+xml"))).isTrue();
|
||||
@@ -56,7 +56,7 @@ public class MappingJackson2XmlHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canWrite() {
|
||||
void canWrite() {
|
||||
assertThat(converter.canWrite(MyBean.class, new MediaType("application", "xml"))).isTrue();
|
||||
assertThat(converter.canWrite(MyBean.class, new MediaType("text", "xml"))).isTrue();
|
||||
assertThat(converter.canWrite(MyBean.class, new MediaType("application", "soap+xml"))).isTrue();
|
||||
@@ -65,7 +65,7 @@ public class MappingJackson2XmlHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void read() throws IOException {
|
||||
void read() throws IOException {
|
||||
String body = "<MyBean>" +
|
||||
"<string>Foo</string>" +
|
||||
"<number>42</number>" +
|
||||
@@ -86,7 +86,7 @@ public class MappingJackson2XmlHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void write() throws IOException {
|
||||
void write() throws IOException {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
MyBean body = new MyBean();
|
||||
body.setString("Foo");
|
||||
@@ -108,7 +108,7 @@ public class MappingJackson2XmlHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readInvalidXml() throws IOException {
|
||||
void readInvalidXml() {
|
||||
String body = "FooBar";
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes(StandardCharsets.UTF_8));
|
||||
inputMessage.getHeaders().setContentType(MediaType.APPLICATION_XML);
|
||||
@@ -117,7 +117,7 @@ public class MappingJackson2XmlHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readValidXmlWithUnknownProperty() throws IOException {
|
||||
void readValidXmlWithUnknownProperty() throws IOException {
|
||||
String body = "<MyBean><string>string</string><unknownProperty>value</unknownProperty></MyBean>";
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes(StandardCharsets.UTF_8));
|
||||
inputMessage.getHeaders().setContentType(MediaType.APPLICATION_XML);
|
||||
@@ -126,7 +126,7 @@ public class MappingJackson2XmlHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonView() throws Exception {
|
||||
void jsonView() throws Exception {
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
JacksonViewBean bean = new JacksonViewBean();
|
||||
bean.setWithView1("with");
|
||||
@@ -144,13 +144,13 @@ public class MappingJackson2XmlHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customXmlMapper() {
|
||||
void customXmlMapper() {
|
||||
new MappingJackson2XmlHttpMessageConverter(new MyXmlMapper());
|
||||
// Assert no exception is thrown
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readWithExternalReference() throws IOException {
|
||||
void readWithExternalReference() throws IOException {
|
||||
String body = "<!DOCTYPE MyBean SYSTEM \"https://192.168.28.42/1.jsp\" [" +
|
||||
" <!ELEMENT root ANY >\n" +
|
||||
" <!ENTITY ext SYSTEM \"" +
|
||||
@@ -165,7 +165,7 @@ public class MappingJackson2XmlHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readWithXmlBomb() throws IOException {
|
||||
void readWithXmlBomb() {
|
||||
// https://en.wikipedia.org/wiki/Billion_laughs
|
||||
// https://msdn.microsoft.com/en-us/magazine/ee335713.aspx
|
||||
String body = """
|
||||
@@ -193,7 +193,6 @@ public class MappingJackson2XmlHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void readNonUnicode() throws Exception {
|
||||
String body = "<MyBean>" +
|
||||
"<string>føø bår</string>" +
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -48,10 +48,10 @@ import static org.mockito.Mockito.mock;
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class MarshallingHttpMessageConverterTests {
|
||||
class MarshallingHttpMessageConverterTests {
|
||||
|
||||
@Test
|
||||
public void canRead() {
|
||||
void canRead() {
|
||||
Unmarshaller unmarshaller = mock();
|
||||
|
||||
given(unmarshaller.supports(Integer.class)).willReturn(false);
|
||||
@@ -66,7 +66,7 @@ public class MarshallingHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canWrite() {
|
||||
void canWrite() {
|
||||
Marshaller marshaller = mock();
|
||||
|
||||
given(marshaller.supports(Integer.class)).willReturn(false);
|
||||
@@ -81,7 +81,7 @@ public class MarshallingHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void read() throws Exception {
|
||||
void read() throws Exception {
|
||||
String body = "<root>Hello World</root>";
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
@@ -96,7 +96,7 @@ public class MarshallingHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readWithTypeMismatchException() throws Exception {
|
||||
void readWithTypeMismatchException() throws Exception {
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(new byte[0]);
|
||||
|
||||
Marshaller marshaller = mock();
|
||||
@@ -110,7 +110,7 @@ public class MarshallingHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readWithMarshallingFailureException() throws Exception {
|
||||
void readWithMarshallingFailureException() throws Exception {
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(new byte[0]);
|
||||
UnmarshallingFailureException ex = new UnmarshallingFailureException("forced");
|
||||
|
||||
@@ -125,7 +125,7 @@ public class MarshallingHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void write() throws Exception {
|
||||
void write() throws Exception {
|
||||
String body = "<root>Hello World</root>";
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
|
||||
@@ -140,7 +140,7 @@ public class MarshallingHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeWithMarshallingFailureException() throws Exception {
|
||||
void writeWithMarshallingFailureException() throws Exception {
|
||||
String body = "<root>Hello World</root>";
|
||||
MockHttpOutputMessage outputMessage = new MockHttpOutputMessage();
|
||||
MarshallingFailureException ex = new MarshallingFailureException("forced");
|
||||
@@ -154,7 +154,7 @@ public class MarshallingHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void supports() {
|
||||
void supports() {
|
||||
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() ->
|
||||
new MarshallingHttpMessageConverter().supports(Object.class));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -55,7 +55,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
* @author Arjen Poutsma
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class SourceHttpMessageConverterTests {
|
||||
class SourceHttpMessageConverterTests {
|
||||
|
||||
private static final String BODY = "<root>Hello World</root>";
|
||||
|
||||
@@ -65,7 +65,7 @@ public class SourceHttpMessageConverterTests {
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup() throws IOException {
|
||||
void setup() throws IOException {
|
||||
converter = new SourceHttpMessageConverter<>();
|
||||
Resource external = new ClassPathResource("external.txt", getClass());
|
||||
|
||||
@@ -76,20 +76,20 @@ public class SourceHttpMessageConverterTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void canRead() {
|
||||
void canRead() {
|
||||
assertThat(converter.canRead(Source.class, new MediaType("application", "xml"))).isTrue();
|
||||
assertThat(converter.canRead(Source.class, new MediaType("application", "soap+xml"))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canWrite() {
|
||||
void canWrite() {
|
||||
assertThat(converter.canWrite(Source.class, new MediaType("application", "xml"))).isTrue();
|
||||
assertThat(converter.canWrite(Source.class, new MediaType("application", "soap+xml"))).isTrue();
|
||||
assertThat(converter.canWrite(Source.class, MediaType.ALL)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readDOMSource() throws Exception {
|
||||
void readDOMSource() throws Exception {
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(BODY.getBytes(StandardCharsets.UTF_8));
|
||||
inputMessage.getHeaders().setContentType(MediaType.APPLICATION_XML);
|
||||
DOMSource result = (DOMSource) converter.read(DOMSource.class, inputMessage);
|
||||
@@ -98,7 +98,7 @@ public class SourceHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readDOMSourceExternal() throws Exception {
|
||||
void readDOMSourceExternal() throws Exception {
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(bodyExternal.getBytes(StandardCharsets.UTF_8));
|
||||
inputMessage.getHeaders().setContentType(MediaType.APPLICATION_XML);
|
||||
converter.setSupportDtd(true);
|
||||
@@ -109,7 +109,7 @@ public class SourceHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readDomSourceWithXmlBomb() throws Exception {
|
||||
void readDomSourceWithXmlBomb() {
|
||||
// https://en.wikipedia.org/wiki/Billion_laughs
|
||||
// https://msdn.microsoft.com/en-us/magazine/ee335713.aspx
|
||||
String content = """
|
||||
@@ -136,7 +136,7 @@ public class SourceHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readSAXSource() throws Exception {
|
||||
void readSAXSource() throws Exception {
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(BODY.getBytes(StandardCharsets.UTF_8));
|
||||
inputMessage.getHeaders().setContentType(MediaType.APPLICATION_XML);
|
||||
SAXSource result = (SAXSource) converter.read(SAXSource.class, inputMessage);
|
||||
@@ -146,7 +146,7 @@ public class SourceHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readSAXSourceExternal() throws Exception {
|
||||
void readSAXSourceExternal() throws Exception {
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(bodyExternal.getBytes(StandardCharsets.UTF_8));
|
||||
inputMessage.getHeaders().setContentType(MediaType.APPLICATION_XML);
|
||||
converter.setSupportDtd(true);
|
||||
@@ -164,7 +164,7 @@ public class SourceHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readSAXSourceWithXmlBomb() throws Exception {
|
||||
void readSAXSourceWithXmlBomb() throws Exception {
|
||||
// https://en.wikipedia.org/wiki/Billion_laughs
|
||||
// https://msdn.microsoft.com/en-us/magazine/ee335713.aspx
|
||||
String content = """
|
||||
@@ -194,7 +194,7 @@ public class SourceHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readStAXSource() throws Exception {
|
||||
void readStAXSource() throws Exception {
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(BODY.getBytes(StandardCharsets.UTF_8));
|
||||
inputMessage.getHeaders().setContentType(MediaType.APPLICATION_XML);
|
||||
StAXSource result = (StAXSource) converter.read(StAXSource.class, inputMessage);
|
||||
@@ -209,7 +209,7 @@ public class SourceHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readStAXSourceExternal() throws Exception {
|
||||
void readStAXSourceExternal() throws Exception {
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(bodyExternal.getBytes(StandardCharsets.UTF_8));
|
||||
inputMessage.getHeaders().setContentType(MediaType.APPLICATION_XML);
|
||||
converter.setSupportDtd(true);
|
||||
@@ -231,7 +231,7 @@ public class SourceHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readStAXSourceWithXmlBomb() throws Exception {
|
||||
void readStAXSourceWithXmlBomb() throws Exception {
|
||||
// https://en.wikipedia.org/wiki/Billion_laughs
|
||||
// https://msdn.microsoft.com/en-us/magazine/ee335713.aspx
|
||||
String content = """
|
||||
@@ -264,7 +264,7 @@ public class SourceHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readStreamSource() throws Exception {
|
||||
void readStreamSource() throws Exception {
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(BODY.getBytes(StandardCharsets.UTF_8));
|
||||
inputMessage.getHeaders().setContentType(MediaType.APPLICATION_XML);
|
||||
StreamSource result = (StreamSource) converter.read(StreamSource.class, inputMessage);
|
||||
@@ -273,14 +273,14 @@ public class SourceHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readSource() throws Exception {
|
||||
void readSource() throws Exception {
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(BODY.getBytes(StandardCharsets.UTF_8));
|
||||
inputMessage.getHeaders().setContentType(MediaType.APPLICATION_XML);
|
||||
converter.read(Source.class, inputMessage);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeDOMSource() throws Exception {
|
||||
void writeDOMSource() throws Exception {
|
||||
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
|
||||
documentBuilderFactory.setNamespaceAware(true);
|
||||
Document document = documentBuilderFactory.newDocumentBuilder().newDocument();
|
||||
@@ -301,7 +301,7 @@ public class SourceHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeSAXSource() throws Exception {
|
||||
void writeSAXSource() throws Exception {
|
||||
String xml = "<root>Hello World</root>";
|
||||
SAXSource saxSource = new SAXSource(new InputSource(new StringReader(xml)));
|
||||
|
||||
@@ -315,7 +315,7 @@ public class SourceHttpMessageConverterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeStreamSource() throws Exception {
|
||||
void writeStreamSource() throws Exception {
|
||||
String xml = "<root>Hello World</root>";
|
||||
StreamSource streamSource = new StreamSource(new StringReader(xml));
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ class DefaultPathContainerTests {
|
||||
private void testPathSegment(String rawValue, String valueToMatch, MultiValueMap<String, String> params) {
|
||||
PathContainer container = PathContainer.parsePath(rawValue);
|
||||
|
||||
if ("".equals(rawValue)) {
|
||||
if (rawValue.isEmpty()) {
|
||||
assertThat(container.elements()).isEmpty();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -18,7 +18,6 @@ package org.springframework.http.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
@@ -37,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Arjen Poutsma
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class ServletServerHttpRequestTests {
|
||||
class ServletServerHttpRequestTests {
|
||||
|
||||
private ServletServerHttpRequest request;
|
||||
|
||||
@@ -58,7 +57,7 @@ public class ServletServerHttpRequestTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void getUriForSimplePath() throws URISyntaxException {
|
||||
void getUriForSimplePath() {
|
||||
URI uri = URI.create("https://example.com/path");
|
||||
mockRequest.setScheme(uri.getScheme());
|
||||
mockRequest.setServerName(uri.getHost());
|
||||
@@ -69,7 +68,7 @@ public class ServletServerHttpRequestTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void getUriWithQueryString() throws URISyntaxException {
|
||||
void getUriWithQueryString() {
|
||||
URI uri = URI.create("https://example.com/path?query");
|
||||
mockRequest.setScheme(uri.getScheme());
|
||||
mockRequest.setServerName(uri.getHost());
|
||||
@@ -80,7 +79,7 @@ public class ServletServerHttpRequestTests {
|
||||
}
|
||||
|
||||
@Test // SPR-16414
|
||||
void getUriWithQueryParam() throws URISyntaxException {
|
||||
void getUriWithQueryParam() {
|
||||
mockRequest.setScheme("https");
|
||||
mockRequest.setServerPort(443);
|
||||
mockRequest.setServerName("example.com");
|
||||
@@ -90,7 +89,7 @@ public class ServletServerHttpRequestTests {
|
||||
}
|
||||
|
||||
@Test // SPR-16414
|
||||
void getUriWithMalformedQueryParam() throws URISyntaxException {
|
||||
void getUriWithMalformedQueryParam() {
|
||||
mockRequest.setScheme("https");
|
||||
mockRequest.setServerPort(443);
|
||||
mockRequest.setServerName("example.com");
|
||||
@@ -100,7 +99,7 @@ public class ServletServerHttpRequestTests {
|
||||
}
|
||||
|
||||
@Test // SPR-13876
|
||||
void getUriWithEncoding() throws URISyntaxException {
|
||||
void getUriWithEncoding() {
|
||||
URI uri = URI.create("https://example.com/%E4%B8%AD%E6%96%87" +
|
||||
"?redirect=https%3A%2F%2Fgithub.com%2Fspring-projects%2Fspring-framework");
|
||||
mockRequest.setScheme(uri.getScheme());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class ServletServerHttpResponseTests {
|
||||
class ServletServerHttpResponseTests {
|
||||
|
||||
private ServletServerHttpResponse response;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -52,7 +52,6 @@ class AsyncIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||
startServer(httpServer);
|
||||
|
||||
URI url = URI.create("http://localhost:" + port);
|
||||
@SuppressWarnings("resource")
|
||||
ResponseEntity<String> response = new RestTemplate().exchange(RequestEntity.get(url).build(), String.class);
|
||||
|
||||
assertThat(response.getBody()).isEqualTo("hello");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -49,7 +49,7 @@ class ChannelSendOperatorTests {
|
||||
|
||||
|
||||
@Test
|
||||
void errorBeforeFirstItem() throws Exception {
|
||||
void errorBeforeFirstItem() {
|
||||
IllegalStateException error = new IllegalStateException("boo");
|
||||
Mono<Void> completion = Mono.<String>error(error).as(this::sendOperator);
|
||||
Signal<Void> signal = completion.materialize().block();
|
||||
@@ -59,7 +59,7 @@ class ChannelSendOperatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void completionBeforeFirstItem() throws Exception {
|
||||
void completionBeforeFirstItem() {
|
||||
Mono<Void> completion = Flux.<String>empty().as(this::sendOperator);
|
||||
Signal<Void> signal = completion.materialize().block();
|
||||
|
||||
@@ -71,15 +71,14 @@ class ChannelSendOperatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void writeOneItem() throws Exception {
|
||||
void writeOneItem() {
|
||||
Mono<Void> completion = Flux.just("one").as(this::sendOperator);
|
||||
Signal<Void> signal = completion.materialize().block();
|
||||
|
||||
assertThat(signal).isNotNull();
|
||||
assertThat(signal.isOnComplete()).as("Unexpected signal: " + signal).isTrue();
|
||||
|
||||
assertThat(this.writer.items).hasSize(1);
|
||||
assertThat(this.writer.items).element(0).isEqualTo("one");
|
||||
assertThat(this.writer.items).containsExactly("one");
|
||||
assertThat(this.writer.completed).isTrue();
|
||||
}
|
||||
|
||||
@@ -93,10 +92,7 @@ class ChannelSendOperatorTests {
|
||||
assertThat(signal).isNotNull();
|
||||
assertThat(signal.isOnComplete()).as("Unexpected signal: " + signal).isTrue();
|
||||
|
||||
assertThat(this.writer.items).hasSize(3);
|
||||
assertThat(this.writer.items).element(0).isEqualTo("one");
|
||||
assertThat(this.writer.items).element(1).isEqualTo("two");
|
||||
assertThat(this.writer.items).element(2).isEqualTo("three");
|
||||
assertThat(this.writer.items).containsExactly("one", "two", "three");
|
||||
assertThat(this.writer.completed).isTrue();
|
||||
}
|
||||
|
||||
@@ -117,10 +113,7 @@ class ChannelSendOperatorTests {
|
||||
assertThat(signal).isNotNull();
|
||||
assertThat(signal.getThrowable()).as("Unexpected signal: " + signal).isSameAs(error);
|
||||
|
||||
assertThat(this.writer.items).hasSize(3);
|
||||
assertThat(this.writer.items).element(0).isEqualTo("1");
|
||||
assertThat(this.writer.items).element(1).isEqualTo("2");
|
||||
assertThat(this.writer.items).element(2).isEqualTo("3");
|
||||
assertThat(this.writer.items).containsExactly("1", "2", "3");
|
||||
assertThat(this.writer.error).isSameAs(error);
|
||||
}
|
||||
|
||||
@@ -171,7 +164,7 @@ class ChannelSendOperatorTests {
|
||||
|
||||
operator.subscribe(new BaseSubscriber<>() {});
|
||||
try {
|
||||
writeSubscriber.signalDemand(1); // Let cached signals ("foo" and error) be published..
|
||||
writeSubscriber.signalDemand(1); // Let cached signals ("foo" and error) be published
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
assertThat(ex.getCause()).isNotNull();
|
||||
@@ -224,7 +217,7 @@ class ChannelSendOperatorTests {
|
||||
}
|
||||
|
||||
|
||||
private <T> Mono<Void> sendOperator(Publisher<String> source){
|
||||
private Mono<Void> sendOperator(Publisher<String> source){
|
||||
return new ChannelSendOperator<>(source, writer::send);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,10 +38,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class ContextPathCompositeHandlerTests {
|
||||
class ContextPathCompositeHandlerTests {
|
||||
|
||||
@Test
|
||||
public void invalidContextPath() {
|
||||
void invalidContextPath() {
|
||||
testInvalid(" ", "Context path must not be empty");
|
||||
testInvalid("path", "Context path must begin with '/'");
|
||||
testInvalid("/path/", "Context path must not end with '/'");
|
||||
@@ -54,7 +54,7 @@ public class ContextPathCompositeHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void match() {
|
||||
void match() {
|
||||
TestHttpHandler handler1 = new TestHttpHandler();
|
||||
TestHttpHandler handler2 = new TestHttpHandler();
|
||||
TestHttpHandler handler3 = new TestHttpHandler();
|
||||
@@ -71,7 +71,7 @@ public class ContextPathCompositeHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchWithContextPathEqualToPath() {
|
||||
void matchWithContextPathEqualToPath() {
|
||||
TestHttpHandler handler1 = new TestHttpHandler();
|
||||
TestHttpHandler handler2 = new TestHttpHandler();
|
||||
TestHttpHandler handler3 = new TestHttpHandler();
|
||||
@@ -88,7 +88,7 @@ public class ContextPathCompositeHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchWithNativeContextPath() {
|
||||
void matchWithNativeContextPath() {
|
||||
MockServerHttpRequest request = MockServerHttpRequest
|
||||
.get("/yet/another/path")
|
||||
.contextPath("/yet") // contextPath in underlying request
|
||||
@@ -104,7 +104,7 @@ public class ContextPathCompositeHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notFound() {
|
||||
void notFound() {
|
||||
TestHttpHandler handler1 = new TestHttpHandler();
|
||||
TestHttpHandler handler2 = new TestHttpHandler();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -39,7 +39,7 @@ import static org.junit.jupiter.api.Assumptions.assumeFalse;
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
public class CookieIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||
class CookieIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||
|
||||
private final CookieHandler cookieHandler = new CookieHandler();
|
||||
|
||||
@@ -56,7 +56,6 @@ public class CookieIntegrationTests extends AbstractHttpHandlerIntegrationTests
|
||||
|
||||
URI url = URI.create("http://localhost:" + port);
|
||||
String header = "SID=31d4d96e407aad42; lang=en-US";
|
||||
@SuppressWarnings("resource")
|
||||
ResponseEntity<Void> response = new RestTemplate().exchange(
|
||||
RequestEntity.get(url).header("Cookie", header).build(), Void.class);
|
||||
|
||||
@@ -105,7 +104,7 @@ public class CookieIntegrationTests extends AbstractHttpHandlerIntegrationTests
|
||||
}
|
||||
|
||||
|
||||
private class CookieHandler implements HttpHandler {
|
||||
private static class CookieHandler implements HttpHandler {
|
||||
|
||||
private Map<String, List<HttpCookie>> requestCookies;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class EchoHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||
class EchoHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||
|
||||
private static final int REQUEST_SIZE = 4096 * 3;
|
||||
|
||||
@@ -49,7 +49,6 @@ public class EchoHandlerIntegrationTests extends AbstractHttpHandlerIntegrationT
|
||||
public void echo(HttpServer httpServer) throws Exception {
|
||||
startServer(httpServer);
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
byte[] body = randomBytes();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -49,7 +49,6 @@ class ErrorHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||
void responseBodyError(HttpServer httpServer) throws Exception {
|
||||
startServer(httpServer);
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
restTemplate.setErrorHandler(NO_OP_ERROR_HANDLER);
|
||||
|
||||
@@ -63,7 +62,6 @@ class ErrorHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||
void handlingError(HttpServer httpServer) throws Exception {
|
||||
startServer(httpServer);
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
restTemplate.setErrorHandler(NO_OP_ERROR_HANDLER);
|
||||
|
||||
@@ -77,7 +75,6 @@ class ErrorHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||
void emptyPathSegments(HttpServer httpServer) throws Exception {
|
||||
startServer(httpServer);
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
restTemplate.setErrorHandler(NO_OP_ERROR_HANDLER);
|
||||
|
||||
|
||||
@@ -20,14 +20,15 @@ import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import io.netty.handler.codec.http.DefaultHttpHeaders;
|
||||
import io.undertow.util.HeaderMap;
|
||||
import org.apache.tomcat.util.http.MimeHeaders;
|
||||
import org.assertj.core.api.StringAssert;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
@@ -89,13 +90,13 @@ class HeadersAdaptersTests {
|
||||
headers.add("TestHeader", "first");
|
||||
headers.add("TestHeader", "second");
|
||||
assertThat(headers.getFirst("TestHeader")).isEqualTo("first");
|
||||
assertThat(headers.get("TestHeader")).element(0).isEqualTo("first");
|
||||
assertThat(headers.get("TestHeader"), StringAssert.class).element(0).isEqualTo("first");
|
||||
}
|
||||
|
||||
@ParameterizedHeadersTest
|
||||
void putShouldOverrideExisting(MultiValueMap<String, String> headers) {
|
||||
headers.add("TestHeader", "first");
|
||||
headers.put("TestHeader", Arrays.asList("override"));
|
||||
headers.put("TestHeader", List.of("override"));
|
||||
assertThat(headers.getFirst("TestHeader")).isEqualTo("override");
|
||||
assertThat(headers.get("TestHeader")).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import static org.mockito.Mockito.mock;
|
||||
* @author Violeta Georgieva
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class ListenerReadPublisherTests {
|
||||
class ListenerReadPublisherTests {
|
||||
|
||||
private final TestListenerReadPublisher publisher = new TestListenerReadPublisher();
|
||||
|
||||
@@ -40,13 +40,13 @@ public class ListenerReadPublisherTests {
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
void setup() {
|
||||
this.publisher.subscribe(this.subscriber);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void twoReads() {
|
||||
void twoReads() {
|
||||
|
||||
this.subscriber.getSubscription().request(2);
|
||||
this.publisher.onDataAvailable();
|
||||
|
||||
@@ -35,7 +35,7 @@ import static org.mockito.Mockito.mock;
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class ListenerWriteProcessorTests {
|
||||
class ListenerWriteProcessorTests {
|
||||
|
||||
private final TestListenerWriteProcessor processor = new TestListenerWriteProcessor();
|
||||
|
||||
@@ -45,7 +45,7 @@ public class ListenerWriteProcessorTests {
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
void setup() {
|
||||
this.processor.subscribe(this.resultSubscriber);
|
||||
this.processor.onSubscribe(this.subscription);
|
||||
assertThat(subscription.getDemand()).isEqualTo(1);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -59,7 +59,6 @@ class RandomHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests
|
||||
|
||||
// TODO: fix Reactor support
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
byte[] body = randomBytes();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -29,10 +29,10 @@ import static org.mockito.Mockito.mock;
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class ReactorUriHelperTests {
|
||||
class ReactorUriHelperTests {
|
||||
|
||||
@Test
|
||||
public void hostnameWithZoneId() throws URISyntaxException {
|
||||
void hostnameWithZoneId() throws URISyntaxException {
|
||||
HttpServerRequest nettyRequest = mock();
|
||||
|
||||
given(nettyRequest.scheme()).willReturn("http");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -46,7 +46,6 @@ class ServerHttpRequestIntegrationTests extends AbstractHttpHandlerIntegrationTe
|
||||
|
||||
URI url = URI.create("http://localhost:" + port + "/foo?param=bar");
|
||||
RequestEntity<Void> request = RequestEntity.post(url).build();
|
||||
@SuppressWarnings("resource")
|
||||
ResponseEntity<Void> response = new RestTemplate().exchange(request, Void.class);
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@@ -48,16 +48,16 @@ import static org.mockito.Mockito.mock;
|
||||
* @author Sam Brannen
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
public class ServerHttpRequestTests {
|
||||
class ServerHttpRequestTests {
|
||||
|
||||
@Test
|
||||
public void queryParamsNone() throws Exception {
|
||||
void queryParamsNone() throws Exception {
|
||||
MultiValueMap<String, String> params = createRequest("/path").getQueryParams();
|
||||
assertThat(params).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryParams() throws Exception {
|
||||
void queryParams() throws Exception {
|
||||
MultiValueMap<String, String> params = createRequest("/path?a=A&b=B").getQueryParams();
|
||||
assertThat(params).hasSize(2);
|
||||
assertThat(params.get("a")).isEqualTo(Collections.singletonList("A"));
|
||||
@@ -65,7 +65,7 @@ public class ServerHttpRequestTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryParamsWithMultipleValues() throws Exception {
|
||||
void queryParamsWithMultipleValues() throws Exception {
|
||||
MultiValueMap<String, String> params = createRequest("/path?a=1&a=2").getQueryParams();
|
||||
assertThat(params).hasSize(1);
|
||||
assertThat(params.get("a")).isEqualTo(Arrays.asList("1", "2"));
|
||||
@@ -79,34 +79,34 @@ public class ServerHttpRequestTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryParamsWithEmptyValue() throws Exception {
|
||||
void queryParamsWithEmptyValue() throws Exception {
|
||||
MultiValueMap<String, String> params = createRequest("/path?a=").getQueryParams();
|
||||
assertThat(params).hasSize(1);
|
||||
assertThat(params.get("a")).isEqualTo(Collections.singletonList(""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryParamsWithNoValue() throws Exception {
|
||||
void queryParamsWithNoValue() throws Exception {
|
||||
MultiValueMap<String, String> params = createRequest("/path?a").getQueryParams();
|
||||
assertThat(params).hasSize(1);
|
||||
assertThat(params.get("a")).isEqualTo(Collections.singletonList(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mutateRequestMethod() throws Exception {
|
||||
void mutateRequestMethod() throws Exception {
|
||||
ServerHttpRequest request = createRequest("/").mutate().method(HttpMethod.DELETE).build();
|
||||
assertThat(request.getMethod()).isEqualTo(HttpMethod.DELETE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mutateSslInfo() throws Exception {
|
||||
void mutateSslInfo() throws Exception {
|
||||
SslInfo sslInfo = mock();
|
||||
ServerHttpRequest request = createRequest("/").mutate().sslInfo(sslInfo).build();
|
||||
assertThat(request.getSslInfo()).isSameAs(sslInfo);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mutateUriAndPath() throws Exception {
|
||||
void mutateUriAndPath() throws Exception {
|
||||
String baseUri = "https://aaa.org:8080/a";
|
||||
|
||||
ServerHttpRequest request = createRequest(baseUri).mutate().uri(URI.create("https://bbb.org:9090/b")).build();
|
||||
@@ -130,12 +130,12 @@ public class ServerHttpRequestTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mutateWithInvalidPath() {
|
||||
void mutateWithInvalidPath() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> createRequest("/").mutate().path("foo-bar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mutateHeadersViaConsumer() throws Exception {
|
||||
void mutateHeadersViaConsumer() throws Exception {
|
||||
String headerName = "key";
|
||||
String headerValue1 = "value1";
|
||||
String headerValue2 = "value2";
|
||||
@@ -151,7 +151,7 @@ public class ServerHttpRequestTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mutateHeaderBySettingHeaderValues() throws Exception {
|
||||
void mutateHeaderBySettingHeaderValues() throws Exception {
|
||||
String headerName = "key";
|
||||
String headerValue1 = "value1";
|
||||
String headerValue2 = "value2";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -85,7 +85,7 @@ class ServerHttpsRequestIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void checkUri() throws Exception {
|
||||
void checkUri() {
|
||||
URI url = URI.create("https://localhost:" + port + "/foo?param=bar");
|
||||
RequestEntity<Void> request = RequestEntity.post(url).build();
|
||||
ResponseEntity<Void> response = this.restTemplate.exchange(request, Void.class);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -54,7 +54,6 @@ class WriteOnlyHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTes
|
||||
void writeOnly(HttpServer httpServer) throws Exception {
|
||||
startServer(httpServer);
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
this.body = randomBytes();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -61,7 +61,6 @@ class ZeroCopyIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||
|
||||
URI url = URI.create("http://localhost:" + port);
|
||||
RequestEntity<?> request = RequestEntity.get(url).build();
|
||||
@SuppressWarnings("resource")
|
||||
ResponseEntity<byte[]> response = new RestTemplate().exchange(request, byte[].class);
|
||||
|
||||
assertThat(response.hasBody()).isTrue();
|
||||
|
||||
@@ -70,7 +70,7 @@ import static org.mockito.BDDMockito.when;
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class ErrorResponseExceptionTests {
|
||||
class ErrorResponseExceptionTests {
|
||||
|
||||
private final MethodParameter methodParameter =
|
||||
new MethodParameter(ResolvableMethod.on(getClass()).resolveMethod("handle"), 0);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class HeaderContentNegotiationStrategyTests {
|
||||
class HeaderContentNegotiationStrategyTests {
|
||||
|
||||
private final HeaderContentNegotiationStrategy strategy = new HeaderContentNegotiationStrategy();
|
||||
|
||||
@@ -45,7 +45,7 @@ public class HeaderContentNegotiationStrategyTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void resolveMediaTypes() throws Exception {
|
||||
void resolveMediaTypes() throws Exception {
|
||||
this.servletRequest.addHeader("Accept", "text/plain; q=0.5, text/html, text/x-dvi; q=0.8, text/x-c");
|
||||
List<MediaType> mediaTypes = this.strategy.resolveMediaTypes(this.webRequest);
|
||||
|
||||
@@ -70,7 +70,7 @@ public class HeaderContentNegotiationStrategyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveMediaTypesParseError() throws Exception {
|
||||
void resolveMediaTypesParseError() {
|
||||
this.servletRequest.addHeader("Accept", "textplain; q=0.5");
|
||||
assertThatExceptionOfType(HttpMediaTypeNotAcceptableException.class).isThrownBy(() ->
|
||||
this.strategy.resolveMediaTypes(this.webRequest));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -33,10 +33,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 3.2
|
||||
*/
|
||||
public class MappingContentNegotiationStrategyTests {
|
||||
class MappingContentNegotiationStrategyTests {
|
||||
|
||||
@Test
|
||||
public void resolveMediaTypes() throws Exception {
|
||||
void resolveMediaTypes() throws Exception {
|
||||
Map<String, MediaType> mapping = Collections.singletonMap("json", MediaType.APPLICATION_JSON);
|
||||
TestMappingContentNegotiationStrategy strategy = new TestMappingContentNegotiationStrategy("json", mapping);
|
||||
|
||||
@@ -47,7 +47,7 @@ public class MappingContentNegotiationStrategyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveMediaTypesNoMatch() throws Exception {
|
||||
void resolveMediaTypesNoMatch() throws Exception {
|
||||
Map<String, MediaType> mapping = null;
|
||||
TestMappingContentNegotiationStrategy strategy = new TestMappingContentNegotiationStrategy("blah", mapping);
|
||||
|
||||
@@ -57,7 +57,7 @@ public class MappingContentNegotiationStrategyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveMediaTypesNoKey() throws Exception {
|
||||
void resolveMediaTypesNoKey() throws Exception {
|
||||
Map<String, MediaType> mapping = Collections.singletonMap("json", MediaType.APPLICATION_JSON);
|
||||
TestMappingContentNegotiationStrategy strategy = new TestMappingContentNegotiationStrategy(null, mapping);
|
||||
|
||||
@@ -67,7 +67,7 @@ public class MappingContentNegotiationStrategyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveMediaTypesHandleNoMatch() throws Exception {
|
||||
void resolveMediaTypesHandleNoMatch() throws Exception {
|
||||
Map<String, MediaType> mapping = null;
|
||||
TestMappingContentNegotiationStrategy strategy = new TestMappingContentNegotiationStrategy("xml", mapping);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -33,23 +33,22 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Melissa Hartsock
|
||||
*/
|
||||
public class MappingMediaTypeFileExtensionResolverTests {
|
||||
class MappingMediaTypeFileExtensionResolverTests {
|
||||
|
||||
private static final Map<String, MediaType> DEFAULT_MAPPINGS =
|
||||
Collections.singletonMap("json", MediaType.APPLICATION_JSON);
|
||||
|
||||
|
||||
@Test
|
||||
public void resolveExtensions() {
|
||||
void resolveExtensions() {
|
||||
List<String> extensions = new MappingMediaTypeFileExtensionResolver(DEFAULT_MAPPINGS)
|
||||
.resolveFileExtensions(MediaType.APPLICATION_JSON);
|
||||
|
||||
assertThat(extensions).hasSize(1);
|
||||
assertThat(extensions).element(0).isEqualTo("json");
|
||||
assertThat(extensions).containsExactly("json");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveExtensionsNoMatch() {
|
||||
void resolveExtensionsNoMatch() {
|
||||
assertThat(new MappingMediaTypeFileExtensionResolver(DEFAULT_MAPPINGS)
|
||||
.resolveFileExtensions(MediaType.TEXT_HTML)).isEmpty();
|
||||
}
|
||||
@@ -61,7 +60,7 @@ public class MappingMediaTypeFileExtensionResolverTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allFileExtensions() {
|
||||
void allFileExtensions() {
|
||||
Map<String, MediaType> mappings = new HashMap<>();
|
||||
mappings.put("json", MediaType.APPLICATION_JSON);
|
||||
mappings.put("JsOn", MediaType.APPLICATION_JSON);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.web.accept;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -54,13 +53,13 @@ class PathExtensionContentNegotiationStrategyTests {
|
||||
|
||||
List<MediaType> mediaTypes = this.strategy.resolveMediaTypes(this.webRequest);
|
||||
|
||||
assertThat(mediaTypes).isEqualTo(Arrays.asList(new MediaType("text", "html")));
|
||||
assertThat(mediaTypes).containsExactly(new MediaType("text", "html"));
|
||||
|
||||
Map<String, MediaType> mapping = Collections.singletonMap("HTML", MediaType.APPLICATION_XHTML_XML);
|
||||
this.strategy = new PathExtensionContentNegotiationStrategy(mapping);
|
||||
mediaTypes = this.strategy.resolveMediaTypes(this.webRequest);
|
||||
|
||||
assertThat(mediaTypes).isEqualTo(Arrays.asList(new MediaType("application", "xhtml+xml")));
|
||||
assertThat(mediaTypes).containsExactly(new MediaType("application", "xhtml+xml"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -69,7 +68,7 @@ class PathExtensionContentNegotiationStrategyTests {
|
||||
|
||||
List<MediaType> mediaTypes = this.strategy.resolveMediaTypes(this.webRequest);
|
||||
|
||||
assertThat(mediaTypes).isEqualTo(Arrays.asList(new MediaType("application", "vnd.ms-excel")));
|
||||
assertThat(mediaTypes).containsExactly(new MediaType("application", "vnd.ms-excel"));
|
||||
}
|
||||
|
||||
@Test // SPR-8678
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -30,10 +30,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Juergen Hoeller
|
||||
* @since 02.05.2003
|
||||
*/
|
||||
public class EscapedErrorsTests {
|
||||
class EscapedErrorsTests {
|
||||
|
||||
@Test
|
||||
public void testEscapedErrors() {
|
||||
void testEscapedErrors() {
|
||||
TestBean tb = new TestBean();
|
||||
tb.setName("empty &");
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class MethodArgumentNotValidExceptionTests {
|
||||
class MethodArgumentNotValidExceptionTests {
|
||||
|
||||
@Test
|
||||
void errorsToStringList() throws Exception {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -37,10 +37,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Chris Beams
|
||||
* @author Scott Andrews
|
||||
*/
|
||||
public class ServletRequestDataBinderTests {
|
||||
class ServletRequestDataBinderTests {
|
||||
|
||||
@Test
|
||||
public void testBindingWithNestedObjectCreation() throws Exception {
|
||||
void testBindingWithNestedObjectCreation() {
|
||||
TestBean tb = new TestBean();
|
||||
|
||||
ServletRequestDataBinder binder = new ServletRequestDataBinder(tb, "person");
|
||||
@@ -61,7 +61,7 @@ public class ServletRequestDataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFieldPrefixCausesFieldReset() throws Exception {
|
||||
void testFieldPrefixCausesFieldReset() {
|
||||
TestBean target = new TestBean();
|
||||
ServletRequestDataBinder binder = new ServletRequestDataBinder(target);
|
||||
|
||||
@@ -77,7 +77,7 @@ public class ServletRequestDataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFieldPrefixCausesFieldResetWithIgnoreUnknownFields() throws Exception {
|
||||
void testFieldPrefixCausesFieldResetWithIgnoreUnknownFields() {
|
||||
TestBean target = new TestBean();
|
||||
ServletRequestDataBinder binder = new ServletRequestDataBinder(target);
|
||||
binder.setIgnoreUnknownFields(false);
|
||||
@@ -94,7 +94,7 @@ public class ServletRequestDataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFieldDefault() throws Exception {
|
||||
void testFieldDefault() {
|
||||
TestBean target = new TestBean();
|
||||
ServletRequestDataBinder binder = new ServletRequestDataBinder(target);
|
||||
|
||||
@@ -110,7 +110,7 @@ public class ServletRequestDataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFieldDefaultPreemptsFieldMarker() throws Exception {
|
||||
void testFieldDefaultPreemptsFieldMarker() {
|
||||
TestBean target = new TestBean();
|
||||
ServletRequestDataBinder binder = new ServletRequestDataBinder(target);
|
||||
|
||||
@@ -131,7 +131,7 @@ public class ServletRequestDataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFieldDefaultNonBoolean() throws Exception {
|
||||
void testFieldDefaultNonBoolean() {
|
||||
TestBean target = new TestBean();
|
||||
ServletRequestDataBinder binder = new ServletRequestDataBinder(target);
|
||||
|
||||
@@ -147,7 +147,7 @@ public class ServletRequestDataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithCommaSeparatedStringArray() throws Exception {
|
||||
void testWithCommaSeparatedStringArray() {
|
||||
TestBean target = new TestBean();
|
||||
ServletRequestDataBinder binder = new ServletRequestDataBinder(target);
|
||||
|
||||
@@ -165,7 +165,7 @@ public class ServletRequestDataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBindingWithNestedObjectCreationAndWrongOrder() throws Exception {
|
||||
void testBindingWithNestedObjectCreationAndWrongOrder() {
|
||||
TestBean tb = new TestBean();
|
||||
|
||||
ServletRequestDataBinder binder = new ServletRequestDataBinder(tb, "person");
|
||||
@@ -186,7 +186,7 @@ public class ServletRequestDataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoPrefix() throws Exception {
|
||||
void testNoPrefix() {
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
request.addParameter("forname", "Tony");
|
||||
request.addParameter("surname", "Blair");
|
||||
@@ -197,7 +197,7 @@ public class ServletRequestDataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPrefix() throws Exception {
|
||||
void testPrefix() {
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
request.addParameter("test_forname", "Tony");
|
||||
request.addParameter("test_surname", "Blair");
|
||||
@@ -213,14 +213,14 @@ public class ServletRequestDataBinderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoParameters() throws Exception {
|
||||
void testNoParameters() {
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
ServletRequestParameterPropertyValues pvs = new ServletRequestParameterPropertyValues(request);
|
||||
assertThat(pvs.getPropertyValues().length).as("Found no parameters").isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultipleValuesForParameter() throws Exception {
|
||||
void testMultipleValuesForParameter() {
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
String[] original = new String[] {"Tony", "Rod"};
|
||||
request.addParameter("forname", original);
|
||||
@@ -236,7 +236,7 @@ public class ServletRequestDataBinderTests {
|
||||
/**
|
||||
* Must contain: forname=Tony surname=Blair age=50
|
||||
*/
|
||||
protected void doTestTony(PropertyValues pvs) throws Exception {
|
||||
protected void doTestTony(PropertyValues pvs) {
|
||||
assertThat(pvs.getPropertyValues().length).as("Contains 3").isEqualTo(3);
|
||||
assertThat(pvs.contains("forname")).as("Contains forname").isTrue();
|
||||
assertThat(pvs.contains("surname")).as("Contains surname").isTrue();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user