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
3a7406fe
Commit
3a7406fe
authored
Dec 20, 2018
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.0.x' into 2.1.x
parents
84a064a7
0741c904
Changes
22
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
166 additions
and
109 deletions
+166
-109
CloudFoundryReactiveHealthEndpointWebExtensionTests.java
.../CloudFoundryReactiveHealthEndpointWebExtensionTests.java
+4
-1
ReactiveCloudFoundryActuatorAutoConfigurationTests.java
...e/ReactiveCloudFoundryActuatorAutoConfigurationTests.java
+11
-9
ReactiveHealthEndpointWebExtensionTests.java
...igure/health/ReactiveHealthEndpointWebExtensionTests.java
+29
-22
WebClientMetricsConfigurationTests.java
...etrics/web/client/WebClientMetricsConfigurationTests.java
+5
-2
EndpointRequestTests.java
...autoconfigure/security/reactive/EndpointRequestTests.java
+6
-4
ReactiveManagementWebSecurityAutoConfigurationTests.java
.../ReactiveManagementWebSecurityAutoConfigurationTests.java
+3
-1
CouchbaseReactiveHealthIndicatorTests.java
...uate/couchbase/CouchbaseReactiveHealthIndicatorTests.java
+3
-2
ControllerEndpointHandlerMappingTests.java
...t/web/reactive/ControllerEndpointHandlerMappingTests.java
+3
-1
MetricsWebClientFilterFunctionTests.java
.../reactive/client/MetricsWebClientFilterFunctionTests.java
+6
-5
MetricsWebFilterTests.java
...te/metrics/web/reactive/server/MetricsWebFilterTests.java
+6
-4
HttpTraceWebFilterTests.java
.../actuate/trace/http/reactive/HttpTraceWebFilterTests.java
+11
-8
FreeMarkerAutoConfigurationReactiveIntegrationTests.java
.../FreeMarkerAutoConfigurationReactiveIntegrationTests.java
+11
-5
ReactiveOAuth2ClientAutoConfigurationTests.java
.../reactive/ReactiveOAuth2ClientAutoConfigurationTests.java
+2
-1
ReactiveUserDetailsServiceAutoConfigurationTests.java
...ive/ReactiveUserDetailsServiceAutoConfigurationTests.java
+14
-12
StaticResourceRequestTests.java
...nfigure/security/reactive/StaticResourceRequestTests.java
+7
-4
WebClientAutoConfigurationTests.java
...tive/function/client/WebClientAutoConfigurationTests.java
+5
-2
DataMongoTestReactiveIntegrationTests.java
...ure/data/mongo/DataMongoTestReactiveIntegrationTests.java
+7
-4
UndertowReactiveWebServerFactoryTests.java
...edded/undertow/UndertowReactiveWebServerFactoryTests.java
+2
-1
MustacheViewResolverTests.java
...t/web/reactive/result/view/MustacheViewResolverTests.java
+8
-3
MustacheViewTests.java
...work/boot/web/reactive/result/view/MustacheViewTests.java
+5
-4
AbstractReactiveWebServerFactoryTests.java
...eactive/server/AbstractReactiveWebServerFactoryTests.java
+10
-9
SampleSessionWebFluxApplicationTests.java
.../sample/session/SampleSessionWebFluxApplicationTests.java
+8
-5
No files found.
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/CloudFoundryReactiveHealthEndpointWebExtensionTests.java
View file @
3a7406fe
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
.
cloudfoundry
.
reactive
;
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
.
cloudfoundry
.
reactive
;
import
java.time.Duration
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration
;
import
org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration
;
...
@@ -63,7 +65,8 @@ public class CloudFoundryReactiveHealthEndpointWebExtensionTests {
...
@@ -63,7 +65,8 @@ public class CloudFoundryReactiveHealthEndpointWebExtensionTests {
this
.
contextRunner
.
run
((
context
)
->
{
this
.
contextRunner
.
run
((
context
)
->
{
CloudFoundryReactiveHealthEndpointWebExtension
extension
=
context
CloudFoundryReactiveHealthEndpointWebExtension
extension
=
context
.
getBean
(
CloudFoundryReactiveHealthEndpointWebExtension
.
class
);
.
getBean
(
CloudFoundryReactiveHealthEndpointWebExtension
.
class
);
assertThat
(
extension
.
health
().
block
().
getBody
().
getDetails
()).
isNotEmpty
();
assertThat
(
extension
.
health
().
block
(
Duration
.
ofSeconds
(
30
)).
getBody
()
.
getDetails
()).
isNotEmpty
();
});
});
}
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfigurationTests.java
View file @
3a7406fe
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
.
cloudfoundry
.
reactive
;
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
.
cloudfoundry
.
reactive
;
import
java.time.Duration
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.List
;
...
@@ -198,16 +199,17 @@ public class ReactiveCloudFoundryActuatorAutoConfigurationTests {
...
@@ -198,16 +199,17 @@ public class ReactiveCloudFoundryActuatorAutoConfigurationTests {
Boolean
cfRequestMatches
=
filters
.
get
(
0
)
Boolean
cfRequestMatches
=
filters
.
get
(
0
)
.
matches
(
MockServerWebExchange
.
from
(
MockServerHttpRequest
.
matches
(
MockServerWebExchange
.
from
(
MockServerHttpRequest
.
get
(
"/cloudfoundryapplication/my-path"
).
build
()))
.
get
(
"/cloudfoundryapplication/my-path"
).
build
()))
.
block
();
.
block
(
Duration
.
ofSeconds
(
30
)
);
Boolean
otherRequestMatches
=
filters
.
get
(
0
)
Boolean
otherRequestMatches
=
filters
.
get
(
0
)
.
matches
(
MockServerWebExchange
.
from
(
MockServerHttpRequest
.
matches
(
MockServerWebExchange
.
from
(
MockServerHttpRequest
.
get
(
"/some-other-path"
).
build
()))
.
get
(
"/some-other-path"
).
build
()))
.
block
();
.
block
(
Duration
.
ofSeconds
(
30
)
);
assertThat
(
cfRequestMatches
).
isTrue
();
assertThat
(
cfRequestMatches
).
isTrue
();
assertThat
(
otherRequestMatches
).
isFalse
();
assertThat
(
otherRequestMatches
).
isFalse
();
otherRequestMatches
=
filters
.
get
(
1
).
matches
(
MockServerWebExchange
otherRequestMatches
=
filters
.
get
(
1
)
.
from
(
MockServerHttpRequest
.
get
(
"/some-other-path"
).
build
()))
.
matches
(
MockServerWebExchange
.
from
(
MockServerHttpRequest
.
block
();
.
get
(
"/some-other-path"
).
build
()))
.
block
(
Duration
.
ofSeconds
(
30
));
assertThat
(
otherRequestMatches
).
isTrue
();
assertThat
(
otherRequestMatches
).
isTrue
();
});
});
...
@@ -312,7 +314,7 @@ public class ReactiveCloudFoundryActuatorAutoConfigurationTests {
...
@@ -312,7 +314,7 @@ public class ReactiveCloudFoundryActuatorAutoConfigurationTests {
WebClient
webClient
=
(
WebClient
)
ReflectionTestUtils
WebClient
webClient
=
(
WebClient
)
ReflectionTestUtils
.
getField
(
interceptorSecurityService
,
"webClient"
);
.
getField
(
interceptorSecurityService
,
"webClient"
);
webClient
.
get
().
uri
(
"https://self-signed.badssl.com/"
).
exchange
()
webClient
.
get
().
uri
(
"https://self-signed.badssl.com/"
).
exchange
()
.
block
();
.
block
(
Duration
.
ofSeconds
(
30
)
);
});
});
}
}
...
@@ -334,9 +336,9 @@ public class ReactiveCloudFoundryActuatorAutoConfigurationTests {
...
@@ -334,9 +336,9 @@ public class ReactiveCloudFoundryActuatorAutoConfigurationTests {
WebClient
webClient
=
(
WebClient
)
ReflectionTestUtils
WebClient
webClient
=
(
WebClient
)
ReflectionTestUtils
.
getField
(
interceptorSecurityService
,
"webClient"
);
.
getField
(
interceptorSecurityService
,
"webClient"
);
assertThatExceptionOfType
(
RuntimeException
.
class
)
assertThatExceptionOfType
(
RuntimeException
.
class
)
.
isThrownBy
(
.
isThrownBy
(
()
->
webClient
.
get
()
webClient
.
get
().
uri
(
"https://self-signed.badssl.com/"
)
.
uri
(
"https://self-signed.badssl.com/"
).
exchange
(
)
.
exchange
()::
block
)
.
block
(
Duration
.
ofSeconds
(
30
))
)
.
withCauseInstanceOf
(
SSLException
.
class
);
.
withCauseInstanceOf
(
SSLException
.
class
);
});
});
}
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/health/ReactiveHealthEndpointWebExtensionTests.java
View file @
3a7406fe
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
.
health
;
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
.
health
;
import
java.security.Principal
;
import
java.security.Principal
;
import
java.time.Duration
;
import
org.junit.Test
;
import
org.junit.Test
;
import
reactor.core.publisher.Mono
;
import
reactor.core.publisher.Mono
;
...
@@ -98,8 +99,8 @@ public class ReactiveHealthEndpointWebExtensionTests {
...
@@ -98,8 +99,8 @@ public class ReactiveHealthEndpointWebExtensionTests {
SecurityContext
securityContext
=
mock
(
SecurityContext
.
class
);
SecurityContext
securityContext
=
mock
(
SecurityContext
.
class
);
given
(
securityContext
.
getPrincipal
())
given
(
securityContext
.
getPrincipal
())
.
willReturn
(
mock
(
Principal
.
class
));
.
willReturn
(
mock
(
Principal
.
class
));
Health
extensionHealth
=
extension
.
health
(
securityContext
)
.
block
()
Health
extensionHealth
=
extension
.
health
(
securityContext
)
.
getBody
();
.
block
(
Duration
.
ofSeconds
(
30
)).
getBody
();
assertThat
(
endpointHealth
.
getDetails
())
assertThat
(
endpointHealth
.
getDetails
())
.
containsOnlyKeys
(
"application"
,
"first"
,
"second"
);
.
containsOnlyKeys
(
"application"
,
"first"
,
"second"
);
assertThat
(
extensionHealth
.
getDetails
())
assertThat
(
extensionHealth
.
getDetails
())
...
@@ -112,8 +113,8 @@ public class ReactiveHealthEndpointWebExtensionTests {
...
@@ -112,8 +113,8 @@ public class ReactiveHealthEndpointWebExtensionTests {
this
.
contextRunner
.
run
((
context
)
->
{
this
.
contextRunner
.
run
((
context
)
->
{
ReactiveHealthEndpointWebExtension
extension
=
context
ReactiveHealthEndpointWebExtension
extension
=
context
.
getBean
(
ReactiveHealthEndpointWebExtension
.
class
);
.
getBean
(
ReactiveHealthEndpointWebExtension
.
class
);
assertThat
(
extension
.
health
(
mock
(
SecurityContext
.
class
))
.
block
().
getBody
()
assertThat
(
extension
.
health
(
mock
(
SecurityContext
.
class
))
.
getDetails
()).
isEmpty
();
.
block
(
Duration
.
ofSeconds
(
30
)).
getBody
().
getDetails
()).
isEmpty
();
});
});
}
}
...
@@ -124,8 +125,8 @@ public class ReactiveHealthEndpointWebExtensionTests {
...
@@ -124,8 +125,8 @@ public class ReactiveHealthEndpointWebExtensionTests {
.
getBean
(
ReactiveHealthEndpointWebExtension
.
class
);
.
getBean
(
ReactiveHealthEndpointWebExtension
.
class
);
SecurityContext
securityContext
=
mock
(
SecurityContext
.
class
);
SecurityContext
securityContext
=
mock
(
SecurityContext
.
class
);
given
(
securityContext
.
getPrincipal
()).
willReturn
(
mock
(
Principal
.
class
));
given
(
securityContext
.
getPrincipal
()).
willReturn
(
mock
(
Principal
.
class
));
assertThat
(
extension
.
health
(
securityContext
).
block
(
).
getBody
().
getDetails
(
))
assertThat
(
extension
.
health
(
securityContext
).
block
(
Duration
.
ofSeconds
(
30
))
.
isEmpty
();
.
getBody
().
getDetails
()).
isEmpty
();
});
});
}
}
...
@@ -140,8 +141,9 @@ public class ReactiveHealthEndpointWebExtensionTests {
...
@@ -140,8 +141,9 @@ public class ReactiveHealthEndpointWebExtensionTests {
SecurityContext
securityContext
=
mock
(
SecurityContext
.
class
);
SecurityContext
securityContext
=
mock
(
SecurityContext
.
class
);
given
(
securityContext
.
getPrincipal
())
given
(
securityContext
.
getPrincipal
())
.
willReturn
(
mock
(
Principal
.
class
));
.
willReturn
(
mock
(
Principal
.
class
));
assertThat
(
extension
.
health
(
securityContext
).
block
().
getBody
()
assertThat
(
extension
.
health
(
securityContext
)
.
getDetails
()).
isNotEmpty
();
.
block
(
Duration
.
ofSeconds
(
30
)).
getBody
().
getDetails
())
.
isNotEmpty
();
});
});
}
}
...
@@ -152,8 +154,8 @@ public class ReactiveHealthEndpointWebExtensionTests {
...
@@ -152,8 +154,8 @@ public class ReactiveHealthEndpointWebExtensionTests {
.
run
((
context
)
->
{
.
run
((
context
)
->
{
ReactiveHealthEndpointWebExtension
extension
=
context
ReactiveHealthEndpointWebExtension
extension
=
context
.
getBean
(
ReactiveHealthEndpointWebExtension
.
class
);
.
getBean
(
ReactiveHealthEndpointWebExtension
.
class
);
assertThat
(
extension
.
health
(
null
).
block
(
).
getBody
().
getDetails
(
))
assertThat
(
extension
.
health
(
null
).
block
(
Duration
.
ofSeconds
(
30
))
.
isNotEmpty
();
.
getBody
().
getDetails
()).
isNotEmpty
();
});
});
}
}
...
@@ -165,8 +167,9 @@ public class ReactiveHealthEndpointWebExtensionTests {
...
@@ -165,8 +167,9 @@ public class ReactiveHealthEndpointWebExtensionTests {
ReactiveHealthEndpointWebExtension
extension
=
context
ReactiveHealthEndpointWebExtension
extension
=
context
.
getBean
(
ReactiveHealthEndpointWebExtension
.
class
);
.
getBean
(
ReactiveHealthEndpointWebExtension
.
class
);
SecurityContext
securityContext
=
mock
(
SecurityContext
.
class
);
SecurityContext
securityContext
=
mock
(
SecurityContext
.
class
);
assertThat
(
extension
.
health
(
securityContext
).
block
().
getBody
()
assertThat
(
extension
.
health
(
securityContext
)
.
getDetails
()).
isEmpty
();
.
block
(
Duration
.
ofSeconds
(
30
)).
getBody
().
getDetails
())
.
isEmpty
();
});
});
}
}
...
@@ -181,8 +184,9 @@ public class ReactiveHealthEndpointWebExtensionTests {
...
@@ -181,8 +184,9 @@ public class ReactiveHealthEndpointWebExtensionTests {
given
(
securityContext
.
getPrincipal
())
given
(
securityContext
.
getPrincipal
())
.
willReturn
(
mock
(
Principal
.
class
));
.
willReturn
(
mock
(
Principal
.
class
));
given
(
securityContext
.
isUserInRole
(
"ACTUATOR"
)).
willReturn
(
false
);
given
(
securityContext
.
isUserInRole
(
"ACTUATOR"
)).
willReturn
(
false
);
assertThat
(
extension
.
health
(
securityContext
).
block
().
getBody
()
assertThat
(
extension
.
health
(
securityContext
)
.
getDetails
()).
isEmpty
();
.
block
(
Duration
.
ofSeconds
(
30
)).
getBody
().
getDetails
())
.
isEmpty
();
});
});
}
}
...
@@ -197,8 +201,9 @@ public class ReactiveHealthEndpointWebExtensionTests {
...
@@ -197,8 +201,9 @@ public class ReactiveHealthEndpointWebExtensionTests {
given
(
securityContext
.
getPrincipal
())
given
(
securityContext
.
getPrincipal
())
.
willReturn
(
mock
(
Principal
.
class
));
.
willReturn
(
mock
(
Principal
.
class
));
given
(
securityContext
.
isUserInRole
(
"ACTUATOR"
)).
willReturn
(
true
);
given
(
securityContext
.
isUserInRole
(
"ACTUATOR"
)).
willReturn
(
true
);
assertThat
(
extension
.
health
(
securityContext
).
block
().
getBody
()
assertThat
(
extension
.
health
(
securityContext
)
.
getDetails
()).
isNotEmpty
();
.
block
(
Duration
.
ofSeconds
(
30
)).
getBody
().
getDetails
())
.
isNotEmpty
();
});
});
}
}
...
@@ -213,8 +218,9 @@ public class ReactiveHealthEndpointWebExtensionTests {
...
@@ -213,8 +218,9 @@ public class ReactiveHealthEndpointWebExtensionTests {
given
(
securityContext
.
getPrincipal
())
given
(
securityContext
.
getPrincipal
())
.
willReturn
(
mock
(
Principal
.
class
));
.
willReturn
(
mock
(
Principal
.
class
));
given
(
securityContext
.
isUserInRole
(
"ADMIN"
)).
willReturn
(
true
);
given
(
securityContext
.
isUserInRole
(
"ADMIN"
)).
willReturn
(
true
);
assertThat
(
extension
.
health
(
securityContext
).
block
().
getBody
()
assertThat
(
extension
.
health
(
securityContext
)
.
getDetails
()).
isNotEmpty
();
.
block
(
Duration
.
ofSeconds
(
30
)).
getBody
().
getDetails
())
.
isNotEmpty
();
});
});
}
}
...
@@ -227,11 +233,12 @@ public class ReactiveHealthEndpointWebExtensionTests {
...
@@ -227,11 +233,12 @@ public class ReactiveHealthEndpointWebExtensionTests {
.
getBean
(
ReactiveHealthIndicatorRegistry
.
class
);
.
getBean
(
ReactiveHealthIndicatorRegistry
.
class
);
ReactiveHealthEndpointWebExtension
extension
=
context
ReactiveHealthEndpointWebExtension
extension
=
context
.
getBean
(
ReactiveHealthEndpointWebExtension
.
class
);
.
getBean
(
ReactiveHealthEndpointWebExtension
.
class
);
assertThat
(
extension
.
health
(
null
).
block
().
getBody
().
getDetails
())
assertThat
(
extension
.
health
(
null
).
block
(
Duration
.
ofSeconds
(
30
))
.
containsOnlyKeys
(
"application"
,
"first"
,
"second"
);
.
getBody
().
getDetails
()).
containsOnlyKeys
(
"application"
,
"first"
,
"second"
);
assertThat
(
registry
.
unregister
(
"second"
)).
isNotNull
();
assertThat
(
registry
.
unregister
(
"second"
)).
isNotNull
();
assertThat
(
extension
.
health
(
null
).
block
(
).
getBody
().
getDetails
(
))
assertThat
(
extension
.
health
(
null
).
block
(
Duration
.
ofSeconds
(
30
))
.
containsKeys
(
"application"
,
"first"
);
.
getBody
().
getDetails
()).
containsKeys
(
"application"
,
"first"
);
});
});
}
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/client/WebClientMetricsConfigurationTests.java
View file @
3a7406fe
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
.
metrics
.
web
.
client
;
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
.
metrics
.
web
.
client
;
import
java.time.Duration
;
import
io.micrometer.core.instrument.MeterRegistry
;
import
io.micrometer.core.instrument.MeterRegistry
;
import
org.junit.Rule
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -106,7 +108,8 @@ public class WebClientMetricsConfigurationTests {
...
@@ -106,7 +108,8 @@ public class WebClientMetricsConfigurationTests {
WebClient
webClient
=
mockWebClient
(
context
.
getBean
(
WebClient
.
Builder
.
class
));
WebClient
webClient
=
mockWebClient
(
context
.
getBean
(
WebClient
.
Builder
.
class
));
MeterRegistry
registry
=
context
.
getBean
(
MeterRegistry
.
class
);
MeterRegistry
registry
=
context
.
getBean
(
MeterRegistry
.
class
);
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
webClient
.
get
().
uri
(
"http://example.org/projects/"
+
i
).
exchange
().
block
();
webClient
.
get
().
uri
(
"http://example.org/projects/"
+
i
).
exchange
()
.
block
(
Duration
.
ofSeconds
(
30
));
}
}
return
registry
;
return
registry
;
}
}
...
@@ -115,7 +118,7 @@ public class WebClientMetricsConfigurationTests {
...
@@ -115,7 +118,7 @@ public class WebClientMetricsConfigurationTests {
WebClient
webClient
=
mockWebClient
(
builder
);
WebClient
webClient
=
mockWebClient
(
builder
);
assertThat
(
registry
.
find
(
"http.client.requests"
).
meter
()).
isNull
();
assertThat
(
registry
.
find
(
"http.client.requests"
).
meter
()).
isNull
();
webClient
.
get
().
uri
(
"http://example.org/projects/{project}"
,
"spring-boot"
)
webClient
.
get
().
uri
(
"http://example.org/projects/{project}"
,
"spring-boot"
)
.
exchange
().
block
();
.
exchange
().
block
(
Duration
.
ofSeconds
(
30
)
);
assertThat
(
registry
.
find
(
"http.client.requests"
)
assertThat
(
registry
.
find
(
"http.client.requests"
)
.
tags
(
"uri"
,
"/projects/{project}"
).
meter
()).
isNotNull
();
.
tags
(
"uri"
,
"/projects/{project}"
).
meter
()).
isNotNull
();
}
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/reactive/EndpointRequestTests.java
View file @
3a7406fe
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
.
security
.
reactive
;
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
.
security
.
reactive
;
import
java.time.Duration
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -250,8 +251,8 @@ public class EndpointRequestTests {
...
@@ -250,8 +251,8 @@ public class EndpointRequestTests {
}
}
private
void
matches
(
ServerWebExchange
exchange
)
{
private
void
matches
(
ServerWebExchange
exchange
)
{
assertThat
(
this
.
matcher
.
matches
(
exchange
).
block
(
).
isMatch
(
))
assertThat
(
this
.
matcher
.
matches
(
exchange
).
block
(
Duration
.
ofSeconds
(
30
))
.
as
(
"Matches "
+
getRequestPath
(
exchange
)).
isTrue
();
.
isMatch
()).
as
(
"Matches "
+
getRequestPath
(
exchange
)).
isTrue
();
}
}
void
doesNotMatch
(
String
path
)
{
void
doesNotMatch
(
String
path
)
{
...
@@ -262,8 +263,9 @@ public class EndpointRequestTests {
...
@@ -262,8 +263,9 @@ public class EndpointRequestTests {
}
}
private
void
doesNotMatch
(
ServerWebExchange
exchange
)
{
private
void
doesNotMatch
(
ServerWebExchange
exchange
)
{
assertThat
(
this
.
matcher
.
matches
(
exchange
).
block
().
isMatch
())
assertThat
(
this
.
matcher
.
matches
(
exchange
).
block
(
Duration
.
ofSeconds
(
30
))
.
as
(
"Does not match "
+
getRequestPath
(
exchange
)).
isFalse
();
.
isMatch
()).
as
(
"Does not match "
+
getRequestPath
(
exchange
))
.
isFalse
();
}
}
private
TestHttpWebHandlerAdapter
webHandler
()
{
private
TestHttpWebHandlerAdapter
webHandler
()
{
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/reactive/ReactiveManagementWebSecurityAutoConfigurationTests.java
View file @
3a7406fe
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
.
security
.
reactive
;
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
.
security
.
reactive
;
import
java.net.URI
;
import
java.net.URI
;
import
java.time.Duration
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
...
@@ -139,7 +140,8 @@ public class ReactiveManagementWebSecurityAutoConfigurationTests {
...
@@ -139,7 +140,8 @@ public class ReactiveManagementWebSecurityAutoConfigurationTests {
ServerWebExchange
exchange
=
webHandler
(
context
).
createExchange
(
ServerWebExchange
exchange
=
webHandler
(
context
).
createExchange
(
MockServerHttpRequest
.
get
(
path
).
build
(),
new
MockServerHttpResponse
());
MockServerHttpRequest
.
get
(
path
).
build
(),
new
MockServerHttpResponse
());
WebFilterChainProxy
proxy
=
context
.
getBean
(
WebFilterChainProxy
.
class
);
WebFilterChainProxy
proxy
=
context
.
getBean
(
WebFilterChainProxy
.
class
);
proxy
.
filter
(
exchange
,
(
serverWebExchange
)
->
Mono
.
empty
()).
block
();
proxy
.
filter
(
exchange
,
(
serverWebExchange
)
->
Mono
.
empty
())
.
block
(
Duration
.
ofSeconds
(
30
));
return
exchange
;
return
exchange
;
}
}
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/couchbase/CouchbaseReactiveHealthIndicatorTests.java
View file @
3a7406fe
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
package
org
.
springframework
.
boot
.
actuate
.
couchbase
;
package
org
.
springframework
.
boot
.
actuate
.
couchbase
;
import
java.net.InetSocketAddress
;
import
java.net.InetSocketAddress
;
import
java.time.Duration
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -52,7 +53,7 @@ public class CouchbaseReactiveHealthIndicatorTests {
...
@@ -52,7 +53,7 @@ public class CouchbaseReactiveHealthIndicatorTests {
DiagnosticsReport
diagnostics
=
new
DiagnosticsReport
(
endpoints
,
"test-sdk"
,
DiagnosticsReport
diagnostics
=
new
DiagnosticsReport
(
endpoints
,
"test-sdk"
,
"test-id"
,
null
);
"test-id"
,
null
);
given
(
cluster
.
diagnostics
()).
willReturn
(
diagnostics
);
given
(
cluster
.
diagnostics
()).
willReturn
(
diagnostics
);
Health
health
=
healthIndicator
.
health
().
block
();
Health
health
=
healthIndicator
.
health
().
block
(
Duration
.
ofSeconds
(
30
)
);
assertThat
(
health
.
getStatus
()).
isEqualTo
(
Status
.
UP
);
assertThat
(
health
.
getStatus
()).
isEqualTo
(
Status
.
UP
);
assertThat
(
health
.
getDetails
()).
containsEntry
(
"sdk"
,
"test-sdk"
);
assertThat
(
health
.
getDetails
()).
containsEntry
(
"sdk"
,
"test-sdk"
);
assertThat
(
health
.
getDetails
()).
containsKey
(
"endpoints"
);
assertThat
(
health
.
getDetails
()).
containsKey
(
"endpoints"
);
...
@@ -77,7 +78,7 @@ public class CouchbaseReactiveHealthIndicatorTests {
...
@@ -77,7 +78,7 @@ public class CouchbaseReactiveHealthIndicatorTests {
DiagnosticsReport
diagnostics
=
new
DiagnosticsReport
(
endpoints
,
"test-sdk"
,
DiagnosticsReport
diagnostics
=
new
DiagnosticsReport
(
endpoints
,
"test-sdk"
,
"test-id"
,
null
);
"test-id"
,
null
);
given
(
cluster
.
diagnostics
()).
willReturn
(
diagnostics
);
given
(
cluster
.
diagnostics
()).
willReturn
(
diagnostics
);
Health
health
=
healthIndicator
.
health
().
block
();
Health
health
=
healthIndicator
.
health
().
block
(
Duration
.
ofSeconds
(
30
)
);
assertThat
(
health
.
getStatus
()).
isEqualTo
(
Status
.
DOWN
);
assertThat
(
health
.
getStatus
()).
isEqualTo
(
Status
.
DOWN
);
assertThat
(
health
.
getDetails
()).
containsEntry
(
"sdk"
,
"test-sdk"
);
assertThat
(
health
.
getDetails
()).
containsEntry
(
"sdk"
,
"test-sdk"
);
assertThat
(
health
.
getDetails
()).
containsKey
(
"endpoints"
);
assertThat
(
health
.
getDetails
()).
containsKey
(
"endpoints"
);
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/reactive/ControllerEndpointHandlerMappingTests.java
View file @
3a7406fe
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
package
org
.
springframework
.
boot
.
actuate
.
endpoint
.
web
.
reactive
;
package
org
.
springframework
.
boot
.
actuate
.
endpoint
.
web
.
reactive
;
import
java.time.Duration
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -95,7 +96,8 @@ public class ControllerEndpointHandlerMappingTests {
...
@@ -95,7 +96,8 @@ public class ControllerEndpointHandlerMappingTests {
private
Object
getHandler
(
ControllerEndpointHandlerMapping
mapping
,
HttpMethod
method
,
private
Object
getHandler
(
ControllerEndpointHandlerMapping
mapping
,
HttpMethod
method
,
String
requestURI
)
{
String
requestURI
)
{
return
mapping
.
getHandler
(
exchange
(
method
,
requestURI
)).
block
();
return
mapping
.
getHandler
(
exchange
(
method
,
requestURI
))
.
block
(
Duration
.
ofSeconds
(
30
));
}
}
private
ControllerEndpointHandlerMapping
createMapping
(
String
prefix
,
private
ControllerEndpointHandlerMapping
createMapping
(
String
prefix
,
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/client/MetricsWebClientFilterFunctionTests.java
View file @
3a7406fe
...
@@ -73,7 +73,7 @@ public class MetricsWebClientFilterFunctionTests {
...
@@ -73,7 +73,7 @@ public class MetricsWebClientFilterFunctionTests {
ClientRequest
request
=
ClientRequest
.
create
(
HttpMethod
.
GET
,
ClientRequest
request
=
ClientRequest
.
create
(
HttpMethod
.
GET
,
URI
.
create
(
"http://example.com/projects/spring-boot"
)).
build
();
URI
.
create
(
"http://example.com/projects/spring-boot"
)).
build
();
given
(
this
.
response
.
statusCode
()).
willReturn
(
HttpStatus
.
OK
);
given
(
this
.
response
.
statusCode
()).
willReturn
(
HttpStatus
.
OK
);
this
.
filterFunction
.
filter
(
request
,
this
.
exchange
).
block
();
this
.
filterFunction
.
filter
(
request
,
this
.
exchange
).
block
(
Duration
.
ofSeconds
(
30
)
);
assertThat
(
this
.
registry
.
get
(
"http.client.requests"
)
assertThat
(
this
.
registry
.
get
(
"http.client.requests"
)
.
tags
(
"method"
,
"GET"
,
"uri"
,
"/projects/spring-boot"
,
"status"
,
"200"
)
.
tags
(
"method"
,
"GET"
,
"uri"
,
"/projects/spring-boot"
,
"status"
,
"200"
)
.
timer
().
count
()).
isEqualTo
(
1
);
.
timer
().
count
()).
isEqualTo
(
1
);
...
@@ -86,7 +86,7 @@ public class MetricsWebClientFilterFunctionTests {
...
@@ -86,7 +86,7 @@ public class MetricsWebClientFilterFunctionTests {
URI
.
create
(
"http://example.com/projects/spring-boot"
))
URI
.
create
(
"http://example.com/projects/spring-boot"
))
.
attribute
(
URI_TEMPLATE_ATTRIBUTE
,
"/projects/{project}"
).
build
();
.
attribute
(
URI_TEMPLATE_ATTRIBUTE
,
"/projects/{project}"
).
build
();
given
(
this
.
response
.
statusCode
()).
willReturn
(
HttpStatus
.
OK
);
given
(
this
.
response
.
statusCode
()).
willReturn
(
HttpStatus
.
OK
);
this
.
filterFunction
.
filter
(
request
,
this
.
exchange
).
block
();
this
.
filterFunction
.
filter
(
request
,
this
.
exchange
).
block
(
Duration
.
ofSeconds
(
30
)
);
assertThat
(
this
.
registry
.
get
(
"http.client.requests"
)
assertThat
(
this
.
registry
.
get
(
"http.client.requests"
)
.
tags
(
"method"
,
"GET"
,
"uri"
,
"/projects/{project}"
,
"status"
,
"200"
)
.
tags
(
"method"
,
"GET"
,
"uri"
,
"/projects/{project}"
,
"status"
,
"200"
)
.
timer
().
count
()).
isEqualTo
(
1
);
.
timer
().
count
()).
isEqualTo
(
1
);
...
@@ -98,7 +98,8 @@ public class MetricsWebClientFilterFunctionTests {
...
@@ -98,7 +98,8 @@ public class MetricsWebClientFilterFunctionTests {
URI
.
create
(
"http://example.com/projects/spring-boot"
)).
build
();
URI
.
create
(
"http://example.com/projects/spring-boot"
)).
build
();
ExchangeFunction
errorExchange
=
(
r
)
->
Mono
.
error
(
new
IOException
());
ExchangeFunction
errorExchange
=
(
r
)
->
Mono
.
error
(
new
IOException
());
this
.
filterFunction
.
filter
(
request
,
errorExchange
)
this
.
filterFunction
.
filter
(
request
,
errorExchange
)
.
onErrorResume
(
IOException
.
class
,
(
t
)
->
Mono
.
empty
()).
block
();
.
onErrorResume
(
IOException
.
class
,
(
t
)
->
Mono
.
empty
())
.
block
(
Duration
.
ofSeconds
(
30
));
assertThat
(
assertThat
(
this
.
registry
this
.
registry
.
get
(
"http.client.requests"
).
tags
(
"method"
,
"GET"
,
"uri"
,
.
get
(
"http.client.requests"
).
tags
(
"method"
,
"GET"
,
"uri"
,
...
@@ -113,7 +114,7 @@ public class MetricsWebClientFilterFunctionTests {
...
@@ -113,7 +114,7 @@ public class MetricsWebClientFilterFunctionTests {
ExchangeFunction
exchange
=
(
r
)
->
Mono
.
error
(
new
IllegalArgumentException
());
ExchangeFunction
exchange
=
(
r
)
->
Mono
.
error
(
new
IllegalArgumentException
());
this
.
filterFunction
.
filter
(
request
,
exchange
)
this
.
filterFunction
.
filter
(
request
,
exchange
)
.
onErrorResume
(
IllegalArgumentException
.
class
,
(
t
)
->
Mono
.
empty
())
.
onErrorResume
(
IllegalArgumentException
.
class
,
(
t
)
->
Mono
.
empty
())
.
block
();
.
block
(
Duration
.
ofSeconds
(
30
)
);
assertThat
(
this
.
registry
assertThat
(
this
.
registry
.
get
(
"http.client.requests"
).
tags
(
"method"
,
"GET"
,
"uri"
,
.
get
(
"http.client.requests"
).
tags
(
"method"
,
"GET"
,
"uri"
,
"/projects/spring-boot"
,
"status"
,
"CLIENT_ERROR"
)
"/projects/spring-boot"
,
"status"
,
"CLIENT_ERROR"
)
...
@@ -128,7 +129,7 @@ public class MetricsWebClientFilterFunctionTests {
...
@@ -128,7 +129,7 @@ public class MetricsWebClientFilterFunctionTests {
.
delaySubscription
(
Duration
.
ofMillis
(
300
)).
cast
(
ClientResponse
.
class
);
.
delaySubscription
(
Duration
.
ofMillis
(
300
)).
cast
(
ClientResponse
.
class
);
this
.
filterFunction
.
filter
(
request
,
exchange
).
retry
(
1
)
this
.
filterFunction
.
filter
(
request
,
exchange
).
retry
(
1
)
.
onErrorResume
(
IllegalArgumentException
.
class
,
(
t
)
->
Mono
.
empty
())
.
onErrorResume
(
IllegalArgumentException
.
class
,
(
t
)
->
Mono
.
empty
())
.
block
();
.
block
(
Duration
.
ofSeconds
(
30
)
);
Timer
timer
=
this
.
registry
.
get
(
"http.client.requests"
).
tags
(
"method"
,
"GET"
,
Timer
timer
=
this
.
registry
.
get
(
"http.client.requests"
).
tags
(
"method"
,
"GET"
,
"uri"
,
"/projects/spring-boot"
,
"status"
,
"CLIENT_ERROR"
).
timer
();
"uri"
,
"/projects/spring-boot"
,
"status"
,
"CLIENT_ERROR"
).
timer
();
assertThat
(
timer
.
count
()).
isEqualTo
(
2
);
assertThat
(
timer
.
count
()).
isEqualTo
(
2
);
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/server/MetricsWebFilterTests.java
View file @
3a7406fe
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
package
org
.
springframework
.
boot
.
actuate
.
metrics
.
web
.
reactive
.
server
;
package
org
.
springframework
.
boot
.
actuate
.
metrics
.
web
.
reactive
.
server
;
import
java.time.Duration
;
import
io.micrometer.core.instrument.MockClock
;
import
io.micrometer.core.instrument.MockClock
;
import
io.micrometer.core.instrument.simple.SimpleConfig
;
import
io.micrometer.core.instrument.simple.SimpleConfig
;
import
io.micrometer.core.instrument.simple.SimpleMeterRegistry
;
import
io.micrometer.core.instrument.simple.SimpleMeterRegistry
;
...
@@ -58,7 +60,7 @@ public class MetricsWebFilterTests {
...
@@ -58,7 +60,7 @@ public class MetricsWebFilterTests {
this
.
webFilter
this
.
webFilter
.
filter
(
exchange
,
.
filter
(
exchange
,
(
serverWebExchange
)
->
exchange
.
getResponse
().
setComplete
())
(
serverWebExchange
)
->
exchange
.
getResponse
().
setComplete
())
.
block
();
.
block
(
Duration
.
ofSeconds
(
30
)
);
assertMetricsContainsTag
(
"uri"
,
"/projects/{project}"
);
assertMetricsContainsTag
(
"uri"
,
"/projects/{project}"
);
assertMetricsContainsTag
(
"status"
,
"200"
);
assertMetricsContainsTag
(
"status"
,
"200"
);
}
}
...
@@ -74,7 +76,7 @@ public class MetricsWebFilterTests {
...
@@ -74,7 +76,7 @@ public class MetricsWebFilterTests {
.
onErrorResume
((
t
)
->
{
.
onErrorResume
((
t
)
->
{
exchange
.
getResponse
().
setStatusCodeValue
(
500
);
exchange
.
getResponse
().
setStatusCodeValue
(
500
);
return
exchange
.
getResponse
().
setComplete
();
return
exchange
.
getResponse
().
setComplete
();
}).
block
();
}).
block
(
Duration
.
ofSeconds
(
30
)
);
assertMetricsContainsTag
(
"uri"
,
"/projects/{project}"
);
assertMetricsContainsTag
(
"uri"
,
"/projects/{project}"
);
assertMetricsContainsTag
(
"status"
,
"500"
);
assertMetricsContainsTag
(
"status"
,
"500"
);
assertMetricsContainsTag
(
"exception"
,
"IllegalStateException"
);
assertMetricsContainsTag
(
"exception"
,
"IllegalStateException"
);
...
@@ -91,7 +93,7 @@ public class MetricsWebFilterTests {
...
@@ -91,7 +93,7 @@ public class MetricsWebFilterTests {
.
onErrorResume
((
t
)
->
{
.
onErrorResume
((
t
)
->
{
exchange
.
getResponse
().
setStatusCodeValue
(
500
);
exchange
.
getResponse
().
setStatusCodeValue
(
500
);
return
exchange
.
getResponse
().
setComplete
();
return
exchange
.
getResponse
().
setComplete
();
}).
block
();
}).
block
(
Duration
.
ofSeconds
(
30
)
);
assertMetricsContainsTag
(
"uri"
,
"/projects/{project}"
);
assertMetricsContainsTag
(
"uri"
,
"/projects/{project}"
);
assertMetricsContainsTag
(
"status"
,
"500"
);
assertMetricsContainsTag
(
"status"
,
"500"
);
assertMetricsContainsTag
(
"exception"
,
anonymous
.
getClass
().
getName
());
assertMetricsContainsTag
(
"exception"
,
anonymous
.
getClass
().
getName
());
...
@@ -105,7 +107,7 @@ public class MetricsWebFilterTests {
...
@@ -105,7 +107,7 @@ public class MetricsWebFilterTests {
exchange
.
getResponse
().
setStatusCodeValue
(
500
);
exchange
.
getResponse
().
setStatusCodeValue
(
500
);
return
exchange
.
getResponse
().
setComplete
()
return
exchange
.
getResponse
().
setComplete
()
.
then
(
Mono
.
error
(
new
IllegalStateException
(
"test error"
)));
.
then
(
Mono
.
error
(
new
IllegalStateException
(
"test error"
)));
}).
onErrorResume
((
t
)
->
Mono
.
empty
()).
block
();
}).
onErrorResume
((
t
)
->
Mono
.
empty
()).
block
(
Duration
.
ofSeconds
(
30
)
);
assertMetricsContainsTag
(
"uri"
,
"/projects/{project}"
);
assertMetricsContainsTag
(
"uri"
,
"/projects/{project}"
);
assertMetricsContainsTag
(
"status"
,
"500"
);
assertMetricsContainsTag
(
"status"
,
"500"
);
}
}
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/trace/http/reactive/HttpTraceWebFilterTests.java
View file @
3a7406fe
...
@@ -18,6 +18,7 @@ package org.springframework.boot.actuate.trace.http.reactive;
...
@@ -18,6 +18,7 @@ package org.springframework.boot.actuate.trace.http.reactive;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.security.Principal
;
import
java.security.Principal
;
import
java.time.Duration
;
import
java.util.EnumSet
;
import
java.util.EnumSet
;
import
javax.servlet.ServletException
;
import
javax.servlet.ServletException
;
...
@@ -68,7 +69,7 @@ public class HttpTraceWebFilterTests {
...
@@ -68,7 +69,7 @@ public class HttpTraceWebFilterTests {
return
Mono
.
empty
();
return
Mono
.
empty
();
}
}
}).
block
();
}).
block
(
Duration
.
ofSeconds
(
30
)
);
assertThat
(
this
.
repository
.
findAll
()).
hasSize
(
1
);
assertThat
(
this
.
repository
.
findAll
()).
hasSize
(
1
);
}
}
...
@@ -82,11 +83,12 @@ public class HttpTraceWebFilterTests {
...
@@ -82,11 +83,12 @@ public class HttpTraceWebFilterTests {
@Override
@Override
public
Mono
<
Void
>
filter
(
ServerWebExchange
exchange
)
{
public
Mono
<
Void
>
filter
(
ServerWebExchange
exchange
)
{
exchange
.
getSession
().
block
().
getAttributes
().
put
(
"a"
,
"alpha"
);
exchange
.
getSession
().
block
(
Duration
.
ofSeconds
(
30
))
.
getAttributes
().
put
(
"a"
,
"alpha"
);
return
Mono
.
empty
();
return
Mono
.
empty
();
}
}
}).
block
();
}).
block
(
Duration
.
ofSeconds
(
30
)
);
assertThat
(
this
.
repository
.
findAll
()).
hasSize
(
1
);
assertThat
(
this
.
repository
.
findAll
()).
hasSize
(
1
);
Session
session
=
this
.
repository
.
findAll
().
get
(
0
).
getSession
();
Session
session
=
this
.
repository
.
findAll
().
get
(
0
).
getSession
();
assertThat
(
session
).
isNotNull
();
assertThat
(
session
).
isNotNull
();
...
@@ -103,11 +105,11 @@ public class HttpTraceWebFilterTests {
...
@@ -103,11 +105,11 @@ public class HttpTraceWebFilterTests {
@Override
@Override
public
Mono
<
Void
>
filter
(
ServerWebExchange
exchange
)
{
public
Mono
<
Void
>
filter
(
ServerWebExchange
exchange
)
{
exchange
.
getSession
().
block
();
exchange
.
getSession
().
block
(
Duration
.
ofSeconds
(
30
)
);
return
Mono
.
empty
();
return
Mono
.
empty
();
}
}
}).
block
();
}).
block
(
Duration
.
ofSeconds
(
30
)
);
assertThat
(
this
.
repository
.
findAll
()).
hasSize
(
1
);
assertThat
(
this
.
repository
.
findAll
()).
hasSize
(
1
);
Session
session
=
this
.
repository
.
findAll
().
get
(
0
).
getSession
();
Session
session
=
this
.
repository
.
findAll
().
get
(
0
).
getSession
();
assertThat
(
session
).
isNull
();
assertThat
(
session
).
isNull
();
...
@@ -129,11 +131,12 @@ public class HttpTraceWebFilterTests {
...
@@ -129,11 +131,12 @@ public class HttpTraceWebFilterTests {
@Override
@Override
public
Mono
<
Void
>
filter
(
ServerWebExchange
exchange
)
{
public
Mono
<
Void
>
filter
(
ServerWebExchange
exchange
)
{
exchange
.
getSession
().
block
().
getAttributes
().
put
(
"a"
,
"alpha"
);
exchange
.
getSession
().
block
(
Duration
.
ofSeconds
(
30
)).
getAttributes
()
.
put
(
"a"
,
"alpha"
);
return
Mono
.
empty
();
return
Mono
.
empty
();
}
}
}).
block
();
}).
block
(
Duration
.
ofSeconds
(
30
)
);
assertThat
(
this
.
repository
.
findAll
()).
hasSize
(
1
);
assertThat
(
this
.
repository
.
findAll
()).
hasSize
(
1
);
org
.
springframework
.
boot
.
actuate
.
trace
.
http
.
HttpTrace
.
Principal
tracedPrincipal
=
this
.
repository
org
.
springframework
.
boot
.
actuate
.
trace
.
http
.
HttpTrace
.
Principal
tracedPrincipal
=
this
.
repository
.
findAll
().
get
(
0
).
getPrincipal
();
.
findAll
().
get
(
0
).
getPrincipal
();
...
@@ -155,7 +158,7 @@ public class HttpTraceWebFilterTests {
...
@@ -155,7 +158,7 @@ public class HttpTraceWebFilterTests {
return
Mono
.
error
(
new
RuntimeException
());
return
Mono
.
error
(
new
RuntimeException
());
}
}
}).
block
();
}).
block
(
Duration
.
ofSeconds
(
30
)
);
fail
();
fail
();
}
}
catch
(
Exception
ex
)
{
catch
(
Exception
ex
)
{
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationReactiveIntegrationTests.java
View file @
3a7406fe
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
freemarker
;
package
org
.
springframework
.
boot
.
autoconfigure
.
freemarker
;
import
java.io.StringWriter
;
import
java.io.StringWriter
;
import
java.time.Duration
;
import
java.util.Locale
;
import
java.util.Locale
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -60,7 +61,8 @@ public class FreeMarkerAutoConfigurationReactiveIntegrationTests {
...
@@ -60,7 +61,8 @@ public class FreeMarkerAutoConfigurationReactiveIntegrationTests {
public
void
defaultViewResolution
()
{
public
void
defaultViewResolution
()
{
this
.
contextRunner
.
run
((
context
)
->
{
this
.
contextRunner
.
run
((
context
)
->
{
MockServerWebExchange
exchange
=
render
(
context
,
"home"
);
MockServerWebExchange
exchange
=
render
(
context
,
"home"
);
String
result
=
exchange
.
getResponse
().
getBodyAsString
().
block
();
String
result
=
exchange
.
getResponse
().
getBodyAsString
()
.
block
(
Duration
.
ofSeconds
(
30
));
assertThat
(
result
).
contains
(
"home"
);
assertThat
(
result
).
contains
(
"home"
);
assertThat
(
exchange
.
getResponse
().
getHeaders
().
getContentType
())
assertThat
(
exchange
.
getResponse
().
getHeaders
().
getContentType
())
.
isEqualTo
(
MediaType
.
TEXT_HTML
);
.
isEqualTo
(
MediaType
.
TEXT_HTML
);
...
@@ -72,7 +74,8 @@ public class FreeMarkerAutoConfigurationReactiveIntegrationTests {
...
@@ -72,7 +74,8 @@ public class FreeMarkerAutoConfigurationReactiveIntegrationTests {
this
.
contextRunner
.
withPropertyValues
(
"spring.freemarker.prefix:prefix/"
)
this
.
contextRunner
.
withPropertyValues
(
"spring.freemarker.prefix:prefix/"
)
.
run
((
context
)
->
{
.
run
((
context
)
->
{
MockServerWebExchange
exchange
=
render
(
context
,
"prefixed"
);
MockServerWebExchange
exchange
=
render
(
context
,
"prefixed"
);
String
result
=
exchange
.
getResponse
().
getBodyAsString
().
block
();
String
result
=
exchange
.
getResponse
().
getBodyAsString
()
.
block
(
Duration
.
ofSeconds
(
30
));
assertThat
(
result
).
contains
(
"prefixed"
);
assertThat
(
result
).
contains
(
"prefixed"
);
});
});
}
}
...
@@ -82,7 +85,8 @@ public class FreeMarkerAutoConfigurationReactiveIntegrationTests {
...
@@ -82,7 +85,8 @@ public class FreeMarkerAutoConfigurationReactiveIntegrationTests {
this
.
contextRunner
.
withPropertyValues
(
"spring.freemarker.suffix:.freemarker"
)
this
.
contextRunner
.
withPropertyValues
(
"spring.freemarker.suffix:.freemarker"
)
.
run
((
context
)
->
{
.
run
((
context
)
->
{
MockServerWebExchange
exchange
=
render
(
context
,
"suffixed"
);
MockServerWebExchange
exchange
=
render
(
context
,
"suffixed"
);
String
result
=
exchange
.
getResponse
().
getBodyAsString
().
block
();
String
result
=
exchange
.
getResponse
().
getBodyAsString
()
.
block
(
Duration
.
ofSeconds
(
30
));
assertThat
(
result
).
contains
(
"suffixed"
);
assertThat
(
result
).
contains
(
"suffixed"
);
});
});
}
}
...
@@ -93,7 +97,8 @@ public class FreeMarkerAutoConfigurationReactiveIntegrationTests {
...
@@ -93,7 +97,8 @@ public class FreeMarkerAutoConfigurationReactiveIntegrationTests {
"spring.freemarker.templateLoaderPath:classpath:/custom-templates/"
)
"spring.freemarker.templateLoaderPath:classpath:/custom-templates/"
)
.
run
((
context
)
->
{
.
run
((
context
)
->
{
MockServerWebExchange
exchange
=
render
(
context
,
"custom"
);
MockServerWebExchange
exchange
=
render
(
context
,
"custom"
);
String
result
=
exchange
.
getResponse
().
getBodyAsString
().
block
();
String
result
=
exchange
.
getResponse
().
getBodyAsString
()
.
block
(
Duration
.
ofSeconds
(
30
));
assertThat
(
result
).
contains
(
"custom"
);
assertThat
(
result
).
contains
(
"custom"
);
});
});
}
}
...
@@ -128,7 +133,8 @@ public class FreeMarkerAutoConfigurationReactiveIntegrationTests {
...
@@ -128,7 +133,8 @@ public class FreeMarkerAutoConfigurationReactiveIntegrationTests {
Mono
<
View
>
view
=
resolver
.
resolveViewName
(
viewName
,
Locale
.
UK
);
Mono
<
View
>
view
=
resolver
.
resolveViewName
(
viewName
,
Locale
.
UK
);
MockServerWebExchange
exchange
=
MockServerWebExchange
MockServerWebExchange
exchange
=
MockServerWebExchange
.
from
(
MockServerHttpRequest
.
get
(
"/path"
));
.
from
(
MockServerHttpRequest
.
get
(
"/path"
));
view
.
flatMap
((
v
)
->
v
.
render
(
null
,
MediaType
.
TEXT_HTML
,
exchange
)).
block
();
view
.
flatMap
((
v
)
->
v
.
render
(
null
,
MediaType
.
TEXT_HTML
,
exchange
))
.
block
(
Duration
.
ofSeconds
(
30
));
return
exchange
;
return
exchange
;
}
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/client/reactive/ReactiveOAuth2ClientAutoConfigurationTests.java
View file @
3a7406fe
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
*/
*/
package
org
.
springframework
.
boot
.
autoconfigure
.
security
.
oauth2
.
client
.
reactive
;
package
org
.
springframework
.
boot
.
autoconfigure
.
security
.
oauth2
.
client
.
reactive
;
import
java.time.Duration
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -77,7 +78,7 @@ public class ReactiveOAuth2ClientAutoConfigurationTests {
...
@@ -77,7 +78,7 @@ public class ReactiveOAuth2ClientAutoConfigurationTests {
ReactiveClientRegistrationRepository
repository
=
context
ReactiveClientRegistrationRepository
repository
=
context
.
getBean
(
ReactiveClientRegistrationRepository
.
class
);
.
getBean
(
ReactiveClientRegistrationRepository
.
class
);
ClientRegistration
registration
=
repository
ClientRegistration
registration
=
repository
.
findByRegistrationId
(
"foo"
).
block
();
.
findByRegistrationId
(
"foo"
).
block
(
Duration
.
ofSeconds
(
30
)
);
assertThat
(
registration
).
isNotNull
();
assertThat
(
registration
).
isNotNull
();
assertThat
(
registration
.
getClientSecret
()).
isEqualTo
(
"secret"
);
assertThat
(
registration
.
getClientSecret
()).
isEqualTo
(
"secret"
);
});
});
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/reactive/ReactiveUserDetailsServiceAutoConfigurationTests.java
View file @
3a7406fe
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
security
.
reactive
;
package
org
.
springframework
.
boot
.
autoconfigure
.
security
.
reactive
;
import
java.time.Duration
;
import
org.junit.Test
;
import
org.junit.Test
;
import
reactor.core.publisher.Mono
;
import
reactor.core.publisher.Mono
;
...
@@ -55,8 +57,8 @@ public class ReactiveUserDetailsServiceAutoConfigurationTests {
...
@@ -55,8 +57,8 @@ public class ReactiveUserDetailsServiceAutoConfigurationTests {
.
run
((
context
)
->
{
.
run
((
context
)
->
{
ReactiveUserDetailsService
userDetailsService
=
context
ReactiveUserDetailsService
userDetailsService
=
context
.
getBean
(
ReactiveUserDetailsService
.
class
);
.
getBean
(
ReactiveUserDetailsService
.
class
);
assertThat
(
userDetailsService
.
findByUsername
(
"user"
)
.
block
())
assertThat
(
userDetailsService
.
findByUsername
(
"user"
)
.
isNotNull
();
.
block
(
Duration
.
ofSeconds
(
30
))).
isNotNull
();
});
});
}
}
...
@@ -67,12 +69,12 @@ public class ReactiveUserDetailsServiceAutoConfigurationTests {
...
@@ -67,12 +69,12 @@ public class ReactiveUserDetailsServiceAutoConfigurationTests {
.
run
((
context
)
->
{
.
run
((
context
)
->
{
ReactiveUserDetailsService
userDetailsService
=
context
ReactiveUserDetailsService
userDetailsService
=
context
.
getBean
(
ReactiveUserDetailsService
.
class
);
.
getBean
(
ReactiveUserDetailsService
.
class
);
assertThat
(
userDetailsService
.
findByUsername
(
"user"
)
.
block
())
assertThat
(
userDetailsService
.
findByUsername
(
"user"
)
.
isNull
();
.
block
(
Duration
.
ofSeconds
(
30
))).
isNull
();
assertThat
(
userDetailsService
.
findByUsername
(
"foo"
)
.
block
())
assertThat
(
userDetailsService
.
findByUsername
(
"foo"
)
.
isNotNull
();
.
block
(
Duration
.
ofSeconds
(
30
))).
isNotNull
();
assertThat
(
userDetailsService
.
findByUsername
(
"admin"
)
.
block
())
assertThat
(
userDetailsService
.
findByUsername
(
"admin"
)
.
isNotNull
();
.
block
(
Duration
.
ofSeconds
(
30
))).
isNotNull
();
});
});
}
}
...
@@ -93,8 +95,8 @@ public class ReactiveUserDetailsServiceAutoConfigurationTests {
...
@@ -93,8 +95,8 @@ public class ReactiveUserDetailsServiceAutoConfigurationTests {
.
run
(((
context
)
->
{
.
run
(((
context
)
->
{
MapReactiveUserDetailsService
userDetailsService
=
context
MapReactiveUserDetailsService
userDetailsService
=
context
.
getBean
(
MapReactiveUserDetailsService
.
class
);
.
getBean
(
MapReactiveUserDetailsService
.
class
);
String
password
=
userDetailsService
.
findByUsername
(
"user"
)
.
block
()
String
password
=
userDetailsService
.
findByUsername
(
"user"
)
.
getPassword
();
.
block
(
Duration
.
ofSeconds
(
30
)).
getPassword
();
assertThat
(
password
).
startsWith
(
"{noop}"
);
assertThat
(
password
).
startsWith
(
"{noop}"
);
}));
}));
}
}
...
@@ -122,8 +124,8 @@ public class ReactiveUserDetailsServiceAutoConfigurationTests {
...
@@ -122,8 +124,8 @@ public class ReactiveUserDetailsServiceAutoConfigurationTests {
.
run
(((
context
)
->
{
.
run
(((
context
)
->
{
MapReactiveUserDetailsService
userDetailsService
=
context
MapReactiveUserDetailsService
userDetailsService
=
context
.
getBean
(
MapReactiveUserDetailsService
.
class
);
.
getBean
(
MapReactiveUserDetailsService
.
class
);
String
password
=
userDetailsService
.
findByUsername
(
"user"
)
.
block
()
String
password
=
userDetailsService
.
findByUsername
(
"user"
)
.
getPassword
();
.
block
(
Duration
.
ofSeconds
(
30
)).
getPassword
();
assertThat
(
password
).
isEqualTo
(
expectedPassword
);
assertThat
(
password
).
isEqualTo
(
expectedPassword
);
}));
}));
}
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/reactive/StaticResourceRequestTests.java
View file @
3a7406fe
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
security
.
reactive
;
package
org
.
springframework
.
boot
.
autoconfigure
.
security
.
reactive
;
import
java.time.Duration
;
import
org.assertj.core.api.AssertDelegateTarget
;
import
org.assertj.core.api.AssertDelegateTarget
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -113,8 +115,8 @@ public class StaticResourceRequestTests {
...
@@ -113,8 +115,8 @@ public class StaticResourceRequestTests {
}
}
private
void
matches
(
ServerWebExchange
exchange
)
{
private
void
matches
(
ServerWebExchange
exchange
)
{
assertThat
(
this
.
matcher
.
matches
(
exchange
).
block
(
).
isMatch
(
))
assertThat
(
this
.
matcher
.
matches
(
exchange
).
block
(
Duration
.
ofSeconds
(
30
))
.
as
(
"Matches "
+
getRequestPath
(
exchange
)).
isTrue
();
.
isMatch
()).
as
(
"Matches "
+
getRequestPath
(
exchange
)).
isTrue
();
}
}
void
doesNotMatch
(
String
path
)
{
void
doesNotMatch
(
String
path
)
{
...
@@ -125,8 +127,9 @@ public class StaticResourceRequestTests {
...
@@ -125,8 +127,9 @@ public class StaticResourceRequestTests {
}
}
private
void
doesNotMatch
(
ServerWebExchange
exchange
)
{
private
void
doesNotMatch
(
ServerWebExchange
exchange
)
{
assertThat
(
this
.
matcher
.
matches
(
exchange
).
block
().
isMatch
())
assertThat
(
this
.
matcher
.
matches
(
exchange
).
block
(
Duration
.
ofSeconds
(
30
))
.
as
(
"Does not match "
+
getRequestPath
(
exchange
)).
isFalse
();
.
isMatch
()).
as
(
"Does not match "
+
getRequestPath
(
exchange
))
.
isFalse
();
}
}
private
TestHttpWebHandlerAdapter
webHandler
()
{
private
TestHttpWebHandlerAdapter
webHandler
()
{
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/function/client/WebClientAutoConfigurationTests.java
View file @
3a7406fe
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
web
.
reactive
.
function
.
client
;
package
org
.
springframework
.
boot
.
autoconfigure
.
web
.
reactive
.
function
.
client
;
import
java.net.URI
;
import
java.net.URI
;
import
java.time.Duration
;
import
org.junit.Test
;
import
org.junit.Test
;
import
reactor.core.publisher.Mono
;
import
reactor.core.publisher.Mono
;
...
@@ -109,8 +110,10 @@ public class WebClientAutoConfigurationTests {
...
@@ -109,8 +110,10 @@ public class WebClientAutoConfigurationTests {
secondBuilder
.
clientConnector
(
secondConnector
)
secondBuilder
.
clientConnector
(
secondConnector
)
.
baseUrl
(
"http://second.example.org"
);
.
baseUrl
(
"http://second.example.org"
);
assertThat
(
firstBuilder
).
isNotEqualTo
(
secondBuilder
);
assertThat
(
firstBuilder
).
isNotEqualTo
(
secondBuilder
);
firstBuilder
.
build
().
get
().
uri
(
"/foo"
).
exchange
().
block
();
firstBuilder
.
build
().
get
().
uri
(
"/foo"
).
exchange
()
secondBuilder
.
build
().
get
().
uri
(
"/foo"
).
exchange
().
block
();
.
block
(
Duration
.
ofSeconds
(
30
));
secondBuilder
.
build
().
get
().
uri
(
"/foo"
).
exchange
()
.
block
(
Duration
.
ofSeconds
(
30
));
verify
(
firstConnector
).
connect
(
eq
(
HttpMethod
.
GET
),
verify
(
firstConnector
).
connect
(
eq
(
HttpMethod
.
GET
),
eq
(
URI
.
create
(
"http://first.example.org/foo"
)),
any
());
eq
(
URI
.
create
(
"http://first.example.org/foo"
)),
any
());
verify
(
secondConnector
).
connect
(
eq
(
HttpMethod
.
GET
),
verify
(
secondConnector
).
connect
(
eq
(
HttpMethod
.
GET
),
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/mongo/DataMongoTestReactiveIntegrationTests.java
View file @
3a7406fe
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
package
org
.
springframework
.
boot
.
test
.
autoconfigure
.
data
.
mongo
;
package
org
.
springframework
.
boot
.
test
.
autoconfigure
.
data
.
mongo
;
import
java.time.Duration
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
...
@@ -44,10 +46,11 @@ public class DataMongoTestReactiveIntegrationTests {
...
@@ -44,10 +46,11 @@ public class DataMongoTestReactiveIntegrationTests {
public
void
testRepository
()
{
public
void
testRepository
()
{
ExampleDocument
exampleDocument
=
new
ExampleDocument
();
ExampleDocument
exampleDocument
=
new
ExampleDocument
();
exampleDocument
.
setText
(
"Look, new @DataMongoTest!"
);
exampleDocument
.
setText
(
"Look, new @DataMongoTest!"
);
exampleDocument
=
this
.
exampleRepository
.
save
(
exampleDocument
).
block
();
exampleDocument
=
this
.
exampleRepository
.
save
(
exampleDocument
)
.
block
(
Duration
.
ofSeconds
(
30
));
assertThat
(
exampleDocument
.
getId
()).
isNotNull
();
assertThat
(
exampleDocument
.
getId
()).
isNotNull
();
assertThat
(
this
.
mongoTemplate
.
collectionExists
(
"exampleDocuments"
)
.
block
())
assertThat
(
this
.
mongoTemplate
.
collectionExists
(
"exampleDocuments"
)
.
isTrue
();
.
block
(
Duration
.
ofSeconds
(
30
))).
isTrue
();
}
}
}
}
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/undertow/UndertowReactiveWebServerFactoryTests.java
View file @
3a7406fe
...
@@ -19,6 +19,7 @@ package org.springframework.boot.web.embedded.undertow;
...
@@ -19,6 +19,7 @@ package org.springframework.boot.web.embedded.undertow;
import
java.io.File
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.net.URISyntaxException
;
import
java.net.URISyntaxException
;
import
java.time.Duration
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
io.undertow.Undertow
;
import
io.undertow.Undertow
;
...
@@ -122,7 +123,7 @@ public class UndertowReactiveWebServerFactoryTests
...
@@ -122,7 +123,7 @@ public class UndertowReactiveWebServerFactoryTests
Mono
<
String
>
result
=
client
.
post
().
uri
(
"/test"
).
contentType
(
MediaType
.
TEXT_PLAIN
)
Mono
<
String
>
result
=
client
.
post
().
uri
(
"/test"
).
contentType
(
MediaType
.
TEXT_PLAIN
)
.
body
(
BodyInserters
.
fromObject
(
"Hello World"
)).
exchange
()
.
body
(
BodyInserters
.
fromObject
(
"Hello World"
)).
exchange
()
.
flatMap
((
response
)
->
response
.
bodyToMono
(
String
.
class
));
.
flatMap
((
response
)
->
response
.
bodyToMono
(
String
.
class
));
assertThat
(
result
.
block
()).
isEqualTo
(
"Hello World"
);
assertThat
(
result
.
block
(
Duration
.
ofSeconds
(
30
)
)).
isEqualTo
(
"Hello World"
);
File
accessLog
=
new
File
(
accessLogDirectory
,
expectedFile
);
File
accessLog
=
new
File
(
accessLogDirectory
,
expectedFile
);
awaitFile
(
accessLog
);
awaitFile
(
accessLog
);
assertThat
(
accessLogDirectory
.
listFiles
()).
contains
(
accessLog
);
assertThat
(
accessLogDirectory
.
listFiles
()).
contains
(
accessLog
);
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/result/view/MustacheViewResolverTests.java
View file @
3a7406fe
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
package
org
.
springframework
.
boot
.
web
.
reactive
.
result
.
view
;
package
org
.
springframework
.
boot
.
web
.
reactive
.
result
.
view
;
import
java.time.Duration
;
import
org.junit.Before
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -46,12 +48,15 @@ public class MustacheViewResolverTests {
...
@@ -46,12 +48,15 @@ public class MustacheViewResolverTests {
@Test
@Test
public
void
resolveNonExistent
()
{
public
void
resolveNonExistent
()
{
assertThat
(
this
.
resolver
.
resolveViewName
(
"bar"
,
null
).
block
()).
isNull
();
assertThat
(
this
.
resolver
.
resolveViewName
(
"bar"
,
null
).
block
(
Duration
.
ofSeconds
(
30
)))
.
isNull
();
}
}
@Test
@Test
public
void
resolveExisting
()
{
public
void
resolveExisting
()
{
assertThat
(
this
.
resolver
.
resolveViewName
(
"template"
,
null
).
block
()).
isNotNull
();
assertThat
(
this
.
resolver
.
resolveViewName
(
"template"
,
null
)
.
block
(
Duration
.
ofSeconds
(
30
))).
isNotNull
();
}
}
}
}
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/result/view/MustacheViewTests.java
View file @
3a7406fe
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
package
org
.
springframework
.
boot
.
web
.
reactive
.
result
.
view
;
package
org
.
springframework
.
boot
.
web
.
reactive
.
result
.
view
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.charset.StandardCharsets
;
import
java.time.Duration
;
import
java.util.Collections
;
import
java.util.Collections
;
import
com.samskivert.mustache.Mustache
;
import
com.samskivert.mustache.Mustache
;
...
@@ -59,9 +60,9 @@ public class MustacheViewTests {
...
@@ -59,9 +60,9 @@ public class MustacheViewTests {
view
.
setCharset
(
StandardCharsets
.
UTF_8
.
displayName
());
view
.
setCharset
(
StandardCharsets
.
UTF_8
.
displayName
());
view
.
setApplicationContext
(
this
.
context
);
view
.
setApplicationContext
(
this
.
context
);
view
.
render
(
Collections
.
singletonMap
(
"World"
,
"Spring"
),
MediaType
.
TEXT_HTML
,
view
.
render
(
Collections
.
singletonMap
(
"World"
,
"Spring"
),
MediaType
.
TEXT_HTML
,
this
.
exchange
).
block
();
this
.
exchange
).
block
(
Duration
.
ofSeconds
(
30
)
);
assertThat
(
this
.
exchange
.
getResponse
().
getBodyAsString
()
.
block
())
assertThat
(
this
.
exchange
.
getResponse
().
getBodyAsString
()
.
isEqualTo
(
"Hello Spring"
);
.
block
(
Duration
.
ofSeconds
(
30
))).
isEqualTo
(
"Hello Spring"
);
}
}
}
}
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/server/AbstractReactiveWebServerFactoryTests.java
View file @
3a7406fe
...
@@ -100,7 +100,7 @@ public abstract class AbstractReactiveWebServerFactoryTests {
...
@@ -100,7 +100,7 @@ public abstract class AbstractReactiveWebServerFactoryTests {
.
contentType
(
MediaType
.
TEXT_PLAIN
)
.
contentType
(
MediaType
.
TEXT_PLAIN
)
.
body
(
BodyInserters
.
fromObject
(
"Hello World"
)).
exchange
()
.
body
(
BodyInserters
.
fromObject
(
"Hello World"
)).
exchange
()
.
flatMap
((
response
)
->
response
.
bodyToMono
(
String
.
class
));
.
flatMap
((
response
)
->
response
.
bodyToMono
(
String
.
class
));
assertThat
(
result
.
block
()).
isEqualTo
(
"Hello World"
);
assertThat
(
result
.
block
(
Duration
.
ofSeconds
(
30
)
)).
isEqualTo
(
"Hello World"
);
assertThat
(
this
.
webServer
.
getPort
()).
isEqualTo
(
specificPort
);
assertThat
(
this
.
webServer
.
getPort
()).
isEqualTo
(
specificPort
);
}
}
...
@@ -129,7 +129,7 @@ public abstract class AbstractReactiveWebServerFactoryTests {
...
@@ -129,7 +129,7 @@ public abstract class AbstractReactiveWebServerFactoryTests {
Mono
<
String
>
result
=
client
.
post
().
uri
(
"/test"
).
contentType
(
MediaType
.
TEXT_PLAIN
)
Mono
<
String
>
result
=
client
.
post
().
uri
(
"/test"
).
contentType
(
MediaType
.
TEXT_PLAIN
)
.
body
(
BodyInserters
.
fromObject
(
"Hello World"
)).
exchange
()
.
body
(
BodyInserters
.
fromObject
(
"Hello World"
)).
exchange
()
.
flatMap
((
response
)
->
response
.
bodyToMono
(
String
.
class
));
.
flatMap
((
response
)
->
response
.
bodyToMono
(
String
.
class
));
assertThat
(
result
.
block
()).
isEqualTo
(
"Hello World"
);
assertThat
(
result
.
block
(
Duration
.
ofSeconds
(
30
)
)).
isEqualTo
(
"Hello World"
);
}
}
protected
ReactorClientHttpConnector
buildTrustAllSslConnector
()
{
protected
ReactorClientHttpConnector
buildTrustAllSslConnector
()
{
...
@@ -191,7 +191,7 @@ public abstract class AbstractReactiveWebServerFactoryTests {
...
@@ -191,7 +191,7 @@ public abstract class AbstractReactiveWebServerFactoryTests {
Mono
<
String
>
result
=
client
.
post
().
uri
(
"/test"
).
contentType
(
MediaType
.
TEXT_PLAIN
)
Mono
<
String
>
result
=
client
.
post
().
uri
(
"/test"
).
contentType
(
MediaType
.
TEXT_PLAIN
)
.
body
(
BodyInserters
.
fromObject
(
"Hello World"
)).
exchange
()
.
body
(
BodyInserters
.
fromObject
(
"Hello World"
)).
exchange
()
.
flatMap
((
response
)
->
response
.
bodyToMono
(
String
.
class
));
.
flatMap
((
response
)
->
response
.
bodyToMono
(
String
.
class
));
assertThat
(
result
.
block
()).
isEqualTo
(
"Hello World"
);
assertThat
(
result
.
block
(
Duration
.
ofSeconds
(
30
)
)).
isEqualTo
(
"Hello World"
);
}
}
@Test
@Test
...
@@ -246,7 +246,7 @@ public abstract class AbstractReactiveWebServerFactoryTests {
...
@@ -246,7 +246,7 @@ public abstract class AbstractReactiveWebServerFactoryTests {
public
void
compressionOfResponseToGetRequest
()
{
public
void
compressionOfResponseToGetRequest
()
{
WebClient
client
=
prepareCompressionTest
();
WebClient
client
=
prepareCompressionTest
();
ResponseEntity
<
Void
>
response
=
client
.
get
().
exchange
()
ResponseEntity
<
Void
>
response
=
client
.
get
().
exchange
()
.
flatMap
((
res
)
->
res
.
toEntity
(
Void
.
class
)).
block
();
.
flatMap
((
res
)
->
res
.
toEntity
(
Void
.
class
)).
block
(
Duration
.
ofSeconds
(
30
)
);
assertResponseIsCompressed
(
response
);
assertResponseIsCompressed
(
response
);
}
}
...
@@ -254,7 +254,7 @@ public abstract class AbstractReactiveWebServerFactoryTests {
...
@@ -254,7 +254,7 @@ public abstract class AbstractReactiveWebServerFactoryTests {
public
void
compressionOfResponseToPostRequest
()
{
public
void
compressionOfResponseToPostRequest
()
{
WebClient
client
=
prepareCompressionTest
();
WebClient
client
=
prepareCompressionTest
();
ResponseEntity
<
Void
>
response
=
client
.
post
().
exchange
()
ResponseEntity
<
Void
>
response
=
client
.
post
().
exchange
()
.
flatMap
((
res
)
->
res
.
toEntity
(
Void
.
class
)).
block
();
.
flatMap
((
res
)
->
res
.
toEntity
(
Void
.
class
)).
block
(
Duration
.
ofSeconds
(
30
)
);
assertResponseIsCompressed
(
response
);
assertResponseIsCompressed
(
response
);
}
}
...
@@ -265,7 +265,7 @@ public abstract class AbstractReactiveWebServerFactoryTests {
...
@@ -265,7 +265,7 @@ public abstract class AbstractReactiveWebServerFactoryTests {
compression
.
setMinResponseSize
(
DataSize
.
ofBytes
(
3001
));
compression
.
setMinResponseSize
(
DataSize
.
ofBytes
(
3001
));
WebClient
client
=
prepareCompressionTest
(
compression
);
WebClient
client
=
prepareCompressionTest
(
compression
);
ResponseEntity
<
Void
>
response
=
client
.
get
().
exchange
()
ResponseEntity
<
Void
>
response
=
client
.
get
().
exchange
()
.
flatMap
((
res
)
->
res
.
toEntity
(
Void
.
class
)).
block
();
.
flatMap
((
res
)
->
res
.
toEntity
(
Void
.
class
)).
block
(
Duration
.
ofSeconds
(
30
)
);
assertResponseIsNotCompressed
(
response
);
assertResponseIsNotCompressed
(
response
);
}
}
...
@@ -275,7 +275,7 @@ public abstract class AbstractReactiveWebServerFactoryTests {
...
@@ -275,7 +275,7 @@ public abstract class AbstractReactiveWebServerFactoryTests {
compression
.
setMimeTypes
(
new
String
[]
{
"application/json"
});
compression
.
setMimeTypes
(
new
String
[]
{
"application/json"
});
WebClient
client
=
prepareCompressionTest
(
compression
);
WebClient
client
=
prepareCompressionTest
(
compression
);
ResponseEntity
<
Void
>
response
=
client
.
get
().
exchange
()
ResponseEntity
<
Void
>
response
=
client
.
get
().
exchange
()
.
flatMap
((
res
)
->
res
.
toEntity
(
Void
.
class
)).
block
();
.
flatMap
((
res
)
->
res
.
toEntity
(
Void
.
class
)).
block
(
Duration
.
ofSeconds
(
30
)
);
assertResponseIsNotCompressed
(
response
);
assertResponseIsNotCompressed
(
response
);
}
}
...
@@ -286,7 +286,8 @@ public abstract class AbstractReactiveWebServerFactoryTests {
...
@@ -286,7 +286,8 @@ public abstract class AbstractReactiveWebServerFactoryTests {
compression
.
setExcludedUserAgents
(
new
String
[]
{
"testUserAgent"
});
compression
.
setExcludedUserAgents
(
new
String
[]
{
"testUserAgent"
});
WebClient
client
=
prepareCompressionTest
(
compression
);
WebClient
client
=
prepareCompressionTest
(
compression
);
ResponseEntity
<
Void
>
response
=
client
.
get
().
header
(
"User-Agent"
,
"testUserAgent"
)
ResponseEntity
<
Void
>
response
=
client
.
get
().
header
(
"User-Agent"
,
"testUserAgent"
)
.
exchange
().
flatMap
((
res
)
->
res
.
toEntity
(
Void
.
class
)).
block
();
.
exchange
().
flatMap
((
res
)
->
res
.
toEntity
(
Void
.
class
))
.
block
(
Duration
.
ofSeconds
(
30
));
assertResponseIsNotCompressed
(
response
);
assertResponseIsNotCompressed
(
response
);
}
}
...
@@ -324,7 +325,7 @@ public abstract class AbstractReactiveWebServerFactoryTests {
...
@@ -324,7 +325,7 @@ public abstract class AbstractReactiveWebServerFactoryTests {
this
.
webServer
=
factory
.
getWebServer
(
new
XForwardedHandler
());
this
.
webServer
=
factory
.
getWebServer
(
new
XForwardedHandler
());
this
.
webServer
.
start
();
this
.
webServer
.
start
();
String
body
=
getWebClient
().
build
().
get
().
header
(
"X-Forwarded-Proto"
,
"https"
)
String
body
=
getWebClient
().
build
().
get
().
header
(
"X-Forwarded-Proto"
,
"https"
)
.
retrieve
().
bodyToMono
(
String
.
class
).
block
();
.
retrieve
().
bodyToMono
(
String
.
class
).
block
(
Duration
.
ofSeconds
(
30
)
);
assertThat
(
body
).
isEqualTo
(
"https"
);
assertThat
(
body
).
isEqualTo
(
"https"
);
}
}
...
...
spring-boot-samples/spring-boot-sample-session-webflux/src/test/java/sample/session/SampleSessionWebFluxApplicationTests.java
View file @
3a7406fe
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
package
sample
.
session
;
package
sample
.
session
;
import
java.time.Duration
;
import
java.util.Base64
;
import
java.util.Base64
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -52,17 +53,19 @@ public class SampleSessionWebFluxApplicationTests {
...
@@ -52,17 +53,19 @@ public class SampleSessionWebFluxApplicationTests {
WebClient
webClient
=
this
.
webClientBuilder
WebClient
webClient
=
this
.
webClientBuilder
.
baseUrl
(
"http://localhost:"
+
this
.
port
+
"/"
).
build
();
.
baseUrl
(
"http://localhost:"
+
this
.
port
+
"/"
).
build
();
ClientResponse
response
=
webClient
.
get
().
header
(
"Authorization"
,
getBasicAuth
())
ClientResponse
response
=
webClient
.
get
().
header
(
"Authorization"
,
getBasicAuth
())
.
exchange
().
block
();
.
exchange
().
block
(
Duration
.
ofSeconds
(
30
)
);
assertThat
(
response
.
statusCode
()).
isEqualTo
(
HttpStatus
.
OK
);
assertThat
(
response
.
statusCode
()).
isEqualTo
(
HttpStatus
.
OK
);
ResponseCookie
sessionCookie
=
response
.
cookies
().
getFirst
(
"SESSION"
);
ResponseCookie
sessionCookie
=
response
.
cookies
().
getFirst
(
"SESSION"
);
String
sessionId
=
response
.
bodyToMono
(
String
.
class
).
block
();
String
sessionId
=
response
.
bodyToMono
(
String
.
class
)
.
block
(
Duration
.
ofSeconds
(
30
));
response
=
webClient
.
get
().
cookie
(
"SESSION"
,
sessionCookie
.
getValue
()).
exchange
()
response
=
webClient
.
get
().
cookie
(
"SESSION"
,
sessionCookie
.
getValue
()).
exchange
()
.
block
();
.
block
(
Duration
.
ofSeconds
(
30
)
);
assertThat
(
response
.
statusCode
()).
isEqualTo
(
HttpStatus
.
OK
);
assertThat
(
response
.
statusCode
()).
isEqualTo
(
HttpStatus
.
OK
);
assertThat
(
response
.
bodyToMono
(
String
.
class
).
block
()).
isEqualTo
(
sessionId
);
assertThat
(
response
.
bodyToMono
(
String
.
class
).
block
(
Duration
.
ofSeconds
(
30
)))
.
isEqualTo
(
sessionId
);
Thread
.
sleep
(
2000
);
Thread
.
sleep
(
2000
);
response
=
webClient
.
get
().
cookie
(
"SESSION"
,
sessionCookie
.
getValue
()).
exchange
()
response
=
webClient
.
get
().
cookie
(
"SESSION"
,
sessionCookie
.
getValue
()).
exchange
()
.
block
();
.
block
(
Duration
.
ofSeconds
(
30
)
);
assertThat
(
response
.
statusCode
()).
isEqualTo
(
HttpStatus
.
UNAUTHORIZED
);
assertThat
(
response
.
statusCode
()).
isEqualTo
(
HttpStatus
.
UNAUTHORIZED
);
}
}
...
...
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