Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
16edf72f
Commit
16edf72f
authored
Sep 21, 2017
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test support for HTTP range requests to endpoints returning a Resource
Closes gh-9978
parent
2e01d906
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
1 deletion
+31
-1
AbstractWebEndpointIntegrationTests.java
...ate/endpoint/web/AbstractWebEndpointIntegrationTests.java
+1
-1
WebFluxEndpointIntegrationTests.java
...ndpoint/web/reactive/WebFluxEndpointIntegrationTests.java
+15
-0
MvcWebEndpointIntegrationTests.java
.../endpoint/web/servlet/MvcWebEndpointIntegrationTests.java
+15
-0
No files found.
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/AbstractWebEndpointIntegrationTests.java
View file @
16edf72f
...
@@ -447,7 +447,7 @@ public abstract class AbstractWebEndpointIntegrationTests<T extends Configurable
...
@@ -447,7 +447,7 @@ public abstract class AbstractWebEndpointIntegrationTests<T extends Configurable
@Configuration
@Configuration
@Import
(
BaseConfiguration
.
class
)
@Import
(
BaseConfiguration
.
class
)
static
class
ResourceEndpointConfiguration
{
protected
static
class
ResourceEndpointConfiguration
{
@Bean
@Bean
public
ResourceEndpoint
resourceEndpoint
()
{
public
ResourceEndpoint
resourceEndpoint
()
{
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/reactive/WebFluxEndpointIntegrationTests.java
View file @
16edf72f
...
@@ -31,12 +31,15 @@ import org.springframework.context.ApplicationListener;
...
@@ -31,12 +31,15 @@ import org.springframework.context.ApplicationListener;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.env.Environment
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.server.reactive.HttpHandler
;
import
org.springframework.http.server.reactive.HttpHandler
;
import
org.springframework.web.cors.CorsConfiguration
;
import
org.springframework.web.cors.CorsConfiguration
;
import
org.springframework.web.reactive.config.EnableWebFlux
;
import
org.springframework.web.reactive.config.EnableWebFlux
;
import
org.springframework.web.server.adapter.WebHttpHandlerBuilder
;
import
org.springframework.web.server.adapter.WebHttpHandlerBuilder
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
/**
* Integration tests for web endpoints exposed using WebFlux.
* Integration tests for web endpoints exposed using WebFlux.
*
*
...
@@ -63,6 +66,18 @@ public class WebFluxEndpointIntegrationTests
...
@@ -63,6 +66,18 @@ public class WebFluxEndpointIntegrationTests
.
valueEquals
(
"Access-Control-Allow-Methods"
,
"GET,POST"
));
.
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
@Override
protected
ReactiveWebServerApplicationContext
createApplicationContext
(
protected
ReactiveWebServerApplicationContext
createApplicationContext
(
Class
<?>...
config
)
{
Class
<?>...
config
)
{
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/MvcWebEndpointIntegrationTests.java
View file @
16edf72f
...
@@ -28,11 +28,14 @@ import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebSe
...
@@ -28,11 +28,14 @@ import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebSe
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.env.Environment
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.MediaType
;
import
org.springframework.web.cors.CorsConfiguration
;
import
org.springframework.web.cors.CorsConfiguration
;
import
org.springframework.web.servlet.DispatcherServlet
;
import
org.springframework.web.servlet.DispatcherServlet
;
import
org.springframework.web.servlet.config.annotation.EnableWebMvc
;
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.
* Integration tests for web endpoints exposed using Spring MVC.
*
*
...
@@ -59,6 +62,18 @@ public class MvcWebEndpointIntegrationTests extends
...
@@ -59,6 +62,18 @@ public class MvcWebEndpointIntegrationTests extends
.
valueEquals
(
"Access-Control-Allow-Methods"
,
"GET,POST"
));
.
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
@Override
protected
AnnotationConfigServletWebServerApplicationContext
createApplicationContext
(
protected
AnnotationConfigServletWebServerApplicationContext
createApplicationContext
(
Class
<?>...
config
)
{
Class
<?>...
config
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment