Browse Source

Start building against Spring Framework 7.0.0-M9 snapshots

See gh-47008
pull/47012/head
Andy Wilkinson 4 months ago
parent
commit
fe371aba17
  1. 6
      buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/github/StandardGitHub.java
  2. 2
      gradle.properties
  3. 4
      module/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/server/HttpStatusHandlerTests.java
  4. 4
      module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/HttpHandlerAutoConfigurationTests.java
  5. 16
      module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/error/DefaultErrorAttributesTests.java
  6. 2
      smoke-test/spring-boot-smoke-test-actuator/src/main/java/smoketest/actuator/SampleRestControllerEndpointWithException.java
  7. 2
      smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementDifferentPortAndEndpointWithExceptionHandlerSampleActuatorApplicationTests.java
  8. 20
      smoke-test/spring-boot-smoke-test-tomcat/src/test/java/smoketest/tomcat/SampleTomcatApplicationTests.java

6
buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/github/StandardGitHub.java

@ -22,7 +22,6 @@ import java.util.Collections; @@ -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 { @@ -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())));
}
}

2
gradle.properties

@ -19,7 +19,7 @@ mavenVersion=3.9.10 @@ -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

4
module/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/server/HttpStatusHandlerTests.java

@ -68,9 +68,9 @@ class HttpStatusHandlerTests { @@ -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);
}
}

4
module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/HttpHandlerAutoConfigurationTests.java

@ -82,7 +82,7 @@ class HttpHandlerAutoConfigurationTests { @@ -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 { @@ -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();
}));
}

16
module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/error/DefaultErrorAttributesTests.java

@ -98,9 +98,9 @@ class DefaultErrorAttributesTests { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 {
}

2
smoke-test/spring-boot-smoke-test-actuator/src/main/java/smoketest/actuator/SampleRestControllerEndpointWithException.java

@ -44,7 +44,7 @@ public class SampleRestControllerEndpointWithException { @@ -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);
}
}

2
smoke-test/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementDifferentPortAndEndpointWithExceptionHandlerSampleActuatorApplicationTests.java

@ -45,7 +45,7 @@ class ManagementDifferentPortAndEndpointWithExceptionHandlerSampleActuatorApplic @@ -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");
}

20
smoke-test/spring-boot-smoke-test-tomcat/src/test/java/smoketest/tomcat/SampleTomcatApplicationTests.java

@ -17,6 +17,7 @@ @@ -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; @@ -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 { @@ -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 { @@ -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…
Cancel
Save