Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sesemomo
spring-framework
提交
5c236e1e
S
spring-framework
项目概览
sesemomo
/
spring-framework
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5c236e1e
编写于
6月 06, 2016
作者:
R
Rossen Stoyanchev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update to latest Reactor snapshot
上级
03b474ed
变更
25
隐藏空白更改
内联
并排
Showing
25 changed file
with
111 addition
and
116 deletion
+111
-116
spring-web-reactive/src/main/java/org/springframework/core/convert/support/ReactiveStreamsToCompletableFutureConverter.java
.../support/ReactiveStreamsToCompletableFutureConverter.java
+2
-2
spring-web-reactive/src/test/java/org/springframework/http/server/reactive/ChannelSendOperatorTests.java
...mework/http/server/reactive/ChannelSendOperatorTests.java
+5
-5
spring-web-reactive/src/test/java/org/springframework/http/server/reactive/ServerHttpResponseTests.java
...amework/http/server/reactive/ServerHttpResponseTests.java
+6
-6
spring-web-reactive/src/test/java/org/springframework/web/reactive/DispatcherHandlerErrorTests.java
...ngframework/web/reactive/DispatcherHandlerErrorTests.java
+3
-3
spring-web-reactive/src/test/java/org/springframework/web/reactive/ResponseStatusExceptionHandlerTests.java
...ork/web/reactive/ResponseStatusExceptionHandlerTests.java
+2
-2
spring-web-reactive/src/test/java/org/springframework/web/reactive/handler/SimpleUrlHandlerMappingTests.java
...rk/web/reactive/handler/SimpleUrlHandlerMappingTests.java
+1
-1
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/HandlerMethodMappingTests.java
...web/reactive/result/method/HandlerMethodMappingTests.java
+4
-4
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/InvocableHandlerMethodTests.java
...b/reactive/result/method/InvocableHandlerMethodTests.java
+3
-3
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMappingTests.java
.../result/method/RequestMappingInfoHandlerMappingTests.java
+2
-2
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/AbstractRequestAttributesArgumentResolverTests.java
...ation/AbstractRequestAttributesArgumentResolverTests.java
+10
-10
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/CookieValueMethodArgumentResolverTests.java
...od/annotation/CookieValueMethodArgumentResolverTests.java
+3
-3
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/ExpressionValueMethodArgumentResolverTests.java
...nnotation/ExpressionValueMethodArgumentResolverTests.java
+1
-1
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/PathVariableMapMethodArgumentResolverTests.java
...nnotation/PathVariableMapMethodArgumentResolverTests.java
+2
-2
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/PathVariableMethodArgumentResolverTests.java
...d/annotation/PathVariableMethodArgumentResolverTests.java
+1
-1
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestAttributeMethodArgumentResolverTests.java
...notation/RequestAttributeMethodArgumentResolverTests.java
+10
-10
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMapMethodArgumentResolverTests.java
...notation/RequestHeaderMapMethodArgumentResolverTests.java
+3
-3
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMethodArgumentResolverTests.java
.../annotation/RequestHeaderMethodArgumentResolverTests.java
+8
-8
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestParamMapMethodArgumentResolverTests.java
...nnotation/RequestParamMapMethodArgumentResolverTests.java
+2
-2
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestParamMethodArgumentResolverTests.java
...d/annotation/RequestParamMethodArgumentResolverTests.java
+10
-10
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseBodyResultHandlerTests.java
...ult/method/annotation/ResponseBodyResultHandlerTests.java
+3
-5
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributeMethodArgumentResolverTests.java
...notation/SessionAttributeMethodArgumentResolverTests.java
+10
-10
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/view/UrlBasedViewResolverTests.java
...k/web/reactive/result/view/UrlBasedViewResolverTests.java
+2
-2
spring-web-reactive/src/test/java/org/springframework/web/server/handler/ExceptionHandlingHttpHandlerTests.java
...web/server/handler/ExceptionHandlingHttpHandlerTests.java
+4
-4
spring-web-reactive/src/test/java/org/springframework/web/server/handler/FilteringWebHandlerTests.java
...ramework/web/server/handler/FilteringWebHandlerTests.java
+6
-9
spring-web-reactive/src/test/java/org/springframework/web/server/session/DefaultWebSessionManagerTests.java
...ork/web/server/session/DefaultWebSessionManagerTests.java
+8
-8
未找到文件。
spring-web-reactive/src/main/java/org/springframework/core/convert/support/ReactiveStreamsToCompletableFutureConverter.java
浏览文件 @
5c236e1e
...
...
@@ -45,10 +45,10 @@ public class ReactiveStreamsToCompletableFutureConverter implements GenericConve
return
null
;
}
else
if
(
CompletableFuture
.
class
.
isAssignableFrom
(
source
.
getClass
()))
{
return
Mono
.
from
CompletableFuture
((
CompletableFuture
)
source
);
return
Mono
.
from
Future
((
CompletableFuture
)
source
);
}
else
if
(
CompletableFuture
.
class
.
isAssignableFrom
(
targetType
.
getResolvableType
().
getRawClass
()))
{
return
Mono
.
from
((
Publisher
)
source
).
toCompletable
Future
();
return
Mono
.
from
((
Publisher
)
source
).
to
Future
();
}
return
null
;
}
...
...
spring-web-reactive/src/test/java/org/springframework/http/server/reactive/ChannelSendOperatorTests.java
浏览文件 @
5c236e1e
...
...
@@ -57,7 +57,7 @@ public class ChannelSendOperatorTests {
public
void
errorBeforeFirstItem
()
throws
Exception
{
IllegalStateException
error
=
new
IllegalStateException
(
"boo"
);
Mono
<
Void
>
completion
=
Mono
.<
String
>
error
(
error
).
as
(
this
::
sendOperator
);
Signal
<
Void
>
signal
=
completion
.
materialize
().
get
();
Signal
<
Void
>
signal
=
completion
.
materialize
().
block
();
assertNotNull
(
signal
);
assertSame
(
"Unexpected signal: "
+
signal
,
error
,
signal
.
getThrowable
());
...
...
@@ -66,7 +66,7 @@ public class ChannelSendOperatorTests {
@Test
public
void
completionBeforeFirstItem
()
throws
Exception
{
Mono
<
Void
>
completion
=
Flux
.<
String
>
empty
().
as
(
this
::
sendOperator
);
Signal
<
Void
>
signal
=
completion
.
materialize
().
get
();
Signal
<
Void
>
signal
=
completion
.
materialize
().
block
();
assertNotNull
(
signal
);
assertTrue
(
"Unexpected signal: "
+
signal
,
signal
.
isOnComplete
());
...
...
@@ -78,7 +78,7 @@ public class ChannelSendOperatorTests {
@Test
public
void
writeOneItem
()
throws
Exception
{
Mono
<
Void
>
completion
=
Flux
.
just
(
"one"
).
as
(
this
::
sendOperator
);
Signal
<
Void
>
signal
=
completion
.
materialize
().
get
();
Signal
<
Void
>
signal
=
completion
.
materialize
().
block
();
assertNotNull
(
signal
);
assertTrue
(
"Unexpected signal: "
+
signal
,
signal
.
isOnComplete
());
...
...
@@ -93,7 +93,7 @@ public class ChannelSendOperatorTests {
public
void
writeMultipleItems
()
throws
Exception
{
List
<
String
>
items
=
Arrays
.
asList
(
"one"
,
"two"
,
"three"
);
Mono
<
Void
>
completion
=
Flux
.
fromIterable
(
items
).
as
(
this
::
sendOperator
);
Signal
<
Void
>
signal
=
completion
.
materialize
().
get
();
Signal
<
Void
>
signal
=
completion
.
materialize
().
block
();
assertNotNull
(
signal
);
assertTrue
(
"Unexpected signal: "
+
signal
,
signal
.
isOnComplete
());
...
...
@@ -117,7 +117,7 @@ public class ChannelSendOperatorTests {
return
i
;
});
Mono
<
Void
>
completion
=
publisher
.
as
(
this
::
sendOperator
);
Signal
<
Void
>
signal
=
completion
.
materialize
().
get
();
Signal
<
Void
>
signal
=
completion
.
materialize
().
block
();
assertNotNull
(
signal
);
assertSame
(
"Unexpected signal: "
+
signal
,
error
,
signal
.
getThrowable
());
...
...
spring-web-reactive/src/test/java/org/springframework/http/server/reactive/ServerHttpResponseTests.java
浏览文件 @
5c236e1e
...
...
@@ -45,7 +45,7 @@ public class ServerHttpResponseTests {
@Test
public
void
writeWith
()
throws
Exception
{
TestServerHttpResponse
response
=
new
TestServerHttpResponse
();
response
.
writeWith
(
Flux
.
just
(
wrap
(
"a"
),
wrap
(
"b"
),
wrap
(
"c"
))).
get
();
response
.
writeWith
(
Flux
.
just
(
wrap
(
"a"
),
wrap
(
"b"
),
wrap
(
"c"
))).
block
();
assertTrue
(
response
.
headersWritten
);
assertTrue
(
response
.
cookiesWritten
);
...
...
@@ -60,7 +60,7 @@ public class ServerHttpResponseTests {
public
void
writeWithError
()
throws
Exception
{
TestServerHttpResponse
response
=
new
TestServerHttpResponse
();
IllegalStateException
error
=
new
IllegalStateException
(
"boo"
);
response
.
writeWith
(
Flux
.
error
(
error
)).
otherwise
(
ex
->
Mono
.
empty
()).
get
();
response
.
writeWith
(
Flux
.
error
(
error
)).
otherwise
(
ex
->
Mono
.
empty
()).
block
();
assertFalse
(
response
.
headersWritten
);
assertFalse
(
response
.
cookiesWritten
);
...
...
@@ -70,7 +70,7 @@ public class ServerHttpResponseTests {
@Test
public
void
setComplete
()
throws
Exception
{
TestServerHttpResponse
response
=
new
TestServerHttpResponse
();
response
.
setComplete
().
get
();
response
.
setComplete
().
block
();
assertTrue
(
response
.
headersWritten
);
assertTrue
(
response
.
cookiesWritten
);
...
...
@@ -85,7 +85,7 @@ public class ServerHttpResponseTests {
response
.
getCookies
().
add
(
cookie
.
getName
(),
cookie
);
return
Mono
.
empty
();
});
response
.
writeWith
(
Flux
.
just
(
wrap
(
"a"
),
wrap
(
"b"
),
wrap
(
"c"
))).
get
();
response
.
writeWith
(
Flux
.
just
(
wrap
(
"a"
),
wrap
(
"b"
),
wrap
(
"c"
))).
block
();
assertTrue
(
response
.
headersWritten
);
assertTrue
(
response
.
cookiesWritten
);
...
...
@@ -102,7 +102,7 @@ public class ServerHttpResponseTests {
TestServerHttpResponse
response
=
new
TestServerHttpResponse
();
IllegalStateException
error
=
new
IllegalStateException
(
"boo"
);
response
.
beforeCommit
(()
->
Mono
.
error
(
error
));
response
.
writeWith
(
Flux
.
just
(
wrap
(
"a"
),
wrap
(
"b"
),
wrap
(
"c"
))).
get
();
response
.
writeWith
(
Flux
.
just
(
wrap
(
"a"
),
wrap
(
"b"
),
wrap
(
"c"
))).
block
();
assertTrue
(
"beforeCommit action errors should be ignored"
,
response
.
headersWritten
);
assertTrue
(
"beforeCommit action errors should be ignored"
,
response
.
cookiesWritten
);
...
...
@@ -122,7 +122,7 @@ public class ServerHttpResponseTests {
response
.
getCookies
().
add
(
cookie
.
getName
(),
cookie
);
return
Mono
.
empty
();
});
response
.
setComplete
().
get
();
response
.
setComplete
().
block
();
assertTrue
(
response
.
headersWritten
);
assertTrue
(
response
.
cookiesWritten
);
...
...
spring-web-reactive/src/test/java/org/springframework/web/reactive/DispatcherHandlerErrorTests.java
浏览文件 @
5c236e1e
...
...
@@ -191,7 +191,7 @@ public class DispatcherHandlerErrorTests {
WebHandler
webHandler
=
new
ExceptionHandlingWebHandler
(
this
.
dispatcherHandler
,
exceptionHandler
);
Mono
<
Void
>
publisher
=
webHandler
.
handle
(
this
.
exchange
);
publisher
.
get
();
publisher
.
block
();
assertEquals
(
HttpStatus
.
INTERNAL_SERVER_ERROR
,
this
.
response
.
getStatus
());
}
...
...
@@ -203,13 +203,13 @@ public class DispatcherHandlerErrorTests {
webHandler
=
new
ExceptionHandlingWebHandler
(
webHandler
,
new
ServerError500ExceptionHandler
());
Mono
<
Void
>
publisher
=
webHandler
.
handle
(
this
.
exchange
);
publisher
.
get
();
publisher
.
block
();
assertEquals
(
HttpStatus
.
INTERNAL_SERVER_ERROR
,
this
.
response
.
getStatus
());
}
private
Throwable
awaitErrorSignal
(
Mono
<?>
mono
)
throws
Exception
{
Signal
<?>
signal
=
mono
.
materialize
().
get
();
Signal
<?>
signal
=
mono
.
materialize
().
block
();
assertEquals
(
"Unexpected signal: "
+
signal
,
SignalKind
.
onError
,
signal
.
getType
());
return
signal
.
getThrowable
();
}
...
...
spring-web-reactive/src/test/java/org/springframework/web/reactive/ResponseStatusExceptionHandlerTests.java
浏览文件 @
5c236e1e
...
...
@@ -63,7 +63,7 @@ public class ResponseStatusExceptionHandlerTests {
Throwable
ex
=
new
ResponseStatusException
(
HttpStatus
.
BAD_REQUEST
,
""
);
Mono
<
Void
>
publisher
=
this
.
handler
.
handle
(
this
.
exchange
,
ex
);
publisher
.
get
();
publisher
.
block
();
assertEquals
(
HttpStatus
.
BAD_REQUEST
,
this
.
response
.
getStatus
());
}
...
...
@@ -72,7 +72,7 @@ public class ResponseStatusExceptionHandlerTests {
Throwable
ex
=
new
IllegalStateException
();
Mono
<
Void
>
publisher
=
this
.
handler
.
handle
(
this
.
exchange
,
ex
);
Signal
<
Void
>
signal
=
publisher
.
materialize
().
get
();
Signal
<
Void
>
signal
=
publisher
.
materialize
().
block
();
assertNotNull
(
signal
);
assertTrue
(
signal
.
hasError
());
assertSame
(
ex
,
signal
.
getThrowable
());
...
...
spring-web-reactive/src/test/java/org/springframework/web/reactive/handler/SimpleUrlHandlerMappingTests.java
浏览文件 @
5c236e1e
...
...
@@ -108,7 +108,7 @@ public class SimpleUrlHandlerMappingTests {
throws
URISyntaxException
{
ServerWebExchange
exchange
=
createExchange
(
url
);
Object
actual
=
handlerMapping
.
getHandler
(
exchange
).
get
();
Object
actual
=
handlerMapping
.
getHandler
(
exchange
).
block
();
if
(
bean
!=
null
)
{
assertNotNull
(
actual
);
assertSame
(
bean
,
actual
);
...
...
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/HandlerMethodMappingTests.java
浏览文件 @
5c236e1e
...
...
@@ -84,7 +84,7 @@ public class HandlerMethodMappingTests {
this
.
mapping
.
registerMapping
(
key
,
this
.
handler
,
this
.
method1
);
Mono
<
Object
>
result
=
this
.
mapping
.
getHandler
(
createExchange
(
HttpMethod
.
GET
,
key
));
assertEquals
(
this
.
method1
,
((
HandlerMethod
)
result
.
get
()).
getMethod
());
assertEquals
(
this
.
method1
,
((
HandlerMethod
)
result
.
block
()).
getMethod
());
}
@Test
...
...
@@ -93,7 +93,7 @@ public class HandlerMethodMappingTests {
this
.
mapping
.
registerMapping
(
"/f*"
,
this
.
handler
,
this
.
method2
);
Mono
<
Object
>
result
=
this
.
mapping
.
getHandler
(
createExchange
(
HttpMethod
.
GET
,
"/foo"
));
assertEquals
(
this
.
method1
,
((
HandlerMethod
)
result
.
get
()).
getMethod
());
assertEquals
(
this
.
method1
,
((
HandlerMethod
)
result
.
block
()).
getMethod
());
}
@Test
...
...
@@ -140,11 +140,11 @@ public class HandlerMethodMappingTests {
String
key
=
"foo"
;
this
.
mapping
.
registerMapping
(
key
,
this
.
handler
,
this
.
method1
);
Mono
<
Object
>
result
=
this
.
mapping
.
getHandler
(
createExchange
(
HttpMethod
.
GET
,
key
));
assertNotNull
(
result
.
get
());
assertNotNull
(
result
.
block
());
this
.
mapping
.
unregisterMapping
(
key
);
result
=
this
.
mapping
.
getHandler
(
createExchange
(
HttpMethod
.
GET
,
key
));
assertNull
(
result
.
get
());
assertNull
(
result
.
block
());
assertNull
(
this
.
mapping
.
getMappingRegistry
().
getMappingsByUrl
(
key
));
}
...
...
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/InvocableHandlerMethodTests.java
浏览文件 @
5c236e1e
...
...
@@ -90,7 +90,7 @@ public class InvocableHandlerMethodTests {
new
RequestParamMethodArgumentResolver
(
new
GenericConversionService
(),
null
,
false
)));
Mono
<
HandlerResult
>
mono
=
hm
.
invokeForRequest
(
this
.
exchange
,
this
.
model
);
HandlerResult
value
=
mono
.
get
();
HandlerResult
value
=
mono
.
block
();
assertNotNull
(
value
);
assertEquals
(
"success:null"
,
value
.
getReturnValue
().
get
());
...
...
@@ -102,7 +102,7 @@ public class InvocableHandlerMethodTests {
addResolver
(
hm
,
Mono
.
just
(
"value1"
));
Mono
<
HandlerResult
>
mono
=
hm
.
invokeForRequest
(
this
.
exchange
,
this
.
model
);
HandlerResult
value
=
mono
.
get
();
HandlerResult
value
=
mono
.
block
();
assertNotNull
(
value
);
assertEquals
(
"success:value1"
,
value
.
getReturnValue
().
get
());
...
...
@@ -114,7 +114,7 @@ public class InvocableHandlerMethodTests {
addResolver
(
hm
,
Flux
.
fromIterable
(
Arrays
.
asList
(
"value1"
,
"value2"
,
"value3"
)));
Mono
<
HandlerResult
>
mono
=
hm
.
invokeForRequest
(
this
.
exchange
,
this
.
model
);
HandlerResult
value
=
mono
.
get
();
HandlerResult
value
=
mono
.
block
();
assertNotNull
(
value
);
assertEquals
(
"success:value1"
,
value
.
getReturnValue
().
get
());
...
...
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMappingTests.java
浏览文件 @
5c236e1e
...
...
@@ -368,7 +368,7 @@ public class RequestMappingInfoHandlerMappingTests {
@SuppressWarnings
(
"ConstantConditions"
)
private
HandlerMethod
getHandler
(
ServerWebExchange
exchange
)
throws
Exception
{
Mono
<
Object
>
handler
=
this
.
handlerMapping
.
getHandler
(
exchange
);
return
(
HandlerMethod
)
handler
.
get
();
return
(
HandlerMethod
)
handler
.
block
();
}
private
void
testHttpMediaTypeNotSupportedException
(
String
url
)
throws
Exception
{
...
...
@@ -389,7 +389,7 @@ public class RequestMappingInfoHandlerMappingTests {
ModelMap
model
=
new
ExtendedModelMap
();
Mono
<
HandlerResult
>
mono
=
new
InvocableHandlerMethod
(
handlerMethod
).
invokeForRequest
(
exchange
,
model
);
HandlerResult
result
=
mono
.
get
();
HandlerResult
result
=
mono
.
block
();
assertNotNull
(
result
);
Optional
<
Object
>
value
=
result
.
getReturnValue
();
...
...
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/AbstractRequestAttributesArgumentResolverTests.java
浏览文件 @
5c236e1e
...
...
@@ -103,7 +103,7 @@ public abstract class AbstractRequestAttributesArgumentResolverTests {
Foo
foo
=
new
Foo
();
this
.
exchange
.
getAttributes
().
put
(
"foo"
,
foo
);
mono
=
this
.
resolver
.
resolveArgument
(
param
,
null
,
this
.
exchange
);
assertSame
(
foo
,
mono
.
get
());
assertSame
(
foo
,
mono
.
block
());
}
@Test
...
...
@@ -112,36 +112,36 @@ public abstract class AbstractRequestAttributesArgumentResolverTests {
Foo
foo
=
new
Foo
();
this
.
exchange
.
getAttributes
().
put
(
"specialFoo"
,
foo
);
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
param
,
null
,
this
.
exchange
);
assertSame
(
foo
,
mono
.
get
());
assertSame
(
foo
,
mono
.
block
());
}
@Test
public
void
resolveNotRequired
()
throws
Exception
{
MethodParameter
param
=
initMethodParameter
(
2
);
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
param
,
null
,
this
.
exchange
);
assertNull
(
mono
.
get
());
assertNull
(
mono
.
block
());
Foo
foo
=
new
Foo
();
this
.
exchange
.
getAttributes
().
put
(
"foo"
,
foo
);
mono
=
this
.
resolver
.
resolveArgument
(
param
,
null
,
this
.
exchange
);
assertSame
(
foo
,
mono
.
get
());
assertSame
(
foo
,
mono
.
block
());
}
@Test
public
void
resolveOptional
()
throws
Exception
{
MethodParameter
param
=
initMethodParameter
(
3
);
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
param
,
null
,
this
.
exchange
);
assertNotNull
(
mono
.
get
());
assertEquals
(
Optional
.
class
,
mono
.
get
().
getClass
());
assertFalse
(((
Optional
)
mono
.
get
()).
isPresent
());
assertNotNull
(
mono
.
block
());
assertEquals
(
Optional
.
class
,
mono
.
block
().
getClass
());
assertFalse
(((
Optional
)
mono
.
block
()).
isPresent
());
Foo
foo
=
new
Foo
();
this
.
exchange
.
getAttributes
().
put
(
"foo"
,
foo
);
mono
=
this
.
resolver
.
resolveArgument
(
param
,
null
,
this
.
exchange
);
assertNotNull
(
mono
.
get
());
assertEquals
(
Optional
.
class
,
mono
.
get
().
getClass
());
Optional
optional
=
(
Optional
)
mono
.
get
();
assertNotNull
(
mono
.
block
());
assertEquals
(
Optional
.
class
,
mono
.
block
().
getClass
());
Optional
optional
=
(
Optional
)
mono
.
block
();
assertTrue
(
optional
.
isPresent
());
assertSame
(
foo
,
optional
.
get
());
}
...
...
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/CookieValueMethodArgumentResolverTests.java
浏览文件 @
5c236e1e
...
...
@@ -92,7 +92,7 @@ public class CookieValueMethodArgumentResolverTests {
this
.
exchange
.
getRequest
().
getCookies
().
add
(
expected
.
getName
(),
expected
);
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
this
.
cookieParameter
,
null
,
this
.
exchange
);
assertEquals
(
expected
,
mono
.
get
());
assertEquals
(
expected
,
mono
.
block
());
}
@Test
...
...
@@ -101,13 +101,13 @@ public class CookieValueMethodArgumentResolverTests {
this
.
exchange
.
getRequest
().
getCookies
().
add
(
cookie
.
getName
(),
cookie
);
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
this
.
cookieStringParameter
,
null
,
this
.
exchange
);
assertEquals
(
"Invalid result"
,
cookie
.
getValue
(),
mono
.
get
());
assertEquals
(
"Invalid result"
,
cookie
.
getValue
(),
mono
.
block
());
}
@Test
public
void
resolveCookieDefaultValue
()
{
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
this
.
cookieStringParameter
,
null
,
this
.
exchange
);
Object
result
=
mono
.
get
();
Object
result
=
mono
.
block
();
assertTrue
(
result
instanceof
String
);
assertEquals
(
"bar"
,
result
);
...
...
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/ExpressionValueMethodArgumentResolverTests.java
浏览文件 @
5c236e1e
...
...
@@ -84,7 +84,7 @@ public class ExpressionValueMethodArgumentResolverTests {
System
.
setProperty
(
"systemProperty"
,
"22"
);
try
{
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
this
.
paramSystemProperty
,
null
,
this
.
exchange
);
Object
value
=
mono
.
get
();
Object
value
=
mono
.
block
();
assertEquals
(
22
,
value
);
}
finally
{
...
...
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/PathVariableMapMethodArgumentResolverTests.java
浏览文件 @
5c236e1e
...
...
@@ -88,7 +88,7 @@ public class PathVariableMapMethodArgumentResolverTests {
this
.
exchange
.
getAttributes
().
put
(
HandlerMapping
.
URI_TEMPLATE_VARIABLES_ATTRIBUTE
,
uriTemplateVars
);
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
this
.
paramMap
,
new
ModelMap
(),
this
.
exchange
);
Object
result
=
mono
.
get
();
Object
result
=
mono
.
block
();
assertEquals
(
uriTemplateVars
,
result
);
}
...
...
@@ -96,7 +96,7 @@ public class PathVariableMapMethodArgumentResolverTests {
@Test
public
void
resolveArgumentNoUriVars
()
throws
Exception
{
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
this
.
paramMap
,
new
ModelMap
(),
this
.
exchange
);
Object
result
=
mono
.
get
();
Object
result
=
mono
.
block
();
assertEquals
(
Collections
.
emptyMap
(),
result
);
}
...
...
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/PathVariableMethodArgumentResolverTests.java
浏览文件 @
5c236e1e
...
...
@@ -89,7 +89,7 @@ public class PathVariableMethodArgumentResolverTests {
this
.
exchange
.
getAttributes
().
put
(
HandlerMapping
.
URI_TEMPLATE_VARIABLES_ATTRIBUTE
,
uriTemplateVars
);
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
this
.
paramNamedString
,
new
ModelMap
(),
this
.
exchange
);
Object
result
=
mono
.
get
();
Object
result
=
mono
.
block
();
assertTrue
(
result
instanceof
String
);
assertEquals
(
"value"
,
result
);
...
...
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestAttributeMethodArgumentResolverTests.java
浏览文件 @
5c236e1e
...
...
@@ -97,7 +97,7 @@ public class RequestAttributeMethodArgumentResolverTests {
Foo
foo
=
new
Foo
();
this
.
exchange
.
getAttributes
().
put
(
"foo"
,
foo
);
mono
=
this
.
resolver
.
resolveArgument
(
param
,
null
,
this
.
exchange
);
assertSame
(
foo
,
mono
.
get
());
assertSame
(
foo
,
mono
.
block
());
}
@Test
...
...
@@ -106,36 +106,36 @@ public class RequestAttributeMethodArgumentResolverTests {
Foo
foo
=
new
Foo
();
this
.
exchange
.
getAttributes
().
put
(
"specialFoo"
,
foo
);
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
param
,
null
,
this
.
exchange
);
assertSame
(
foo
,
mono
.
get
());
assertSame
(
foo
,
mono
.
block
());
}
@Test
public
void
resolveNotRequired
()
throws
Exception
{
MethodParameter
param
=
initMethodParameter
(
2
);
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
param
,
null
,
this
.
exchange
);
assertNull
(
mono
.
get
());
assertNull
(
mono
.
block
());
Foo
foo
=
new
Foo
();
this
.
exchange
.
getAttributes
().
put
(
"foo"
,
foo
);
mono
=
this
.
resolver
.
resolveArgument
(
param
,
null
,
this
.
exchange
);
assertSame
(
foo
,
mono
.
get
());
assertSame
(
foo
,
mono
.
block
());
}
@Test
public
void
resolveOptional
()
throws
Exception
{
MethodParameter
param
=
initMethodParameter
(
3
);
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
param
,
null
,
this
.
exchange
);
assertNotNull
(
mono
.
get
());
assertEquals
(
Optional
.
class
,
mono
.
get
().
getClass
());
assertFalse
(((
Optional
)
mono
.
get
()).
isPresent
());
assertNotNull
(
mono
.
block
());
assertEquals
(
Optional
.
class
,
mono
.
block
().
getClass
());
assertFalse
(((
Optional
)
mono
.
block
()).
isPresent
());
Foo
foo
=
new
Foo
();
this
.
exchange
.
getAttributes
().
put
(
"foo"
,
foo
);
mono
=
this
.
resolver
.
resolveArgument
(
param
,
null
,
this
.
exchange
);
assertNotNull
(
mono
.
get
());
assertEquals
(
Optional
.
class
,
mono
.
get
().
getClass
());
Optional
optional
=
(
Optional
)
mono
.
get
();
assertNotNull
(
mono
.
block
());
assertEquals
(
Optional
.
class
,
mono
.
block
().
getClass
());
Optional
optional
=
(
Optional
)
mono
.
block
();
assertTrue
(
optional
.
isPresent
());
assertSame
(
foo
,
optional
.
get
());
}
...
...
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMapMethodArgumentResolverTests.java
浏览文件 @
5c236e1e
...
...
@@ -93,7 +93,7 @@ public class RequestHeaderMapMethodArgumentResolverTests {
this
.
exchange
.
getRequest
().
getHeaders
().
add
(
name
,
value
);
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
paramMap
,
null
,
this
.
exchange
);
Object
result
=
mono
.
get
();
Object
result
=
mono
.
block
();
assertTrue
(
result
instanceof
Map
);
assertEquals
(
"Invalid result"
,
expected
,
result
);
...
...
@@ -113,7 +113,7 @@ public class RequestHeaderMapMethodArgumentResolverTests {
expected
.
add
(
name
,
value2
);
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
paramMultiValueMap
,
null
,
this
.
exchange
);
Object
result
=
mono
.
get
();
Object
result
=
mono
.
block
();
assertTrue
(
result
instanceof
MultiValueMap
);
assertEquals
(
"Invalid result"
,
expected
,
result
);
...
...
@@ -133,7 +133,7 @@ public class RequestHeaderMapMethodArgumentResolverTests {
expected
.
add
(
name
,
value2
);
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
paramHttpHeaders
,
null
,
this
.
exchange
);
Object
result
=
mono
.
get
();
Object
result
=
mono
.
block
();
assertTrue
(
result
instanceof
HttpHeaders
);
assertEquals
(
"Invalid result"
,
expected
,
result
);
...
...
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMethodArgumentResolverTests.java
浏览文件 @
5c236e1e
...
...
@@ -109,7 +109,7 @@ public class RequestHeaderMethodArgumentResolverTests {
this
.
exchange
.
getRequest
().
getHeaders
().
add
(
"name"
,
expected
);
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
paramNamedDefaultValueStringHeader
,
null
,
this
.
exchange
);
Object
result
=
mono
.
get
();
Object
result
=
mono
.
block
();
assertTrue
(
result
instanceof
String
);
assertEquals
(
expected
,
result
);
}
...
...
@@ -120,7 +120,7 @@ public class RequestHeaderMethodArgumentResolverTests {
this
.
exchange
.
getRequest
().
getHeaders
().
put
(
"name"
,
Arrays
.
asList
(
expected
));
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
paramNamedValueStringArray
,
null
,
this
.
exchange
);
Object
result
=
mono
.
get
();
Object
result
=
mono
.
block
();
assertTrue
(
result
instanceof
String
[]);
assertArrayEquals
(
expected
,
(
String
[])
result
);
}
...
...
@@ -128,7 +128,7 @@ public class RequestHeaderMethodArgumentResolverTests {
@Test
public
void
resolveDefaultValue
()
throws
Exception
{
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
paramNamedDefaultValueStringHeader
,
null
,
this
.
exchange
);
Object
result
=
mono
.
get
();
Object
result
=
mono
.
block
();
assertTrue
(
result
instanceof
String
);
assertEquals
(
"bar"
,
result
);
}
...
...
@@ -138,7 +138,7 @@ public class RequestHeaderMethodArgumentResolverTests {
System
.
setProperty
(
"systemProperty"
,
"bar"
);
try
{
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
paramSystemProperty
,
null
,
this
.
exchange
);
Object
result
=
mono
.
get
();
Object
result
=
mono
.
block
();
assertTrue
(
result
instanceof
String
);
assertEquals
(
"bar"
,
result
);
}
...
...
@@ -155,7 +155,7 @@ public class RequestHeaderMethodArgumentResolverTests {
System
.
setProperty
(
"systemProperty"
,
"bar"
);
try
{
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
paramResolvedNameWithExpression
,
null
,
this
.
exchange
);
Object
result
=
mono
.
get
();
Object
result
=
mono
.
block
();
assertTrue
(
result
instanceof
String
);
assertEquals
(
expected
,
result
);
}
...
...
@@ -172,7 +172,7 @@ public class RequestHeaderMethodArgumentResolverTests {
System
.
setProperty
(
"systemProperty"
,
"bar"
);
try
{
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
paramResolvedNameWithPlaceholder
,
null
,
this
.
exchange
);
Object
result
=
mono
.
get
();
Object
result
=
mono
.
block
();
assertTrue
(
result
instanceof
String
);
assertEquals
(
expected
,
result
);
}
...
...
@@ -196,7 +196,7 @@ public class RequestHeaderMethodArgumentResolverTests {
this
.
exchange
.
getRequest
().
getHeaders
().
add
(
"name"
,
rfc1123val
);
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
paramDate
,
null
,
this
.
exchange
);
Object
result
=
mono
.
get
();
Object
result
=
mono
.
block
();
assertTrue
(
result
instanceof
Date
);
assertEquals
(
new
Date
(
rfc1123val
),
result
);
...
...
@@ -208,7 +208,7 @@ public class RequestHeaderMethodArgumentResolverTests {
this
.
exchange
.
getRequest
().
getHeaders
().
add
(
"name"
,
rfc1123val
);
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
paramInstant
,
null
,
this
.
exchange
);
Object
result
=
mono
.
get
();
Object
result
=
mono
.
block
();
assertTrue
(
result
instanceof
Instant
);
assertEquals
(
Instant
.
from
(
DateTimeFormatter
.
RFC_1123_DATE_TIME
.
parse
(
rfc1123val
)),
result
);
...
...
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestParamMapMethodArgumentResolverTests.java
浏览文件 @
5c236e1e
...
...
@@ -94,7 +94,7 @@ public class RequestParamMapMethodArgumentResolverTests {
Map
<
String
,
String
>
expected
=
Collections
.
singletonMap
(
name
,
value
);
Mono
<
Object
>
mono
=
resolver
.
resolveArgument
(
paramMap
,
null
,
exchange
);
Object
result
=
mono
.
get
();
Object
result
=
mono
.
block
();
assertTrue
(
result
instanceof
Map
);
assertEquals
(
expected
,
result
);
...
...
@@ -112,7 +112,7 @@ public class RequestParamMapMethodArgumentResolverTests {
expected
.
add
(
name
,
value2
);
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
this
.
paramMultiValueMap
,
null
,
this
.
exchange
);
Object
result
=
mono
.
get
();
Object
result
=
mono
.
block
();
assertTrue
(
result
instanceof
MultiValueMap
);
assertEquals
(
expected
,
result
);
...
...
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestParamMethodArgumentResolverTests.java
浏览文件 @
5c236e1e
...
...
@@ -119,7 +119,7 @@ public class RequestParamMethodArgumentResolverTests {
this
.
exchange
.
getRequest
().
getQueryParams
().
set
(
"name"
,
expected
);
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
this
.
paramNamedDefaultValueString
,
null
,
this
.
exchange
);
Object
result
=
mono
.
get
();
Object
result
=
mono
.
block
();
assertTrue
(
result
instanceof
String
);
assertEquals
(
"Invalid result"
,
expected
,
result
);
...
...
@@ -131,7 +131,7 @@ public class RequestParamMethodArgumentResolverTests {
this
.
exchange
.
getRequest
().
getQueryParams
().
put
(
"name"
,
Arrays
.
asList
(
expected
));
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
this
.
paramNamedStringArray
,
null
,
this
.
exchange
);
Object
result
=
mono
.
get
();
Object
result
=
mono
.
block
();
assertTrue
(
result
instanceof
String
[]);
assertArrayEquals
(
expected
,
(
String
[])
result
);
...
...
@@ -140,7 +140,7 @@ public class RequestParamMethodArgumentResolverTests {
@Test
public
void
resolveDefaultValue
()
throws
Exception
{
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
paramNamedDefaultValueString
,
null
,
this
.
exchange
);
Object
result
=
mono
.
get
();
Object
result
=
mono
.
block
();
assertTrue
(
result
instanceof
String
);
assertEquals
(
"Invalid result"
,
"bar"
,
result
);
...
...
@@ -158,7 +158,7 @@ public class RequestParamMethodArgumentResolverTests {
public
void
resolveSimpleTypeParam
()
throws
Exception
{
this
.
exchange
.
getRequest
().
getQueryParams
().
set
(
"stringNotAnnot"
,
"plainValue"
);
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
paramStringNotAnnot
,
null
,
this
.
exchange
);
Object
result
=
mono
.
get
();
Object
result
=
mono
.
block
();
assertTrue
(
result
instanceof
String
);
assertEquals
(
"plainValue"
,
result
);
...
...
@@ -167,7 +167,7 @@ public class RequestParamMethodArgumentResolverTests {
@Test
// SPR-8561
public
void
resolveSimpleTypeParamToNull
()
throws
Exception
{
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
paramStringNotAnnot
,
null
,
this
.
exchange
);
Object
result
=
mono
.
get
();
Object
result
=
mono
.
block
();
assertNull
(
result
);
}
...
...
@@ -176,7 +176,7 @@ public class RequestParamMethodArgumentResolverTests {
public
void
resolveEmptyValueToDefault
()
throws
Exception
{
this
.
exchange
.
getRequest
().
getQueryParams
().
set
(
"name"
,
""
);
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
paramNamedDefaultValueString
,
null
,
this
.
exchange
);
Object
result
=
mono
.
get
();
Object
result
=
mono
.
block
();
assertEquals
(
"bar"
,
result
);
}
...
...
@@ -185,7 +185,7 @@ public class RequestParamMethodArgumentResolverTests {
public
void
resolveEmptyValueWithoutDefault
()
throws
Exception
{
this
.
exchange
.
getRequest
().
getQueryParams
().
set
(
"stringNotAnnot"
,
""
);
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
paramStringNotAnnot
,
null
,
this
.
exchange
);
Object
result
=
mono
.
get
();
Object
result
=
mono
.
block
();
assertEquals
(
""
,
result
);
}
...
...
@@ -194,7 +194,7 @@ public class RequestParamMethodArgumentResolverTests {
public
void
resolveEmptyValueRequiredWithoutDefault
()
throws
Exception
{
this
.
exchange
.
getRequest
().
getQueryParams
().
set
(
"name"
,
""
);
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
paramRequired
,
null
,
this
.
exchange
);
Object
result
=
mono
.
get
();
Object
result
=
mono
.
block
();
assertEquals
(
""
,
result
);
}
...
...
@@ -202,13 +202,13 @@ public class RequestParamMethodArgumentResolverTests {
@Test
public
void
resolveOptionalParamValue
()
throws
Exception
{
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
paramOptional
,
null
,
this
.
exchange
);
Object
result
=
mono
.
get
();
Object
result
=
mono
.
block
();
assertEquals
(
Optional
.
empty
(),
result
);
this
.
exchange
.
getRequest
().
getQueryParams
().
set
(
"name"
,
"123"
);
mono
=
resolver
.
resolveArgument
(
paramOptional
,
null
,
this
.
exchange
);
result
=
mono
.
get
();
result
=
mono
.
block
();
assertEquals
(
Optional
.
class
,
result
.
getClass
());
Optional
<?>
value
=
(
Optional
<?>)
result
;
...
...
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseBodyResultHandlerTests.java
浏览文件 @
5c236e1e
...
...
@@ -24,8 +24,6 @@ import java.util.List;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
javax.print.attribute.standard.Media
;
import
org.junit.Test
;
import
org.reactivestreams.Publisher
;
...
...
@@ -47,9 +45,9 @@ import org.springframework.web.method.HandlerMethod;
import
org.springframework.web.reactive.HandlerMapping
;
import
org.springframework.web.reactive.HandlerResult
;
import
org.springframework.web.reactive.HandlerResultHandler
;
import
org.springframework.web.reactive.accept.RequestedContentTypeResolver
;
import
org.springframework.web.reactive.accept.FixedContentTypeResolver
;
import
org.springframework.web.reactive.accept.HeaderContentTypeResolver
;
import
org.springframework.web.reactive.accept.RequestedContentTypeResolver
;
import
org.springframework.web.server.ServerWebExchange
;
import
org.springframework.web.server.adapter.DefaultServerWebExchange
;
import
org.springframework.web.server.session.WebSessionManager
;
...
...
@@ -100,7 +98,7 @@ public class ResponseBodyResultHandlerTests {
ServerWebExchange
exchange
=
createExchange
(
"/foo"
);
HandlerResult
result
=
new
HandlerResult
(
new
Object
(),
"fooValue"
,
ResolvableType
.
forClass
(
String
.
class
));
handler
.
handleResult
(
exchange
,
result
).
get
();
handler
.
handleResult
(
exchange
,
result
).
block
();
assertEquals
(
contentType
,
exchange
.
getResponse
().
getHeaders
().
getContentType
());
}
...
...
@@ -114,7 +112,7 @@ public class ResponseBodyResultHandlerTests {
HandlerResultHandler
handler
=
createHandler
(
new
StringEncoder
(),
new
JacksonJsonEncoder
());
HandlerResult
result
=
new
HandlerResult
(
new
Object
(),
"fooValue"
,
ResolvableType
.
forClass
(
String
.
class
));
handler
.
handleResult
(
exchange
,
result
).
get
();
handler
.
handleResult
(
exchange
,
result
).
block
();
assertEquals
(
MediaType
.
APPLICATION_JSON
,
exchange
.
getResponse
().
getHeaders
().
getContentType
());
}
...
...
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributeMethodArgumentResolverTests.java
浏览文件 @
5c236e1e
...
...
@@ -104,7 +104,7 @@ public class SessionAttributeMethodArgumentResolverTests {
Foo
foo
=
new
Foo
();
when
(
this
.
session
.
getAttribute
(
"foo"
)).
thenReturn
(
Optional
.
of
(
foo
));
mono
=
this
.
resolver
.
resolveArgument
(
param
,
null
,
this
.
exchange
);
assertSame
(
foo
,
mono
.
get
());
assertSame
(
foo
,
mono
.
block
());
}
@Test
...
...
@@ -113,36 +113,36 @@ public class SessionAttributeMethodArgumentResolverTests {
Foo
foo
=
new
Foo
();
when
(
this
.
session
.
getAttribute
(
"specialFoo"
)).
thenReturn
(
Optional
.
of
(
foo
));
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
param
,
null
,
this
.
exchange
);
assertSame
(
foo
,
mono
.
get
());
assertSame
(
foo
,
mono
.
block
());
}
@Test
public
void
resolveNotRequired
()
throws
Exception
{
MethodParameter
param
=
initMethodParameter
(
2
);
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
param
,
null
,
this
.
exchange
);
assertNull
(
mono
.
get
());
assertNull
(
mono
.
block
());
Foo
foo
=
new
Foo
();
when
(
this
.
session
.
getAttribute
(
"foo"
)).
thenReturn
(
Optional
.
of
(
foo
));
mono
=
this
.
resolver
.
resolveArgument
(
param
,
null
,
this
.
exchange
);
assertSame
(
foo
,
mono
.
get
());
assertSame
(
foo
,
mono
.
block
());
}
@Test
public
void
resolveOptional
()
throws
Exception
{
MethodParameter
param
=
initMethodParameter
(
3
);
Mono
<
Object
>
mono
=
this
.
resolver
.
resolveArgument
(
param
,
null
,
this
.
exchange
);
assertNotNull
(
mono
.
get
());
assertEquals
(
Optional
.
class
,
mono
.
get
().
getClass
());
assertFalse
(((
Optional
)
mono
.
get
()).
isPresent
());
assertNotNull
(
mono
.
block
());
assertEquals
(
Optional
.
class
,
mono
.
block
().
getClass
());
assertFalse
(((
Optional
)
mono
.
block
()).
isPresent
());
Foo
foo
=
new
Foo
();
when
(
this
.
session
.
getAttribute
(
"foo"
)).
thenReturn
(
Optional
.
of
(
foo
));
mono
=
this
.
resolver
.
resolveArgument
(
param
,
null
,
this
.
exchange
);
assertNotNull
(
mono
.
get
());
assertEquals
(
Optional
.
class
,
mono
.
get
().
getClass
());
Optional
optional
=
(
Optional
)
mono
.
get
();
assertNotNull
(
mono
.
block
());
assertEquals
(
Optional
.
class
,
mono
.
block
().
getClass
());
Optional
optional
=
(
Optional
)
mono
.
block
();
assertTrue
(
optional
.
isPresent
());
assertSame
(
foo
,
optional
.
get
());
}
...
...
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/view/UrlBasedViewResolverTests.java
浏览文件 @
5c236e1e
...
...
@@ -48,10 +48,10 @@ public class UrlBasedViewResolverTests {
resolver
.
setApplicationContext
(
context
);
Mono
<
View
>
mono
=
resolver
.
resolveViewName
(
"my-view"
,
Locale
.
US
);
assertNotNull
(
mono
.
get
());
assertNotNull
(
mono
.
block
());
mono
=
resolver
.
resolveViewName
(
"not-my-view"
,
Locale
.
US
);
assertNull
(
mono
.
get
());
assertNull
(
mono
.
block
());
}
...
...
spring-web-reactive/src/test/java/org/springframework/web/server/handler/ExceptionHandlingHttpHandlerTests.java
浏览文件 @
5c236e1e
...
...
@@ -62,7 +62,7 @@ public class ExceptionHandlingHttpHandlerTests {
@Test
public
void
handleErrorSignal
()
throws
Exception
{
WebExceptionHandler
exceptionHandler
=
new
BadRequestExceptionHandler
();
createWebHandler
(
exceptionHandler
).
handle
(
this
.
exchange
).
get
();
createWebHandler
(
exceptionHandler
).
handle
(
this
.
exchange
).
block
();
assertEquals
(
HttpStatus
.
BAD_REQUEST
,
this
.
response
.
getStatus
());
}
...
...
@@ -75,7 +75,7 @@ public class ExceptionHandlingHttpHandlerTests {
new
BadRequestExceptionHandler
(),
new
UnresolvedExceptionHandler
()
};
createWebHandler
(
exceptionHandlers
).
handle
(
this
.
exchange
).
get
();
createWebHandler
(
exceptionHandlers
).
handle
(
this
.
exchange
).
block
();
assertEquals
(
HttpStatus
.
BAD_REQUEST
,
this
.
response
.
getStatus
());
}
...
...
@@ -83,7 +83,7 @@ public class ExceptionHandlingHttpHandlerTests {
@Test
public
void
unresolvedException
()
throws
Exception
{
WebExceptionHandler
exceptionHandler
=
new
UnresolvedExceptionHandler
();
createWebHandler
(
exceptionHandler
).
handle
(
this
.
exchange
).
get
();
createWebHandler
(
exceptionHandler
).
handle
(
this
.
exchange
).
block
();
assertEquals
(
HttpStatus
.
INTERNAL_SERVER_ERROR
,
this
.
response
.
getStatus
());
}
...
...
@@ -91,7 +91,7 @@ public class ExceptionHandlingHttpHandlerTests {
@Test
public
void
thrownExceptionBecomesErrorSignal
()
throws
Exception
{
WebExceptionHandler
exceptionHandler
=
new
BadRequestExceptionHandler
();
createWebHandler
(
exceptionHandler
).
handle
(
this
.
exchange
).
get
();
createWebHandler
(
exceptionHandler
).
handle
(
this
.
exchange
).
block
();
assertEquals
(
HttpStatus
.
BAD_REQUEST
,
this
.
response
.
getStatus
());
}
...
...
spring-web-reactive/src/test/java/org/springframework/web/server/handler/FilteringWebHandlerTests.java
浏览文件 @
5c236e1e
...
...
@@ -23,20 +23,17 @@ import org.apache.commons.logging.LogFactory;
import
org.junit.Before
;
import
org.junit.Test
;
import
reactor.core.publisher.Mono
;
import
reactor.core.test.TestSubscriber
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.server.reactive.HttpHandler
;
import
org.springframework.http.server.reactive.MockServerHttpRequest
;
import
org.springframework.http.server.reactive.MockServerHttpResponse
;
import
org.springframework.http.server.reactive.ServerHttpRequest
;
import
org.springframework.http.server.reactive.ServerHttpResponse
;
import
org.springframework.web.server.ServerWebExchange
;
import
org.springframework.web.server.WebExceptionHandler
;
import
org.springframework.web.server.WebFilter
;
import
org.springframework.web.server.WebFilterChain
;
import
org.springframework.web.server.WebHandler
;
import
org.springframework.web.server.ServerWebExchange
;
import
org.springframework.web.server.adapter.WebHttpHandlerBuilder
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
...
...
@@ -70,7 +67,7 @@ public class FilteringWebHandlerTests {
TestFilter
filter2
=
new
TestFilter
();
TestFilter
filter3
=
new
TestFilter
();
HttpHandler
httpHandler
=
createHttpHandler
(
webHandler
,
filter1
,
filter2
,
filter3
);
httpHandler
.
handle
(
this
.
request
,
this
.
response
).
get
();
httpHandler
.
handle
(
this
.
request
,
this
.
response
).
block
();
assertTrue
(
filter1
.
invoked
());
assertTrue
(
filter2
.
invoked
());
...
...
@@ -82,7 +79,7 @@ public class FilteringWebHandlerTests {
public
void
zeroFilters
()
throws
Exception
{
StubWebHandler
webHandler
=
new
StubWebHandler
();
HttpHandler
httpHandler
=
createHttpHandler
(
webHandler
);
httpHandler
.
handle
(
this
.
request
,
this
.
response
).
get
();
httpHandler
.
handle
(
this
.
request
,
this
.
response
).
block
();
assertTrue
(
webHandler
.
invoked
());
}
...
...
@@ -94,7 +91,7 @@ public class FilteringWebHandlerTests {
ShortcircuitingFilter
filter2
=
new
ShortcircuitingFilter
();
TestFilter
filter3
=
new
TestFilter
();
HttpHandler
httpHandler
=
createHttpHandler
(
webHandler
,
filter1
,
filter2
,
filter3
);
httpHandler
.
handle
(
this
.
request
,
this
.
response
).
get
();
httpHandler
.
handle
(
this
.
request
,
this
.
response
).
block
();
assertTrue
(
filter1
.
invoked
());
assertTrue
(
filter2
.
invoked
());
...
...
@@ -107,7 +104,7 @@ public class FilteringWebHandlerTests {
StubWebHandler
webHandler
=
new
StubWebHandler
();
AsyncFilter
filter
=
new
AsyncFilter
();
HttpHandler
httpHandler
=
createHttpHandler
(
webHandler
,
filter
);
httpHandler
.
handle
(
this
.
request
,
this
.
response
).
get
();
httpHandler
.
handle
(
this
.
request
,
this
.
response
).
block
();
assertTrue
(
filter
.
invoked
());
assertTrue
(
webHandler
.
invoked
());
...
...
@@ -118,7 +115,7 @@ public class FilteringWebHandlerTests {
TestExceptionHandler
exceptionHandler
=
new
TestExceptionHandler
();
HttpHandler
handler
=
WebHttpHandlerBuilder
.
webHandler
(
new
StubWebHandler
())
.
filters
(
new
ExceptionFilter
()).
exceptionHandlers
(
exceptionHandler
).
build
();
handler
.
handle
(
this
.
request
,
this
.
response
).
get
();
handler
.
handle
(
this
.
request
,
this
.
response
).
block
();
assertEquals
(
HttpStatus
.
INTERNAL_SERVER_ERROR
,
this
.
response
.
getStatus
());
...
...
spring-web-reactive/src/test/java/org/springframework/web/server/session/DefaultWebSessionManagerTests.java
浏览文件 @
5c236e1e
...
...
@@ -66,32 +66,32 @@ public class DefaultWebSessionManagerTests {
@Test
public
void
getSessionWithoutStarting
()
throws
Exception
{
this
.
idResolver
.
setIdsToResolve
(
Collections
.
emptyList
());
WebSession
session
=
this
.
manager
.
getSession
(
this
.
exchange
).
get
();
WebSession
session
=
this
.
manager
.
getSession
(
this
.
exchange
).
block
();
session
.
save
();
assertFalse
(
session
.
isStarted
());
assertFalse
(
session
.
isExpired
());
assertNull
(
this
.
idResolver
.
getSavedId
());
assertNull
(
this
.
manager
.
getSessionStore
().
retrieveSession
(
session
.
getId
()).
get
());
assertNull
(
this
.
manager
.
getSessionStore
().
retrieveSession
(
session
.
getId
()).
block
());
}
@Test
public
void
startSessionExplicitly
()
throws
Exception
{
this
.
idResolver
.
setIdsToResolve
(
Collections
.
emptyList
());
WebSession
session
=
this
.
manager
.
getSession
(
this
.
exchange
).
get
();
WebSession
session
=
this
.
manager
.
getSession
(
this
.
exchange
).
block
();
session
.
start
();
session
.
save
();
String
id
=
session
.
getId
();
assertNotNull
(
this
.
idResolver
.
getSavedId
());
assertEquals
(
id
,
this
.
idResolver
.
getSavedId
());
assertSame
(
session
,
this
.
manager
.
getSessionStore
().
retrieveSession
(
id
).
get
());
assertSame
(
session
,
this
.
manager
.
getSessionStore
().
retrieveSession
(
id
).
block
());
}
@Test
public
void
startSessionImplicitly
()
throws
Exception
{
this
.
idResolver
.
setIdsToResolve
(
Collections
.
emptyList
());
WebSession
session
=
this
.
manager
.
getSession
(
this
.
exchange
).
get
();
WebSession
session
=
this
.
manager
.
getSession
(
this
.
exchange
).
block
();
session
.
getAttributes
().
put
(
"foo"
,
"bar"
);
session
.
save
();
...
...
@@ -104,7 +104,7 @@ public class DefaultWebSessionManagerTests {
this
.
manager
.
getSessionStore
().
storeSession
(
existing
);
this
.
idResolver
.
setIdsToResolve
(
Collections
.
singletonList
(
"1"
));
WebSession
actual
=
this
.
manager
.
getSession
(
this
.
exchange
).
get
();
WebSession
actual
=
this
.
manager
.
getSession
(
this
.
exchange
).
block
();
assertSame
(
existing
,
actual
);
}
...
...
@@ -117,7 +117,7 @@ public class DefaultWebSessionManagerTests {
this
.
manager
.
getSessionStore
().
storeSession
(
existing
);
this
.
idResolver
.
setIdsToResolve
(
Collections
.
singletonList
(
"1"
));
WebSession
actual
=
this
.
manager
.
getSession
(
this
.
exchange
).
get
();
WebSession
actual
=
this
.
manager
.
getSession
(
this
.
exchange
).
block
();
assertNotSame
(
existing
,
actual
);
}
...
...
@@ -127,7 +127,7 @@ public class DefaultWebSessionManagerTests {
this
.
manager
.
getSessionStore
().
storeSession
(
existing
);
this
.
idResolver
.
setIdsToResolve
(
Arrays
.
asList
(
"1"
,
"2"
,
"3"
));
WebSession
actual
=
this
.
manager
.
getSession
(
this
.
exchange
).
get
();
WebSession
actual
=
this
.
manager
.
getSession
(
this
.
exchange
).
block
();
assertSame
(
existing
,
actual
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录