Start building against Spring Framework 7.0.0-M9 snapshots
See gh-47008
This commit is contained in:
parent
62649ae3ed
commit
fe371aba17
|
|
@ -22,7 +22,6 @@ import java.util.Collections;
|
|||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.DefaultUriBuilderFactory;
|
||||
import org.springframework.web.util.UriTemplateHandler;
|
||||
|
|
@ -60,9 +59,10 @@ final class StandardGitHub implements GitHub {
|
|||
return new StandardGitHubRepository(restTemplate);
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
@SuppressWarnings({ "deprecation", "removal" })
|
||||
private RestTemplate createRestTemplate() {
|
||||
return new RestTemplate(Collections.singletonList(new MappingJackson2HttpMessageConverter(new ObjectMapper())));
|
||||
return new RestTemplate(Collections.singletonList(
|
||||
new org.springframework.http.converter.json.MappingJackson2HttpMessageConverter(new ObjectMapper())));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ mavenVersion=3.9.10
|
|||
mockitoVersion=5.19.0
|
||||
nativeBuildToolsVersion=0.11.0
|
||||
snakeYamlVersion=2.4
|
||||
springFrameworkVersion=7.0.0-M8
|
||||
springFrameworkVersion=7.0.0-SNAPSHOT
|
||||
springFramework60xVersion=6.0.23
|
||||
tomcatVersion=11.0.10
|
||||
nullabilityPluginVersion=0.0.4
|
||||
|
|
|
|||
|
|
@ -68,9 +68,9 @@ class HttpStatusHandlerTests {
|
|||
|
||||
@Test
|
||||
void respondsWithStatus() throws Exception {
|
||||
HttpStatusHandler handler = new HttpStatusHandler(HttpStatus.I_AM_A_TEAPOT);
|
||||
HttpStatusHandler handler = new HttpStatusHandler(HttpStatus.EXPECTATION_FAILED);
|
||||
handler.handle(this.request, this.response);
|
||||
assertThat(this.servletResponse.getStatus()).isEqualTo(418);
|
||||
assertThat(this.servletResponse.getStatus()).isEqualTo(417);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ class HttpHandlerAutoConfigurationTests {
|
|||
ServerHttpRequest request = MockServerHttpRequest.get("").build();
|
||||
ServerHttpResponse response = new MockServerHttpResponse();
|
||||
httpHandler.handle(request, response).block();
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.I_AM_A_TEAPOT);
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.EXPECTATION_FAILED);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -131,7 +131,7 @@ class HttpHandlerAutoConfigurationTests {
|
|||
WebHttpHandlerBuilderCustomizer customizerDecorator() {
|
||||
return (webHttpHandlerBuilder) -> webHttpHandlerBuilder
|
||||
.httpHandlerDecorator(((httpHandler) -> (request, response) -> {
|
||||
response.setStatusCode(HttpStatus.I_AM_A_TEAPOT);
|
||||
response.setStatusCode(HttpStatus.EXPECTATION_FAILED);
|
||||
return response.setComplete();
|
||||
}));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,9 +98,9 @@ class DefaultErrorAttributesTests {
|
|||
MockServerHttpRequest request = MockServerHttpRequest.get("/test").build();
|
||||
Map<String, Object> attributes = this.errorAttributes.getErrorAttributes(buildServerRequest(request, error),
|
||||
ErrorAttributeOptions.defaults());
|
||||
assertThat(attributes).containsEntry("error", HttpStatus.I_AM_A_TEAPOT.getReasonPhrase());
|
||||
assertThat(attributes).containsEntry("error", HttpStatus.EXPECTATION_FAILED.getReasonPhrase());
|
||||
assertThat(attributes).doesNotContainKey("message");
|
||||
assertThat(attributes).containsEntry("status", HttpStatus.I_AM_A_TEAPOT.value());
|
||||
assertThat(attributes).containsEntry("status", HttpStatus.EXPECTATION_FAILED.value());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -109,9 +109,9 @@ class DefaultErrorAttributesTests {
|
|||
MockServerHttpRequest request = MockServerHttpRequest.get("/test").build();
|
||||
Map<String, Object> attributes = this.errorAttributes.getErrorAttributes(buildServerRequest(request, error),
|
||||
ErrorAttributeOptions.of(Include.MESSAGE, Include.STATUS, Include.ERROR));
|
||||
assertThat(attributes).containsEntry("error", HttpStatus.I_AM_A_TEAPOT.getReasonPhrase());
|
||||
assertThat(attributes).containsEntry("error", HttpStatus.EXPECTATION_FAILED.getReasonPhrase());
|
||||
assertThat(attributes).containsEntry("message", "Test Message");
|
||||
assertThat(attributes).containsEntry("status", HttpStatus.I_AM_A_TEAPOT.value());
|
||||
assertThat(attributes).containsEntry("status", HttpStatus.EXPECTATION_FAILED.value());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -120,8 +120,8 @@ class DefaultErrorAttributesTests {
|
|||
MockServerHttpRequest request = MockServerHttpRequest.get("/test").build();
|
||||
Map<String, Object> attributes = this.errorAttributes.getErrorAttributes(buildServerRequest(request, error),
|
||||
ErrorAttributeOptions.of(Include.MESSAGE, Include.STATUS, Include.ERROR));
|
||||
assertThat(attributes).containsEntry("error", HttpStatus.I_AM_A_TEAPOT.getReasonPhrase());
|
||||
assertThat(attributes).containsEntry("status", HttpStatus.I_AM_A_TEAPOT.value());
|
||||
assertThat(attributes).containsEntry("error", HttpStatus.EXPECTATION_FAILED.getReasonPhrase());
|
||||
assertThat(attributes).containsEntry("status", HttpStatus.EXPECTATION_FAILED.value());
|
||||
assertThat(attributes).containsEntry("message", "Nope!");
|
||||
}
|
||||
|
||||
|
|
@ -385,7 +385,7 @@ class DefaultErrorAttributesTests {
|
|||
return 42;
|
||||
}
|
||||
|
||||
@ResponseStatus(HttpStatus.I_AM_A_TEAPOT)
|
||||
@ResponseStatus(HttpStatus.EXPECTATION_FAILED)
|
||||
static class CustomException extends RuntimeException {
|
||||
|
||||
CustomException() {
|
||||
|
|
@ -397,7 +397,7 @@ class DefaultErrorAttributesTests {
|
|||
|
||||
}
|
||||
|
||||
@ResponseStatus(value = HttpStatus.I_AM_A_TEAPOT, reason = "Nope!")
|
||||
@ResponseStatus(value = HttpStatus.EXPECTATION_FAILED, reason = "Nope!")
|
||||
static class Custom2Exception extends RuntimeException {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class SampleRestControllerEndpointWithException {
|
|||
|
||||
@ExceptionHandler(CustomException.class)
|
||||
ResponseEntity<String> handleCustomException(CustomException e) {
|
||||
return new ResponseEntity<>("this is a custom exception body", HttpStatus.I_AM_A_TEAPOT);
|
||||
return new ResponseEntity<>("this is a custom exception body", HttpStatus.EXPECTATION_FAILED);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ class ManagementDifferentPortAndEndpointWithExceptionHandlerSampleActuatorApplic
|
|||
void testExceptionHandlerRestControllerEndpoint() {
|
||||
ResponseEntity<String> entity = new TestRestTemplate("user", "password")
|
||||
.getForEntity("http://localhost:" + this.managementPort + "/actuator/exception", String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.I_AM_A_TEAPOT);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.EXPECTATION_FAILED);
|
||||
assertThat(entity.getBody()).isEqualTo("this is a custom exception body");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
package smoketest.tomcat;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
|
|
@ -28,14 +29,18 @@ import smoketest.tomcat.util.RandomStringUtil;
|
|||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.http.client.ClientHttpRequestFactoryBuilder;
|
||||
import org.springframework.boot.restclient.RestTemplateBuilder;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.boot.test.context.TestConfiguration;
|
||||
import org.springframework.boot.test.system.CapturedOutput;
|
||||
import org.springframework.boot.test.system.OutputCaptureExtension;
|
||||
import org.springframework.boot.tomcat.TomcatWebServer;
|
||||
import org.springframework.boot.web.server.servlet.context.ServletWebServerApplicationContext;
|
||||
import org.springframework.boot.web.server.test.client.TestRestTemplate;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
|
@ -70,16 +75,18 @@ class SampleTomcatApplicationTests {
|
|||
void testHome() {
|
||||
ResponseEntity<String> entity = this.restTemplate.getForEntity("/", String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(entity.getHeaders().get(HttpHeaders.CONTENT_ENCODING)).isNull();
|
||||
assertThat(entity.getBody()).isEqualTo("Hello World");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCompression() throws Exception {
|
||||
void testCompression() throws IOException {
|
||||
HttpHeaders requestHeaders = new HttpHeaders();
|
||||
requestHeaders.set("Accept-Encoding", "gzip");
|
||||
HttpEntity<?> requestEntity = new HttpEntity<>(requestHeaders);
|
||||
ResponseEntity<byte[]> entity = this.restTemplate.exchange("/", HttpMethod.GET, requestEntity, byte[].class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(entity.getHeaders().get(HttpHeaders.CONTENT_ENCODING)).containsExactly("gzip");
|
||||
try (GZIPInputStream inflater = new GZIPInputStream(new ByteArrayInputStream(entity.getBody()))) {
|
||||
assertThat(StreamUtils.copyToString(inflater, StandardCharsets.UTF_8)).isEqualTo("Hello World");
|
||||
}
|
||||
|
|
@ -113,4 +120,15 @@ class SampleTomcatApplicationTests {
|
|||
assertThat(output).contains("java.lang.IllegalArgumentException: Request header is too large");
|
||||
}
|
||||
|
||||
@TestConfiguration
|
||||
static class DisableCompressionConfiguration {
|
||||
|
||||
@Bean
|
||||
RestTemplateBuilder restTemplateBuilder() {
|
||||
return new RestTemplateBuilder().requestFactoryBuilder(ClientHttpRequestFactoryBuilder.jdk()
|
||||
.withCustomizer((factory) -> factory.enableCompression(false)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue