Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sesemomo
spring-framework
提交
3a66927b
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,发现更多精彩内容 >>
提交
3a66927b
编写于
11月 12, 2018
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polishing
上级
c58da710
变更
20
隐藏空白更改
内联
并排
Showing
20 changed file
with
77 addition
and
87 deletion
+77
-87
spring-messaging/src/main/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistry.java
...rk/messaging/simp/broker/DefaultSubscriptionRegistry.java
+2
-2
spring-web/src/main/java/org/springframework/http/HttpHeaders.java
...b/src/main/java/org/springframework/http/HttpHeaders.java
+4
-3
spring-web/src/main/java/org/springframework/web/server/ServerWebExchange.java
...ava/org/springframework/web/server/ServerWebExchange.java
+3
-6
spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyInserters.java
.../springframework/web/reactive/function/BodyInserters.java
+9
-5
spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientRequest.java
...framework/web/reactive/function/client/ClientRequest.java
+1
-2
spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientRequestBuilder.java
...reactive/function/client/DefaultClientRequestBuilder.java
+9
-17
spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctions.java
...web/reactive/function/client/ExchangeFilterFunctions.java
+3
-3
spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerRequestBuilder.java
...reactive/function/server/DefaultServerRequestBuilder.java
+2
-3
spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultWebClientTests.java
...k/web/reactive/function/client/DefaultWebClientTests.java
+1
-0
spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctionsTests.java
...eactive/function/client/ExchangeFilterFunctionsTests.java
+1
-0
spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientDataBufferAllocatingTests.java
...e/function/client/WebClientDataBufferAllocatingTests.java
+1
-0
spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java
...b/reactive/function/client/WebClientIntegrationTests.java
+1
-1
spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilderTests.java
...ve/function/server/DefaultServerResponseBuilderTests.java
+1
-1
spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DispatcherHandlerIntegrationTests.java
...ve/function/server/DispatcherHandlerIntegrationTests.java
+6
-9
spring-webflux/src/test/java/org/springframework/web/reactive/function/server/LocaleContextResolverIntegrationTests.java
...unction/server/LocaleContextResolverIntegrationTests.java
+21
-16
spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RenderingResponseIntegrationTests.java
...ve/function/server/RenderingResponseIntegrationTests.java
+3
-3
spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicateTests.java
...k/web/reactive/function/server/RequestPredicateTests.java
+1
-1
spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RouterFunctionBuilderTests.java
.../reactive/function/server/RouterFunctionBuilderTests.java
+1
-2
spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/DispatcherHandlerIntegrationTests.java
...ion/server/support/DispatcherHandlerIntegrationTests.java
+5
-5
spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/ServerRequestWrapperTests.java
...ve/function/server/support/ServerRequestWrapperTests.java
+2
-8
未找到文件。
spring-messaging/src/main/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistry.java
浏览文件 @
3a66927b
...
@@ -66,7 +66,7 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry {
...
@@ -66,7 +66,7 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry {
public
static
final
int
DEFAULT_CACHE_LIMIT
=
1024
;
public
static
final
int
DEFAULT_CACHE_LIMIT
=
1024
;
/** Static evaluation context to reuse. */
/** Static evaluation context to reuse. */
private
static
EvaluationContext
messageEvalContext
=
private
static
final
EvaluationContext
messageEvalContext
=
SimpleEvaluationContext
.
forPropertyAccessors
(
new
SimpMessageHeaderPropertyAccessor
()).
build
();
SimpleEvaluationContext
.
forPropertyAccessors
(
new
SimpMessageHeaderPropertyAccessor
()).
build
();
...
@@ -130,7 +130,7 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry {
...
@@ -130,7 +130,7 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry {
* @since 4.2
* @since 4.2
*/
*/
public
void
setSelectorHeaderName
(
@Nullable
String
selectorHeaderName
)
{
public
void
setSelectorHeaderName
(
@Nullable
String
selectorHeaderName
)
{
this
.
selectorHeaderName
=
StringUtils
.
hasText
(
selectorHeaderName
)
?
selectorHeaderName
:
null
;
this
.
selectorHeaderName
=
(
StringUtils
.
hasText
(
selectorHeaderName
)
?
selectorHeaderName
:
null
)
;
}
}
/**
/**
...
...
spring-web/src/main/java/org/springframework/http/HttpHeaders.java
浏览文件 @
3a66927b
...
@@ -1017,9 +1017,10 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
...
@@ -1017,9 +1017,10 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
}
}
/**
/**
* Return the value of the required {@code Host} header.
* Return the value of the {@code Host} header, if available.
* <p>If the header value does not contain a port, the returned
* <p>If the header value does not contain a port, the
* {@linkplain InetSocketAddress#getPort() port} will be {@code 0}.
* {@linkplain InetSocketAddress#getPort() port} in the returned address will
* be {@code 0}.
* @since 5.0
* @since 5.0
*/
*/
@Nullable
@Nullable
...
...
spring-web/src/main/java/org/springframework/web/server/ServerWebExchange.java
浏览文件 @
3a66927b
...
@@ -90,7 +90,7 @@ public interface ServerWebExchange {
...
@@ -90,7 +90,7 @@ public interface ServerWebExchange {
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
default
<
T
>
T
getRequiredAttribute
(
String
name
)
{
default
<
T
>
T
getRequiredAttribute
(
String
name
)
{
T
value
=
getAttribute
(
name
);
T
value
=
getAttribute
(
name
);
Assert
.
notNull
(
value
,
()
->
"Required attribute '"
+
name
+
"' is missing
.
"
);
Assert
.
notNull
(
value
,
()
->
"Required attribute '"
+
name
+
"' is missing"
);
return
value
;
return
value
;
}
}
...
@@ -124,7 +124,6 @@ public interface ServerWebExchange {
...
@@ -124,7 +124,6 @@ public interface ServerWebExchange {
/**
/**
* Return the form data from the body of the request if the Content-Type is
* Return the form data from the body of the request if the Content-Type is
* {@code "application/x-www-form-urlencoded"} or an empty map otherwise.
* {@code "application/x-www-form-urlencoded"} or an empty map otherwise.
*
* <p><strong>Note:</strong> calling this method causes the request body to
* <p><strong>Note:</strong> calling this method causes the request body to
* be read and parsed in full and the resulting {@code MultiValueMap} is
* be read and parsed in full and the resulting {@code MultiValueMap} is
* cached so that this method is safe to call more than once.
* cached so that this method is safe to call more than once.
...
@@ -134,7 +133,6 @@ public interface ServerWebExchange {
...
@@ -134,7 +133,6 @@ public interface ServerWebExchange {
/**
/**
* Return the parts of a multipart request if the Content-Type is
* Return the parts of a multipart request if the Content-Type is
* {@code "multipart/form-data"} or an empty map otherwise.
* {@code "multipart/form-data"} or an empty map otherwise.
*
* <p><strong>Note:</strong> calling this method causes the request body to
* <p><strong>Note:</strong> calling this method causes the request body to
* be read and parsed in full and the resulting {@code MultiValueMap} is
* be read and parsed in full and the resulting {@code MultiValueMap} is
* cached so that this method is safe to call more than once.
* cached so that this method is safe to call more than once.
...
@@ -150,10 +148,9 @@ public interface ServerWebExchange {
...
@@ -150,10 +148,9 @@ public interface ServerWebExchange {
/**
/**
* Return the {@link ApplicationContext} associated with the web application,
* Return the {@link ApplicationContext} associated with the web application,
* if it was initialized with one via
* if it was initialized with one via
* {@link org.springframework.web.server.adapter.WebHttpHandlerBuilder#applicationContext
* {@link org.springframework.web.server.adapter.WebHttpHandlerBuilder#applicationContext}.
* WebHttpHandlerBuilder#applicationContext}.
* @since 5.0.3
* @since 5.0.3
* @see org.springframework.web.server.adapter.WebHttpHandlerBuilder#applicationContext
(ApplicationContext)
* @see org.springframework.web.server.adapter.WebHttpHandlerBuilder#applicationContext
*/
*/
@Nullable
@Nullable
ApplicationContext
getApplicationContext
();
ApplicationContext
getApplicationContext
();
...
...
spring-webflux/src/main/java/org/springframework/web/reactive/function/BodyInserters.java
浏览文件 @
3a66927b
...
@@ -99,6 +99,8 @@ public abstract class BodyInserters {
...
@@ -99,6 +99,8 @@ public abstract class BodyInserters {
public
static
<
T
,
P
extends
Publisher
<
T
>>
BodyInserter
<
P
,
ReactiveHttpOutputMessage
>
fromPublisher
(
public
static
<
T
,
P
extends
Publisher
<
T
>>
BodyInserter
<
P
,
ReactiveHttpOutputMessage
>
fromPublisher
(
P
publisher
,
Class
<
T
>
elementClass
)
{
P
publisher
,
Class
<
T
>
elementClass
)
{
Assert
.
notNull
(
publisher
,
"Publisher must not be null"
);
Assert
.
notNull
(
elementClass
,
"Element Class must not be null"
);
return
(
message
,
context
)
->
return
(
message
,
context
)
->
writeWithMessageWriters
(
message
,
context
,
publisher
,
ResolvableType
.
forClass
(
elementClass
));
writeWithMessageWriters
(
message
,
context
,
publisher
,
ResolvableType
.
forClass
(
elementClass
));
}
}
...
@@ -109,16 +111,18 @@ public abstract class BodyInserters {
...
@@ -109,16 +111,18 @@ public abstract class BodyInserters {
* {@link org.springframework.web.reactive.function.client.WebClient WebClient} and
* {@link org.springframework.web.reactive.function.client.WebClient WebClient} and
* {@link org.springframework.web.reactive.function.server.ServerResponse ServerResponse}.
* {@link org.springframework.web.reactive.function.server.ServerResponse ServerResponse}.
* @param publisher the publisher to write with
* @param publisher the publisher to write with
* @param typeRef the type of elements contained in the publisher
* @param typeRef
erence
the type of elements contained in the publisher
* @param <T> the type of the elements contained in the publisher
* @param <T> the type of the elements contained in the publisher
* @param <P> the {@code Publisher} type
* @param <P> the {@code Publisher} type
* @return the inserter to write a {@code Publisher}
* @return the inserter to write a {@code Publisher}
*/
*/
public
static
<
T
,
P
extends
Publisher
<
T
>>
BodyInserter
<
P
,
ReactiveHttpOutputMessage
>
fromPublisher
(
public
static
<
T
,
P
extends
Publisher
<
T
>>
BodyInserter
<
P
,
ReactiveHttpOutputMessage
>
fromPublisher
(
P
publisher
,
ParameterizedTypeReference
<
T
>
typeRef
)
{
P
publisher
,
ParameterizedTypeReference
<
T
>
typeRef
erence
)
{
Assert
.
notNull
(
publisher
,
"Publisher must not be null"
);
Assert
.
notNull
(
typeReference
,
"ParameterizedTypeReference must not be null"
);
return
(
message
,
context
)
->
return
(
message
,
context
)
->
writeWithMessageWriters
(
message
,
context
,
publisher
,
ResolvableType
.
forType
(
typeRef
.
getType
()));
writeWithMessageWriters
(
message
,
context
,
publisher
,
ResolvableType
.
forType
(
typeRef
erence
.
getType
()));
}
}
/**
/**
...
@@ -130,6 +134,7 @@ public abstract class BodyInserters {
...
@@ -130,6 +134,7 @@ public abstract class BodyInserters {
* @return the inserter to write a {@code Publisher}
* @return the inserter to write a {@code Publisher}
*/
*/
public
static
<
T
extends
Resource
>
BodyInserter
<
T
,
ReactiveHttpOutputMessage
>
fromResource
(
T
resource
)
{
public
static
<
T
extends
Resource
>
BodyInserter
<
T
,
ReactiveHttpOutputMessage
>
fromResource
(
T
resource
)
{
Assert
.
notNull
(
resource
,
"Resource must not be null"
);
return
(
outputMessage
,
context
)
->
{
return
(
outputMessage
,
context
)
->
{
ResolvableType
elementType
=
RESOURCE_TYPE
;
ResolvableType
elementType
=
RESOURCE_TYPE
;
HttpMessageWriter
<
Resource
>
writer
=
findWriter
(
context
,
elementType
,
null
);
HttpMessageWriter
<
Resource
>
writer
=
findWriter
(
context
,
elementType
,
null
);
...
@@ -151,6 +156,7 @@ public abstract class BodyInserters {
...
@@ -151,6 +156,7 @@ public abstract class BodyInserters {
public
static
<
T
,
S
extends
Publisher
<
ServerSentEvent
<
T
>>>
BodyInserter
<
S
,
ServerHttpResponse
>
fromServerSentEvents
(
public
static
<
T
,
S
extends
Publisher
<
ServerSentEvent
<
T
>>>
BodyInserter
<
S
,
ServerHttpResponse
>
fromServerSentEvents
(
S
eventsPublisher
)
{
S
eventsPublisher
)
{
Assert
.
notNull
(
eventsPublisher
,
"Publisher must not be null"
);
return
(
serverResponse
,
context
)
->
{
return
(
serverResponse
,
context
)
->
{
ResolvableType
elmentType
=
SSE_TYPE
;
ResolvableType
elmentType
=
SSE_TYPE
;
MediaType
mediaType
=
MediaType
.
TEXT_EVENT_STREAM
;
MediaType
mediaType
=
MediaType
.
TEXT_EVENT_STREAM
;
...
@@ -163,13 +169,11 @@ public abstract class BodyInserters {
...
@@ -163,13 +169,11 @@ public abstract class BodyInserters {
* Return a {@link FormInserter} to write the given {@code MultiValueMap}
* Return a {@link FormInserter} to write the given {@code MultiValueMap}
* as URL-encoded form data. The returned inserter allows for additional
* as URL-encoded form data. The returned inserter allows for additional
* entries to be added via {@link FormInserter#with(String, Object)}.
* entries to be added via {@link FormInserter#with(String, Object)}.
*
* <p>Note that you can also use the {@code syncBody(Object)} method in the
* <p>Note that you can also use the {@code syncBody(Object)} method in the
* request builders of both the {@code WebClient} and {@code WebTestClient}.
* request builders of both the {@code WebClient} and {@code WebTestClient}.
* In that case the setting of the request content type is also not required,
* In that case the setting of the request content type is also not required,
* just be sure the map contains String values only or otherwise it would be
* just be sure the map contains String values only or otherwise it would be
* interpreted as a multipart request.
* interpreted as a multipart request.
*
* @param formData the form data to write to the output message
* @param formData the form data to write to the output message
* @return the inserter that allows adding more form data
* @return the inserter that allows adding more form data
*/
*/
...
...
spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientRequest.java
浏览文件 @
3a66927b
...
@@ -106,8 +106,7 @@ public interface ClientRequest {
...
@@ -106,8 +106,7 @@ public interface ClientRequest {
String
logPrefix
();
String
logPrefix
();
/**
/**
* Writes this request to the given {@link ClientHttpRequest}.
* Write this request to the given {@link ClientHttpRequest}.
*
* @param request the client http request to write to
* @param request the client http request to write to
* @param strategies the strategies to use when writing
* @param strategies the strategies to use when writing
* @return {@code Mono<Void>} to indicate when writing is complete
* @return {@code Mono<Void>} to indicate when writing is complete
...
...
spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientRequestBuilder.java
浏览文件 @
3a66927b
...
@@ -64,13 +64,6 @@ final class DefaultClientRequestBuilder implements ClientRequest.Builder {
...
@@ -64,13 +64,6 @@ final class DefaultClientRequestBuilder implements ClientRequest.Builder {
private
BodyInserter
<?,
?
super
ClientHttpRequest
>
body
=
BodyInserters
.
empty
();
private
BodyInserter
<?,
?
super
ClientHttpRequest
>
body
=
BodyInserters
.
empty
();
public
DefaultClientRequestBuilder
(
HttpMethod
method
,
URI
url
)
{
Assert
.
notNull
(
method
,
"HttpMethod must not be null"
);
Assert
.
notNull
(
url
,
"URI must not be null"
);
this
.
method
=
method
;
this
.
url
=
url
;
}
public
DefaultClientRequestBuilder
(
ClientRequest
other
)
{
public
DefaultClientRequestBuilder
(
ClientRequest
other
)
{
Assert
.
notNull
(
other
,
"ClientRequest must not be null"
);
Assert
.
notNull
(
other
,
"ClientRequest must not be null"
);
this
.
method
=
other
.
method
();
this
.
method
=
other
.
method
();
...
@@ -81,17 +74,24 @@ final class DefaultClientRequestBuilder implements ClientRequest.Builder {
...
@@ -81,17 +74,24 @@ final class DefaultClientRequestBuilder implements ClientRequest.Builder {
body
(
other
.
body
());
body
(
other
.
body
());
}
}
public
DefaultClientRequestBuilder
(
HttpMethod
method
,
URI
url
)
{
Assert
.
notNull
(
method
,
"HttpMethod must not be null"
);
Assert
.
notNull
(
url
,
"URI must not be null"
);
this
.
method
=
method
;
this
.
url
=
url
;
}
@Override
@Override
public
ClientRequest
.
Builder
method
(
HttpMethod
method
)
{
public
ClientRequest
.
Builder
method
(
HttpMethod
method
)
{
Assert
.
notNull
(
method
,
"
'method'
must not be null"
);
Assert
.
notNull
(
method
,
"
HttpMethod
must not be null"
);
this
.
method
=
method
;
this
.
method
=
method
;
return
this
;
return
this
;
}
}
@Override
@Override
public
ClientRequest
.
Builder
url
(
URI
url
)
{
public
ClientRequest
.
Builder
url
(
URI
url
)
{
Assert
.
notNull
(
url
,
"
'url'
must not be null"
);
Assert
.
notNull
(
url
,
"
URI
must not be null"
);
this
.
url
=
url
;
this
.
url
=
url
;
return
this
;
return
this
;
}
}
...
@@ -126,9 +126,6 @@ final class DefaultClientRequestBuilder implements ClientRequest.Builder {
...
@@ -126,9 +126,6 @@ final class DefaultClientRequestBuilder implements ClientRequest.Builder {
@Override
@Override
public
<
S
,
P
extends
Publisher
<
S
>>
ClientRequest
.
Builder
body
(
P
publisher
,
Class
<
S
>
elementClass
)
{
public
<
S
,
P
extends
Publisher
<
S
>>
ClientRequest
.
Builder
body
(
P
publisher
,
Class
<
S
>
elementClass
)
{
Assert
.
notNull
(
publisher
,
"'publisher' must not be null"
);
Assert
.
notNull
(
elementClass
,
"'elementClass' must not be null"
);
this
.
body
=
BodyInserters
.
fromPublisher
(
publisher
,
elementClass
);
this
.
body
=
BodyInserters
.
fromPublisher
(
publisher
,
elementClass
);
return
this
;
return
this
;
}
}
...
@@ -137,9 +134,6 @@ final class DefaultClientRequestBuilder implements ClientRequest.Builder {
...
@@ -137,9 +134,6 @@ final class DefaultClientRequestBuilder implements ClientRequest.Builder {
public
<
S
,
P
extends
Publisher
<
S
>>
ClientRequest
.
Builder
body
(
public
<
S
,
P
extends
Publisher
<
S
>>
ClientRequest
.
Builder
body
(
P
publisher
,
ParameterizedTypeReference
<
S
>
typeReference
)
{
P
publisher
,
ParameterizedTypeReference
<
S
>
typeReference
)
{
Assert
.
notNull
(
publisher
,
"'publisher' must not be null"
);
Assert
.
notNull
(
typeReference
,
"'typeReference' must not be null"
);
this
.
body
=
BodyInserters
.
fromPublisher
(
publisher
,
typeReference
);
this
.
body
=
BodyInserters
.
fromPublisher
(
publisher
,
typeReference
);
return
this
;
return
this
;
}
}
...
@@ -184,7 +178,6 @@ final class DefaultClientRequestBuilder implements ClientRequest.Builder {
...
@@ -184,7 +178,6 @@ final class DefaultClientRequestBuilder implements ClientRequest.Builder {
private
final
String
logPrefix
;
private
final
String
logPrefix
;
public
BodyInserterRequest
(
HttpMethod
method
,
URI
url
,
HttpHeaders
headers
,
public
BodyInserterRequest
(
HttpMethod
method
,
URI
url
,
HttpHeaders
headers
,
MultiValueMap
<
String
,
String
>
cookies
,
BodyInserter
<?,
?
super
ClientHttpRequest
>
body
,
MultiValueMap
<
String
,
String
>
cookies
,
BodyInserter
<?,
?
super
ClientHttpRequest
>
body
,
Map
<
String
,
Object
>
attributes
)
{
Map
<
String
,
Object
>
attributes
)
{
...
@@ -200,7 +193,6 @@ final class DefaultClientRequestBuilder implements ClientRequest.Builder {
...
@@ -200,7 +193,6 @@ final class DefaultClientRequestBuilder implements ClientRequest.Builder {
this
.
logPrefix
=
"["
+
id
+
"] "
;
this
.
logPrefix
=
"["
+
id
+
"] "
;
}
}
@Override
@Override
public
HttpMethod
method
()
{
public
HttpMethod
method
()
{
return
this
.
method
;
return
this
.
method
;
...
...
spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctions.java
浏览文件 @
3a66927b
...
@@ -116,9 +116,9 @@ public abstract class ExchangeFilterFunctions {
...
@@ -116,9 +116,9 @@ public abstract class ExchangeFilterFunctions {
@Deprecated
@Deprecated
public
static
ExchangeFilterFunction
basicAuthentication
()
{
public
static
ExchangeFilterFunction
basicAuthentication
()
{
return
(
request
,
next
)
->
{
return
(
request
,
next
)
->
{
Credentials
cred
=
(
Credentials
)
request
Object
attr
=
request
.
attributes
().
get
(
BASIC_AUTHENTICATION_CREDENTIALS_ATTRIBUTE
);
.
attribute
(
BASIC_AUTHENTICATION_CREDENTIALS_ATTRIBUTE
).
orElse
(
null
);
if
(
attr
instanceof
Credentials
)
{
if
(
cred
!=
null
)
{
Credentials
cred
=
(
Credentials
)
attr
;
return
next
.
exchange
(
ClientRequest
.
from
(
request
)
return
next
.
exchange
(
ClientRequest
.
from
(
request
)
.
headers
(
headers
->
headers
.
setBasicAuth
(
cred
.
username
,
cred
.
password
))
.
headers
(
headers
->
headers
.
setBasicAuth
(
cred
.
username
,
cred
.
password
))
.
build
());
.
build
());
...
...
spring-webflux/src/main/java/org/springframework/web/reactive/function/server/DefaultServerRequestBuilder.java
浏览文件 @
3a66927b
...
@@ -140,7 +140,7 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder {
...
@@ -140,7 +140,7 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder {
@Override
@Override
public
ServerRequest
.
Builder
body
(
Flux
<
DataBuffer
>
body
)
{
public
ServerRequest
.
Builder
body
(
Flux
<
DataBuffer
>
body
)
{
Assert
.
notNull
(
body
,
"
'body'
must not be null"
);
Assert
.
notNull
(
body
,
"
Body
must not be null"
);
releaseBody
();
releaseBody
();
this
.
body
=
body
;
this
.
body
=
body
;
return
this
;
return
this
;
...
@@ -148,7 +148,7 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder {
...
@@ -148,7 +148,7 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder {
@Override
@Override
public
ServerRequest
.
Builder
body
(
String
body
)
{
public
ServerRequest
.
Builder
body
(
String
body
)
{
Assert
.
notNull
(
body
,
"
'body'
must not be null"
);
Assert
.
notNull
(
body
,
"
Body
must not be null"
);
releaseBody
();
releaseBody
();
DataBufferFactory
dataBufferFactory
=
new
DefaultDataBufferFactory
();
DataBufferFactory
dataBufferFactory
=
new
DefaultDataBufferFactory
();
this
.
body
=
Flux
.
just
(
body
).
this
.
body
=
Flux
.
just
(
body
).
...
@@ -165,7 +165,6 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder {
...
@@ -165,7 +165,6 @@ class DefaultServerRequestBuilder implements ServerRequest.Builder {
@Override
@Override
public
ServerRequest
.
Builder
attribute
(
String
name
,
Object
value
)
{
public
ServerRequest
.
Builder
attribute
(
String
name
,
Object
value
)
{
Assert
.
notNull
(
name
,
"'name' must not be null"
);
this
.
attributes
.
put
(
name
,
value
);
this
.
attributes
.
put
(
name
,
value
);
return
this
;
return
this
;
}
}
...
...
spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultWebClientTests.java
浏览文件 @
3a66927b
...
@@ -39,6 +39,7 @@ import static org.mockito.Mockito.*;
...
@@ -39,6 +39,7 @@ import static org.mockito.Mockito.*;
/**
/**
* Unit tests for {@link DefaultWebClient}.
* Unit tests for {@link DefaultWebClient}.
*
* @author Rossen Stoyanchev
* @author Rossen Stoyanchev
*/
*/
public
class
DefaultWebClientTests
{
public
class
DefaultWebClientTests
{
...
...
spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctionsTests.java
浏览文件 @
3a66927b
...
@@ -38,6 +38,7 @@ import static org.mockito.Mockito.*;
...
@@ -38,6 +38,7 @@ import static org.mockito.Mockito.*;
/**
/**
* Unit tests for {@link ExchangeFilterFunctions}.
* Unit tests for {@link ExchangeFilterFunctions}.
*
* @author Arjen Poutsma
* @author Arjen Poutsma
*/
*/
public
class
ExchangeFilterFunctionsTests
{
public
class
ExchangeFilterFunctionsTests
{
...
...
spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientDataBufferAllocatingTests.java
浏览文件 @
3a66927b
...
@@ -42,6 +42,7 @@ import static org.junit.Assert.*;
...
@@ -42,6 +42,7 @@ import static org.junit.Assert.*;
/**
/**
* WebClient integration tests focusing on data buffer management.
* WebClient integration tests focusing on data buffer management.
*
* @author Rossen Stoyanchev
* @author Rossen Stoyanchev
*/
*/
public
class
WebClientDataBufferAllocatingTests
extends
AbstractDataBufferAllocatingTestCase
{
public
class
WebClientDataBufferAllocatingTests
extends
AbstractDataBufferAllocatingTestCase
{
...
...
spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java
浏览文件 @
3a66927b
...
@@ -75,13 +75,13 @@ public class WebClientIntegrationTests {
...
@@ -75,13 +75,13 @@ public class WebClientIntegrationTests {
@Parameterized
.
Parameters
(
name
=
"webClient [{0}]"
)
@Parameterized
.
Parameters
(
name
=
"webClient [{0}]"
)
public
static
Object
[][]
arguments
()
{
public
static
Object
[][]
arguments
()
{
return
new
Object
[][]
{
return
new
Object
[][]
{
{
new
JettyClientHttpConnector
()},
{
new
JettyClientHttpConnector
()},
{
new
ReactorClientHttpConnector
()}
{
new
ReactorClientHttpConnector
()}
};
};
}
}
@Before
@Before
public
void
setup
()
{
public
void
setup
()
{
this
.
server
=
new
MockWebServer
();
this
.
server
=
new
MockWebServer
();
...
...
spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilderTests.java
浏览文件 @
3a66927b
...
@@ -62,6 +62,7 @@ public class DefaultServerResponseBuilderTests {
...
@@ -62,6 +62,7 @@ public class DefaultServerResponseBuilderTests {
}
}
};
};
@Test
@Test
public
void
from
()
{
public
void
from
()
{
ServerResponse
other
=
ServerResponse
.
ok
().
header
(
"foo"
,
"bar"
).
build
().
block
();
ServerResponse
other
=
ServerResponse
.
ok
().
header
(
"foo"
,
"bar"
).
build
().
block
();
...
@@ -383,5 +384,4 @@ public class DefaultServerResponseBuilderTests {
...
@@ -383,5 +384,4 @@ public class DefaultServerResponseBuilderTests {
.
verify
();
.
verify
();
}
}
}
}
spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DispatcherHandlerIntegrationTests.java
浏览文件 @
3a66927b
...
@@ -43,9 +43,8 @@ import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
...
@@ -43,9 +43,8 @@ import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
import
org.springframework.web.util.pattern.PathPattern
;
import
org.springframework.web.util.pattern.PathPattern
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
springframework
.
web
.
reactive
.
function
.
BodyInserters
.
fromPublisher
;
import
static
org
.
springframework
.
web
.
reactive
.
function
.
BodyInserters
.*;
import
static
org
.
springframework
.
web
.
reactive
.
function
.
server
.
RouterFunctions
.
nest
;
import
static
org
.
springframework
.
web
.
reactive
.
function
.
server
.
RouterFunctions
.*;
import
static
org
.
springframework
.
web
.
reactive
.
function
.
server
.
RouterFunctions
.
route
;
/**
/**
* Tests the use of {@link HandlerFunction} and {@link RouterFunction} in a
* Tests the use of {@link HandlerFunction} and {@link RouterFunction} in a
...
@@ -134,7 +133,6 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr
...
@@ -134,7 +133,6 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr
return
new
AttributesHandler
();
return
new
AttributesHandler
();
}
}
@Bean
@Bean
public
RouterFunction
<
EntityResponse
<
Person
>>
monoRouterFunction
(
PersonHandler
personHandler
)
{
public
RouterFunction
<
EntityResponse
<
Person
>>
monoRouterFunction
(
PersonHandler
personHandler
)
{
return
route
(
RequestPredicates
.
GET
(
"/mono"
),
personHandler:
:
mono
);
return
route
(
RequestPredicates
.
GET
(
"/mono"
),
personHandler:
:
mono
);
...
@@ -150,7 +148,6 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr
...
@@ -150,7 +148,6 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr
return
nest
(
RequestPredicates
.
GET
(
"/attributes"
),
return
nest
(
RequestPredicates
.
GET
(
"/attributes"
),
route
(
RequestPredicates
.
GET
(
"/{foo}"
),
attributesHandler:
:
attributes
));
route
(
RequestPredicates
.
GET
(
"/{foo}"
),
attributesHandler:
:
attributes
));
}
}
}
}
...
@@ -167,16 +164,15 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr
...
@@ -167,16 +164,15 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr
return
ServerResponse
.
ok
().
body
(
return
ServerResponse
.
ok
().
body
(
fromPublisher
(
Flux
.
just
(
person1
,
person2
),
Person
.
class
));
fromPublisher
(
Flux
.
just
(
person1
,
person2
),
Person
.
class
));
}
}
}
}
private
static
class
AttributesHandler
{
private
static
class
AttributesHandler
{
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
public
Mono
<
ServerResponse
>
attributes
(
ServerRequest
request
)
{
public
Mono
<
ServerResponse
>
attributes
(
ServerRequest
request
)
{
assertTrue
(
request
.
attributes
().
containsKey
(
RouterFunctions
.
REQUEST_ATTRIBUTE
));
assertTrue
(
request
.
attributes
().
containsKey
(
RouterFunctions
.
REQUEST_ATTRIBUTE
));
assertTrue
(
request
.
attributes
()
assertTrue
(
request
.
attributes
().
containsKey
(
HandlerMapping
.
BEST_MATCHING_HANDLER_ATTRIBUTE
));
.
containsKey
(
HandlerMapping
.
BEST_MATCHING_HANDLER_ATTRIBUTE
));
Map
<
String
,
String
>
pathVariables
=
Map
<
String
,
String
>
pathVariables
=
(
Map
<
String
,
String
>)
request
.
attributes
().
get
(
RouterFunctions
.
URI_TEMPLATE_VARIABLES_ATTRIBUTE
);
(
Map
<
String
,
String
>)
request
.
attributes
().
get
(
RouterFunctions
.
URI_TEMPLATE_VARIABLES_ATTRIBUTE
);
...
@@ -203,9 +199,9 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr
...
@@ -203,9 +199,9 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr
return
ServerResponse
.
ok
().
build
();
return
ServerResponse
.
ok
().
build
();
}
}
}
}
@Controller
@Controller
public
static
class
PersonController
{
public
static
class
PersonController
{
...
@@ -216,6 +212,7 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr
...
@@ -216,6 +212,7 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr
}
}
}
}
private
static
class
Person
{
private
static
class
Person
{
private
String
name
;
private
String
name
;
...
...
spring-webflux/src/test/java/org/springframework/web/reactive/function/server/LocaleContextResolverIntegrationTests.java
浏览文件 @
3a66927b
/*
/*
* Copyright 2002-201
7
the original author or authors.
* Copyright 2002-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.
...
@@ -44,21 +44,6 @@ public class LocaleContextResolverIntegrationTests extends AbstractRouterFunctio
...
@@ -44,21 +44,6 @@ public class LocaleContextResolverIntegrationTests extends AbstractRouterFunctio
private
final
WebClient
webClient
=
WebClient
.
create
();
private
final
WebClient
webClient
=
WebClient
.
create
();
@Test
public
void
fixedLocale
()
{
Mono
<
ClientResponse
>
result
=
webClient
.
get
()
.
uri
(
"http://localhost:"
+
this
.
port
+
"/"
)
.
exchange
();
StepVerifier
.
create
(
result
)
.
consumeNextWith
(
response
->
{
assertEquals
(
HttpStatus
.
OK
,
response
.
statusCode
());
assertEquals
(
Locale
.
GERMANY
,
response
.
headers
().
asHttpHeaders
().
getContentLanguage
());
})
.
verifyComplete
();
}
@Override
@Override
protected
RouterFunction
<?>
routerFunction
()
{
protected
RouterFunction
<?>
routerFunction
()
{
...
@@ -77,6 +62,24 @@ public class LocaleContextResolverIntegrationTests extends AbstractRouterFunctio
...
@@ -77,6 +62,24 @@ public class LocaleContextResolverIntegrationTests extends AbstractRouterFunctio
.
build
();
.
build
();
}
}
@Test
public
void
fixedLocale
()
{
Mono
<
ClientResponse
>
result
=
webClient
.
get
()
.
uri
(
"http://localhost:"
+
this
.
port
+
"/"
)
.
exchange
();
StepVerifier
.
create
(
result
)
.
consumeNextWith
(
response
->
{
assertEquals
(
HttpStatus
.
OK
,
response
.
statusCode
());
assertEquals
(
Locale
.
GERMANY
,
response
.
headers
().
asHttpHeaders
().
getContentLanguage
());
})
.
verifyComplete
();
}
private
static
class
DummyViewResolver
implements
ViewResolver
{
private
static
class
DummyViewResolver
implements
ViewResolver
{
@Override
@Override
...
@@ -85,6 +88,7 @@ public class LocaleContextResolverIntegrationTests extends AbstractRouterFunctio
...
@@ -85,6 +88,7 @@ public class LocaleContextResolverIntegrationTests extends AbstractRouterFunctio
}
}
}
}
private
static
class
DummyView
implements
View
{
private
static
class
DummyView
implements
View
{
private
final
Locale
locale
;
private
final
Locale
locale
;
...
@@ -105,4 +109,5 @@ public class LocaleContextResolverIntegrationTests extends AbstractRouterFunctio
...
@@ -105,4 +109,5 @@ public class LocaleContextResolverIntegrationTests extends AbstractRouterFunctio
return
Mono
.
empty
();
return
Mono
.
empty
();
}
}
}
}
}
}
spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RenderingResponseIntegrationTests.java
浏览文件 @
3a66927b
/*
/*
* Copyright 2002-201
7
the original author or authors.
* Copyright 2002-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.
...
@@ -69,9 +69,9 @@ public class RenderingResponseIntegrationTests extends AbstractRouterFunctionInt
...
@@ -69,9 +69,9 @@ public class RenderingResponseIntegrationTests extends AbstractRouterFunctionInt
return
HandlerStrategies
.
builder
()
return
HandlerStrategies
.
builder
()
.
viewResolver
(
new
DummyViewResolver
())
.
viewResolver
(
new
DummyViewResolver
())
.
build
();
.
build
();
}
}
@Test
@Test
public
void
normal
()
{
public
void
normal
()
{
ResponseEntity
<
String
>
result
=
ResponseEntity
<
String
>
result
=
...
@@ -109,6 +109,7 @@ public class RenderingResponseIntegrationTests extends AbstractRouterFunctionInt
...
@@ -109,6 +109,7 @@ public class RenderingResponseIntegrationTests extends AbstractRouterFunctionInt
return
result
;
return
result
;
}
}
private
static
class
RenderingResponseHandler
{
private
static
class
RenderingResponseHandler
{
public
Mono
<
RenderingResponse
>
render
(
ServerRequest
request
)
{
public
Mono
<
RenderingResponse
>
render
(
ServerRequest
request
)
{
...
@@ -116,7 +117,6 @@ public class RenderingResponseIntegrationTests extends AbstractRouterFunctionInt
...
@@ -116,7 +117,6 @@ public class RenderingResponseIntegrationTests extends AbstractRouterFunctionInt
.
modelAttribute
(
"bar"
,
"baz"
)
.
modelAttribute
(
"bar"
,
"baz"
)
.
build
();
.
build
();
}
}
}
}
private
static
class
DummyViewResolver
implements
ViewResolver
{
private
static
class
DummyViewResolver
implements
ViewResolver
{
...
...
spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicateTests.java
浏览文件 @
3a66927b
/*
/*
* Copyright 2002-201
7
the original author or authors.
* Copyright 2002-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.
...
...
spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RouterFunctionBuilderTests.java
浏览文件 @
3a66927b
...
@@ -209,7 +209,6 @@ public class RouterFunctionBuilderTests {
...
@@ -209,7 +209,6 @@ public class RouterFunctionBuilderTests {
StepVerifier
.
create
(
barResponseMono
)
StepVerifier
.
create
(
barResponseMono
)
.
expectNext
(
500
)
.
expectNext
(
500
)
.
verifyComplete
();
.
verifyComplete
();
}
}
}
}
\ No newline at end of file
spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/DispatcherHandlerIntegrationTests.java
浏览文件 @
3a66927b
...
@@ -35,8 +35,8 @@ import org.springframework.web.reactive.function.server.ServerResponse;
...
@@ -35,8 +35,8 @@ import org.springframework.web.reactive.function.server.ServerResponse;
import
org.springframework.web.server.adapter.WebHttpHandlerBuilder
;
import
org.springframework.web.server.adapter.WebHttpHandlerBuilder
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
springframework
.
web
.
reactive
.
function
.
server
.
RequestPredicates
.
accept
;
import
static
org
.
springframework
.
web
.
reactive
.
function
.
server
.
RequestPredicates
.
*
;
import
static
org
.
springframework
.
web
.
reactive
.
function
.
server
.
RouterFunctions
.
route
;
import
static
org
.
springframework
.
web
.
reactive
.
function
.
server
.
RouterFunctions
.
*
;
/**
/**
* @author Arjen Poutsma
* @author Arjen Poutsma
...
@@ -45,6 +45,7 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr
...
@@ -45,6 +45,7 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr
private
final
RestTemplate
restTemplate
=
new
RestTemplate
();
private
final
RestTemplate
restTemplate
=
new
RestTemplate
();
@Override
@Override
protected
HttpHandler
createHttpHandler
()
{
protected
HttpHandler
createHttpHandler
()
{
AnnotationConfigApplicationContext
wac
=
new
AnnotationConfigApplicationContext
();
AnnotationConfigApplicationContext
wac
=
new
AnnotationConfigApplicationContext
();
...
@@ -54,6 +55,7 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr
...
@@ -54,6 +55,7 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr
return
WebHttpHandlerBuilder
.
webHandler
(
new
DispatcherHandler
(
wac
)).
build
();
return
WebHttpHandlerBuilder
.
webHandler
(
new
DispatcherHandler
(
wac
)).
build
();
}
}
@Test
@Test
public
void
nested
()
{
public
void
nested
()
{
ResponseEntity
<
String
>
result
=
this
.
restTemplate
ResponseEntity
<
String
>
result
=
this
.
restTemplate
...
@@ -83,6 +85,7 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr
...
@@ -83,6 +85,7 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr
}
}
}
}
static
class
Handler
{
static
class
Handler
{
public
Mono
<
ServerResponse
>
handle
(
ServerRequest
request
)
{
public
Mono
<
ServerResponse
>
handle
(
ServerRequest
request
)
{
...
@@ -90,7 +93,4 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr
...
@@ -90,7 +93,4 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr
}
}
}
}
}
}
\ No newline at end of file
spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/ServerRequestWrapperTests.java
浏览文件 @
3a66927b
...
@@ -21,7 +21,6 @@ import java.util.Collections;
...
@@ -21,7 +21,6 @@ import java.util.Collections;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Optional
;
import
java.util.Optional
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.Test
;
import
reactor.core.publisher.Flux
;
import
reactor.core.publisher.Flux
;
import
reactor.core.publisher.Mono
;
import
reactor.core.publisher.Mono
;
...
@@ -44,15 +43,10 @@ import static org.mockito.Mockito.*;
...
@@ -44,15 +43,10 @@ import static org.mockito.Mockito.*;
*/
*/
public
class
ServerRequestWrapperTests
{
public
class
ServerRequestWrapperTests
{
private
ServerRequest
mockRequest
;
private
final
ServerRequest
mockRequest
=
mock
(
ServerRequest
.
class
)
;
private
ServerRequestWrapper
wrapper
;
private
final
ServerRequestWrapper
wrapper
=
new
ServerRequestWrapper
(
mockRequest
)
;
@Before
public
void
createWrapper
()
{
mockRequest
=
mock
(
ServerRequest
.
class
);
wrapper
=
new
ServerRequestWrapper
(
mockRequest
);
}
@Test
@Test
public
void
request
()
{
public
void
request
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录