diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/AbstractWebEndpointIntegrationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/AbstractWebEndpointIntegrationTests.java index a1e81acf8dd..bc522ae8132 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/AbstractWebEndpointIntegrationTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/AbstractWebEndpointIntegrationTests.java @@ -447,7 +447,7 @@ public abstract class AbstractWebEndpointIntegrationTests { + byte[] responseBody = client.get().uri("/resource") + .header("Range", "bytes=0-3").exchange().expectStatus() + .isEqualTo(HttpStatus.PARTIAL_CONTENT).expectHeader() + .contentType(MediaType.APPLICATION_OCTET_STREAM) + .returnResult(byte[].class).getResponseBodyContent(); + assertThat(responseBody).containsExactly(0, 1, 2, 3); + }); + } + @Override protected ReactiveWebServerApplicationContext createApplicationContext( Class... config) { diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/MvcWebEndpointIntegrationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/MvcWebEndpointIntegrationTests.java index 08db3668538..01589e8c7fb 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/MvcWebEndpointIntegrationTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/MvcWebEndpointIntegrationTests.java @@ -28,11 +28,14 @@ import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebSe import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; +import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.servlet.DispatcherServlet; import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import static org.assertj.core.api.Assertions.assertThat; + /** * Integration tests for web endpoints exposed using Spring MVC. * @@ -59,6 +62,18 @@ public class MvcWebEndpointIntegrationTests extends .valueEquals("Access-Control-Allow-Methods", "GET,POST")); } + @Test + public void readOperationsThatReturnAResourceSupportRangeRequests() { + load(ResourceEndpointConfiguration.class, (client) -> { + byte[] responseBody = client.get().uri("/resource") + .header("Range", "bytes=0-3").exchange().expectStatus() + .isEqualTo(HttpStatus.PARTIAL_CONTENT).expectHeader() + .contentType(MediaType.APPLICATION_OCTET_STREAM) + .returnResult(byte[].class).getResponseBodyContent(); + assertThat(responseBody).containsExactly(0, 1, 2, 3); + }); + } + @Override protected AnnotationConfigServletWebServerApplicationContext createApplicationContext( Class... config) {