Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sesemomo
spring-framework
提交
2575c260
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,发现更多精彩内容 >>
提交
2575c260
编写于
3月 11, 2018
作者:
S
Sam Brannen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Clean up warnings and dead code in spring-webflux module
上级
fb7c4a30
变更
25
隐藏空白更改
内联
并排
Showing
25 changed file
with
86 addition
and
162 deletion
+86
-162
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractMessageWriterResultHandler.java
...method/annotation/AbstractMessageWriterResultHandler.java
+1
-1
spring-webflux/src/main/java/org/springframework/web/reactive/socket/adapter/TomcatWebSocketSession.java
...k/web/reactive/socket/adapter/TomcatWebSocketSession.java
+2
-1
spring-webflux/src/test/java/org/springframework/web/reactive/accept/HeaderContentTypeResolverTests.java
...k/web/reactive/accept/HeaderContentTypeResolverTests.java
+3
-10
spring-webflux/src/test/java/org/springframework/web/reactive/config/DelegatingWebFluxConfigurationTests.java
.../reactive/config/DelegatingWebFluxConfigurationTests.java
+1
-3
spring-webflux/src/test/java/org/springframework/web/reactive/config/WebFluxConfigurationSupportTests.java
...web/reactive/config/WebFluxConfigurationSupportTests.java
+2
-2
spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyExtractorsTests.java
...gframework/web/reactive/function/BodyExtractorsTests.java
+1
-1
spring-webflux/src/test/java/org/springframework/web/reactive/function/MultipartIntegrationTests.java
...work/web/reactive/function/MultipartIntegrationTests.java
+1
-5
spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultClientResponseTests.java
.../reactive/function/client/DefaultClientResponseTests.java
+11
-11
spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultEntityResponseBuilderTests.java
...ve/function/server/DefaultEntityResponseBuilderTests.java
+0
-17
spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerRequestTests.java
...b/reactive/function/server/DefaultServerRequestTests.java
+5
-12
spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/RouterFunctionMappingTests.java
...e/function/server/support/RouterFunctionMappingTests.java
+3
-40
spring-webflux/src/test/java/org/springframework/web/reactive/handler/SimpleUrlHandlerMappingTests.java
...rk/web/reactive/handler/SimpleUrlHandlerMappingTests.java
+5
-2
spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceUrlProviderTests.java
...ework/web/reactive/resource/ResourceUrlProviderTests.java
+2
-2
spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ProducesRequestConditionTests.java
...ctive/result/condition/ProducesRequestConditionTests.java
+1
-2
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/CookieValueMethodArgumentResolverTests.java
...od/annotation/CookieValueMethodArgumentResolverTests.java
+2
-1
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ExpressionValueMethodArgumentResolverTests.java
...nnotation/ExpressionValueMethodArgumentResolverTests.java
+1
-0
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/HttpEntityArgumentResolverTests.java
...lt/method/annotation/HttpEntityArgumentResolverTests.java
+2
-2
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelAttributeMethodArgumentResolverTests.java
...annotation/ModelAttributeMethodArgumentResolverTests.java
+1
-0
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelInitializerTests.java
...ctive/result/method/annotation/ModelInitializerTests.java
+2
-5
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestAttributeMethodArgumentResolverTests.java
...notation/RequestAttributeMethodArgumentResolverTests.java
+2
-1
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestBodyArgumentResolverTests.java
...t/method/annotation/RequestBodyArgumentResolverTests.java
+2
-2
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMethodArgumentResolverTests.java
.../annotation/RequestHeaderMethodArgumentResolverTests.java
+2
-1
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingExceptionHandlingIntegrationTests.java
...tion/RequestMappingExceptionHandlingIntegrationTests.java
+1
-3
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributeMethodArgumentResolverTests.java
...notation/SessionAttributeMethodArgumentResolverTests.java
+2
-1
spring-webflux/src/test/java/org/springframework/web/reactive/result/view/AbstractViewTests.java
...framework/web/reactive/result/view/AbstractViewTests.java
+31
-37
未找到文件。
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractMessageWriterResultHandler.java
浏览文件 @
2575c260
...
...
@@ -110,7 +110,7 @@ public abstract class AbstractMessageWriterResultHandler extends HandlerResultHa
* @return indicates completion or error
* @since 5.0.2
*/
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
{
"unchecked"
,
"rawtypes"
}
)
protected
Mono
<
Void
>
writeBody
(
@Nullable
Object
body
,
MethodParameter
bodyParameter
,
@Nullable
MethodParameter
actualParameter
,
ServerWebExchange
exchange
)
{
...
...
spring-webflux/src/main/java/org/springframework/web/reactive/socket/adapter/TomcatWebSocketSession.java
浏览文件 @
2575c260
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -38,6 +38,7 @@ public class TomcatWebSocketSession extends StandardWebSocketSession {
private
static
final
AtomicIntegerFieldUpdater
<
TomcatWebSocketSession
>
SUSPENDED
=
AtomicIntegerFieldUpdater
.
newUpdater
(
TomcatWebSocketSession
.
class
,
"suspended"
);
@SuppressWarnings
(
"unused"
)
private
volatile
int
suspended
;
...
...
spring-webflux/src/test/java/org/springframework/web/reactive/accept/HeaderContentTypeResolverTests.java
浏览文件 @
2575c260
/*
* Copyright 2002-201
6
the original author or authors.
* Copyright 2002-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -13,18 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.web.reactive.accept
;
import
java.util.List
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.springframework.http.MediaType
;
import
org.springframework.mock.http.server.reactive.test.MockServerHttpRequest
;
import
org.springframework.mock.web.test.server.MockServerWebExchange
;
import
org.springframework.web.server.NotAcceptableStatusException
;
import
org.springframework.web.server.ServerWebExchange
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
...
...
@@ -35,13 +34,7 @@ import static org.junit.Assert.assertEquals;
*/
public
class
HeaderContentTypeResolverTests
{
private
HeaderContentTypeResolver
resolver
;
@Before
public
void
setup
()
{
this
.
resolver
=
new
HeaderContentTypeResolver
();
}
private
final
HeaderContentTypeResolver
resolver
=
new
HeaderContentTypeResolver
();
@Test
...
...
spring-webflux/src/test/java/org/springframework/web/reactive/config/DelegatingWebFluxConfigurationTests.java
浏览文件 @
2575c260
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -27,14 +27,12 @@ import org.mockito.Mock;
import
org.mockito.MockitoAnnotations
;
import
org.springframework.context.support.StaticApplicationContext
;
import
org.springframework.core.convert.ConversionService
;
import
org.springframework.format.FormatterRegistry
;
import
org.springframework.http.codec.HttpMessageWriter
;
import
org.springframework.http.codec.ServerCodecConfigurer
;
import
org.springframework.validation.beanvalidation.LocalValidatorFactoryBean
;
import
org.springframework.web.bind.support.ConfigurableWebBindingInitializer
;
import
org.springframework.web.reactive.accept.RequestedContentTypeResolverBuilder
;
import
org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
mockito
.
BDDMockito
.*;
...
...
spring-webflux/src/test/java/org/springframework/web/reactive/config/WebFluxConfigurationSupportTests.java
浏览文件 @
2575c260
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -305,7 +305,7 @@ public class WebFluxConfigurationSupportTests {
@Override
protected
void
configureHttpMessageCodecs
(
ServerCodecConfigurer
configurer
)
{
configurer
.
registerDefaults
(
false
);
configurer
.
customCodecs
().
decoder
(
StringDecoder
.
textPlainOnly
(
true
));
configurer
.
customCodecs
().
decoder
(
StringDecoder
.
textPlainOnly
());
configurer
.
customCodecs
().
decoder
(
new
Jaxb2XmlDecoder
());
configurer
.
customCodecs
().
encoder
(
CharSequenceEncoder
.
textPlainOnly
());
configurer
.
customCodecs
().
encoder
(
new
Jaxb2XmlEncoder
());
...
...
spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyExtractorsTests.java
浏览文件 @
2575c260
...
...
@@ -76,7 +76,7 @@ public class BodyExtractorsTests {
public
void
createContext
()
{
final
List
<
HttpMessageReader
<?>>
messageReaders
=
new
ArrayList
<>();
messageReaders
.
add
(
new
DecoderHttpMessageReader
<>(
new
ByteBufferDecoder
()));
messageReaders
.
add
(
new
DecoderHttpMessageReader
<>(
StringDecoder
.
allMimeTypes
(
true
)));
messageReaders
.
add
(
new
DecoderHttpMessageReader
<>(
StringDecoder
.
allMimeTypes
()));
messageReaders
.
add
(
new
DecoderHttpMessageReader
<>(
new
Jaxb2XmlDecoder
()));
messageReaders
.
add
(
new
DecoderHttpMessageReader
<>(
new
Jackson2JsonDecoder
()));
messageReaders
.
add
(
new
FormHttpMessageReader
());
...
...
spring-webflux/src/test/java/org/springframework/web/reactive/function/MultipartIntegrationTests.java
浏览文件 @
2575c260
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -23,16 +23,12 @@ import reactor.core.publisher.Mono;
import
reactor.test.StepVerifier
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.core.io.Resource
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.client.MultipartBodyBuilder
;
import
org.springframework.http.codec.multipart.FilePart
;
import
org.springframework.http.codec.multipart.FormFieldPart
;
import
org.springframework.http.codec.multipart.Part
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.web.reactive.function.client.ClientResponse
;
import
org.springframework.web.reactive.function.client.WebClient
;
...
...
spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultClientResponseTests.java
浏览文件 @
2575c260
...
...
@@ -127,7 +127,7 @@ public class DefaultClientResponseTests {
when
(
mockResponse
.
getBody
()).
thenReturn
(
body
);
List
<
HttpMessageReader
<?>>
messageReaders
=
Collections
.
singletonList
(
new
DecoderHttpMessageReader
<>(
StringDecoder
.
allMimeTypes
(
true
)));
.
singletonList
(
new
DecoderHttpMessageReader
<>(
StringDecoder
.
allMimeTypes
()));
when
(
mockExchangeStrategies
.
messageReaders
()).
thenReturn
(
messageReaders
);
Mono
<
String
>
resultMono
=
defaultClientResponse
.
body
(
toMono
(
String
.
class
));
...
...
@@ -148,7 +148,7 @@ public class DefaultClientResponseTests {
when
(
mockResponse
.
getBody
()).
thenReturn
(
body
);
List
<
HttpMessageReader
<?>>
messageReaders
=
Collections
.
singletonList
(
new
DecoderHttpMessageReader
<>(
StringDecoder
.
allMimeTypes
(
true
)));
.
singletonList
(
new
DecoderHttpMessageReader
<>(
StringDecoder
.
allMimeTypes
()));
when
(
mockExchangeStrategies
.
messageReaders
()).
thenReturn
(
messageReaders
);
Mono
<
String
>
resultMono
=
defaultClientResponse
.
bodyToMono
(
String
.
class
);
...
...
@@ -169,7 +169,7 @@ public class DefaultClientResponseTests {
when
(
mockResponse
.
getBody
()).
thenReturn
(
body
);
List
<
HttpMessageReader
<?>>
messageReaders
=
Collections
.
singletonList
(
new
DecoderHttpMessageReader
<>(
StringDecoder
.
allMimeTypes
(
true
)));
.
singletonList
(
new
DecoderHttpMessageReader
<>(
StringDecoder
.
allMimeTypes
()));
when
(
mockExchangeStrategies
.
messageReaders
()).
thenReturn
(
messageReaders
);
Mono
<
String
>
resultMono
=
...
...
@@ -192,7 +192,7 @@ public class DefaultClientResponseTests {
when
(
mockResponse
.
getBody
()).
thenReturn
(
body
);
List
<
HttpMessageReader
<?>>
messageReaders
=
Collections
.
singletonList
(
new
DecoderHttpMessageReader
<>(
StringDecoder
.
allMimeTypes
(
true
)));
.
singletonList
(
new
DecoderHttpMessageReader
<>(
StringDecoder
.
allMimeTypes
()));
when
(
mockExchangeStrategies
.
messageReaders
()).
thenReturn
(
messageReaders
);
Flux
<
String
>
resultFlux
=
defaultClientResponse
.
bodyToFlux
(
String
.
class
);
...
...
@@ -214,7 +214,7 @@ public class DefaultClientResponseTests {
when
(
mockResponse
.
getBody
()).
thenReturn
(
body
);
List
<
HttpMessageReader
<?>>
messageReaders
=
Collections
.
singletonList
(
new
DecoderHttpMessageReader
<>(
StringDecoder
.
allMimeTypes
(
true
)));
.
singletonList
(
new
DecoderHttpMessageReader
<>(
StringDecoder
.
allMimeTypes
()));
when
(
mockExchangeStrategies
.
messageReaders
()).
thenReturn
(
messageReaders
);
Flux
<
String
>
resultFlux
=
...
...
@@ -238,7 +238,7 @@ public class DefaultClientResponseTests {
when
(
mockResponse
.
getBody
()).
thenReturn
(
body
);
List
<
HttpMessageReader
<?>>
messageReaders
=
Collections
.
singletonList
(
new
DecoderHttpMessageReader
<>(
StringDecoder
.
allMimeTypes
(
true
)));
.
singletonList
(
new
DecoderHttpMessageReader
<>(
StringDecoder
.
allMimeTypes
()));
when
(
mockExchangeStrategies
.
messageReaders
()).
thenReturn
(
messageReaders
);
ResponseEntity
<
String
>
result
=
defaultClientResponse
.
toEntity
(
String
.
class
).
block
();
...
...
@@ -261,7 +261,7 @@ public class DefaultClientResponseTests {
when
(
mockResponse
.
getBody
()).
thenReturn
(
body
);
List
<
HttpMessageReader
<?>>
messageReaders
=
Collections
.
singletonList
(
new
DecoderHttpMessageReader
<>(
StringDecoder
.
allMimeTypes
(
true
)));
.
singletonList
(
new
DecoderHttpMessageReader
<>(
StringDecoder
.
allMimeTypes
()));
when
(
mockExchangeStrategies
.
messageReaders
()).
thenReturn
(
messageReaders
);
ResponseEntity
<
String
>
result
=
defaultClientResponse
.
toEntity
(
...
...
@@ -286,7 +286,7 @@ public class DefaultClientResponseTests {
when
(
mockResponse
.
getBody
()).
thenReturn
(
body
);
List
<
HttpMessageReader
<?>>
messageReaders
=
Collections
.
singletonList
(
new
DecoderHttpMessageReader
<>(
StringDecoder
.
allMimeTypes
(
true
)));
.
singletonList
(
new
DecoderHttpMessageReader
<>(
StringDecoder
.
allMimeTypes
()));
when
(
mockExchangeStrategies
.
messageReaders
()).
thenReturn
(
messageReaders
);
ResponseEntity
<
List
<
String
>>
result
=
defaultClientResponse
.
toEntityList
(
String
.
class
).
block
();
...
...
@@ -309,7 +309,7 @@ public class DefaultClientResponseTests {
when
(
mockResponse
.
getBody
()).
thenReturn
(
body
);
List
<
HttpMessageReader
<?>>
messageReaders
=
Collections
.
singletonList
(
new
DecoderHttpMessageReader
<>(
StringDecoder
.
allMimeTypes
(
true
)));
.
singletonList
(
new
DecoderHttpMessageReader
<>(
StringDecoder
.
allMimeTypes
()));
when
(
mockExchangeStrategies
.
messageReaders
()).
thenReturn
(
messageReaders
);
ResponseEntity
<
List
<
String
>>
result
=
defaultClientResponse
.
toEntityList
(
...
...
@@ -331,7 +331,7 @@ public class DefaultClientResponseTests {
when
(
mockResponse
.
getBody
()).
thenReturn
(
body
.
flux
());
List
<
HttpMessageReader
<?>>
messageReaders
=
Collections
.
singletonList
(
new
DecoderHttpMessageReader
<>(
StringDecoder
.
allMimeTypes
(
true
)));
.
singletonList
(
new
DecoderHttpMessageReader
<>(
StringDecoder
.
allMimeTypes
()));
when
(
mockExchangeStrategies
.
messageReaders
()).
thenReturn
(
messageReaders
);
StepVerifier
.
create
(
defaultClientResponse
.
bodyToMono
(
Void
.
class
))
...
...
@@ -356,7 +356,7 @@ public class DefaultClientResponseTests {
when
(
mockResponse
.
getBody
()).
thenReturn
(
body
.
flux
());
List
<
HttpMessageReader
<?>>
messageReaders
=
Collections
.
singletonList
(
new
DecoderHttpMessageReader
<>(
StringDecoder
.
allMimeTypes
(
true
)));
.
singletonList
(
new
DecoderHttpMessageReader
<>(
StringDecoder
.
allMimeTypes
()));
when
(
mockExchangeStrategies
.
messageReaders
()).
thenReturn
(
messageReaders
);
StepVerifier
.
create
(
defaultClientResponse
.
bodyToMono
(
Void
.
class
))
...
...
spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultEntityResponseBuilderTests.java
浏览文件 @
2575c260
...
...
@@ -16,7 +16,6 @@
package
org.springframework.web.reactive.function.server
;
import
java.nio.ByteBuffer
;
import
java.time.ZonedDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.time.temporal.ChronoUnit
;
...
...
@@ -24,7 +23,6 @@ import java.util.Collections;
import
java.util.EnumSet
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.function.BiFunction
;
import
org.junit.Test
;
import
org.reactivestreams.Publisher
;
...
...
@@ -34,8 +32,6 @@ import reactor.test.StepVerifier;
import
org.springframework.core.ParameterizedTypeReference
;
import
org.springframework.core.codec.CharSequenceEncoder
;
import
org.springframework.core.io.buffer.DataBuffer
;
import
org.springframework.core.io.buffer.DefaultDataBufferFactory
;
import
org.springframework.http.CacheControl
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpMethod
;
...
...
@@ -44,16 +40,13 @@ import org.springframework.http.MediaType;
import
org.springframework.http.ResponseCookie
;
import
org.springframework.http.codec.EncoderHttpMessageWriter
;
import
org.springframework.http.codec.HttpMessageWriter
;
import
org.springframework.http.server.reactive.ServerHttpResponse
;
import
org.springframework.mock.http.server.reactive.test.MockServerHttpRequest
;
import
org.springframework.mock.http.server.reactive.test.MockServerHttpResponse
;
import
org.springframework.mock.web.test.server.MockServerWebExchange
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.web.reactive.function.BodyInserter
;
import
org.springframework.web.reactive.result.view.ViewResolver
;
import
static
java
.
nio
.
charset
.
StandardCharsets
.
UTF_8
;
import
static
org
.
junit
.
Assert
.*;
/**
...
...
@@ -135,7 +128,6 @@ public class DefaultEntityResponseBuilderTests {
.
verify
();
}
@Test
public
void
lastModified
()
throws
Exception
{
ZonedDateTime
now
=
ZonedDateTime
.
now
();
...
...
@@ -197,14 +189,6 @@ public class DefaultEntityResponseBuilderTests {
public
void
bodyInserter
()
throws
Exception
{
String
body
=
"foo"
;
Publisher
<
String
>
publisher
=
Mono
.
just
(
body
);
BiFunction
<
ServerHttpResponse
,
BodyInserter
.
Context
,
Mono
<
Void
>>
writer
=
(
response
,
strategies
)
->
{
byte
[]
bodyBytes
=
body
.
getBytes
(
UTF_8
);
ByteBuffer
byteBuffer
=
ByteBuffer
.
wrap
(
bodyBytes
);
DataBuffer
buffer
=
new
DefaultDataBufferFactory
().
wrap
(
byteBuffer
);
return
response
.
writeWith
(
Mono
.
just
(
buffer
));
};
Mono
<
EntityResponse
<
Publisher
<
String
>>>
result
=
EntityResponse
.
fromPublisher
(
publisher
,
String
.
class
).
build
();
...
...
@@ -257,7 +241,6 @@ public class DefaultEntityResponseBuilderTests {
.
verify
();
}
@Test
public
void
notModifiedLastModified
()
{
ZonedDateTime
now
=
ZonedDateTime
.
now
();
...
...
spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerRequestTests.java
浏览文件 @
2575c260
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -27,7 +27,6 @@ import java.util.Map;
import
java.util.Optional
;
import
java.util.OptionalLong
;
import
org.junit.Before
;
import
org.junit.Test
;
import
reactor.core.publisher.Flux
;
import
reactor.core.publisher.Mono
;
...
...
@@ -59,14 +58,8 @@ import static org.springframework.web.reactive.function.BodyExtractors.toMono;
*/
public
class
DefaultServerRequestTests
{
List
<
HttpMessageReader
<?>>
messageReaders
;
@Before
public
void
createMocks
()
{
this
.
messageReaders
=
Collections
.
singletonList
(
new
DecoderHttpMessageReader
<>(
StringDecoder
.
allMimeTypes
(
true
)));
}
private
final
List
<
HttpMessageReader
<?>>
messageReaders
=
Collections
.
singletonList
(
new
DecoderHttpMessageReader
<>(
StringDecoder
.
allMimeTypes
()));
@Test
...
...
@@ -335,12 +328,12 @@ public class DefaultServerRequestTests {
.
method
(
HttpMethod
.
GET
,
"http://example.com?foo=bar"
)
.
headers
(
httpHeaders
)
.
body
(
body
);
this
.
messageReaders
=
Collections
.
emptyList
();
DefaultServerRequest
request
=
new
DefaultServerRequest
(
MockServerWebExchange
.
from
(
mockRequest
),
messageReaders
);
DefaultServerRequest
request
=
new
DefaultServerRequest
(
MockServerWebExchange
.
from
(
mockRequest
),
Collections
.
emptyList
());
Flux
<
String
>
resultFlux
=
request
.
bodyToFlux
(
String
.
class
);
StepVerifier
.
create
(
resultFlux
)
.
expectError
(
UnsupportedMediaTypeStatusException
.
class
)
.
verify
();
}
}
spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/RouterFunctionMappingTests.java
浏览文件 @
2575c260
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -16,26 +16,15 @@
package
org.springframework.web.reactive.function.server.support
;
import
java.util.Collections
;
import
java.util.List
;
import
org.junit.Before
;
import
org.junit.Test
;
import
reactor.core.publisher.Mono
;
import
reactor.test.StepVerifier
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.codec.ByteBufferDecoder
;
import
org.springframework.http.codec.DecoderHttpMessageReader
;
import
org.springframework.http.codec.HttpMessageReader
;
import
org.springframework.http.codec.ServerCodecConfigurer
;
import
org.springframework.mock.http.server.reactive.test.MockServerHttpRequest
;
import
org.springframework.mock.web.test.server.MockServerWebExchange
;
import
org.springframework.web.reactive.config.EnableWebFlux
;
import
org.springframework.web.reactive.function.server.HandlerFunction
;
import
org.springframework.web.reactive.function.server.RequestPredicates
;
import
org.springframework.web.reactive.function.server.RouterFunction
;
import
org.springframework.web.reactive.function.server.RouterFunctions
;
import
org.springframework.web.reactive.function.server.ServerResponse
;
import
org.springframework.web.server.ServerWebExchange
;
...
...
@@ -44,20 +33,10 @@ import org.springframework.web.server.ServerWebExchange;
*/
public
class
RouterFunctionMappingTests
{
private
final
ServerWebExchange
exchange
=
MockServerWebExchange
.
from
(
MockServerHttpRequest
.
get
(
"http://example.com/match"
));
private
List
<
HttpMessageReader
<?>>
messageReaders
;
private
ServerWebExchange
exchange
;
private
ServerCodecConfigurer
codecConfigurer
;
private
final
ServerCodecConfigurer
codecConfigurer
=
ServerCodecConfigurer
.
create
();
@Before
public
void
setUp
()
{
this
.
messageReaders
=
Collections
.
singletonList
(
new
DecoderHttpMessageReader
<>(
new
ByteBufferDecoder
()));
this
.
exchange
=
MockServerWebExchange
.
from
(
MockServerHttpRequest
.
get
(
"http://example.com/match"
));
codecConfigurer
=
ServerCodecConfigurer
.
create
();
}
@Test
public
void
normal
()
{
...
...
@@ -88,20 +67,4 @@ public class RouterFunctionMappingTests {
.
verify
();
}
@Configuration
@EnableWebFlux
private
static
class
TestConfig
{
public
RouterFunction
<
ServerResponse
>
match
()
{
HandlerFunction
<
ServerResponse
>
handlerFunction
=
request
->
ServerResponse
.
ok
().
build
();
return
RouterFunctions
.
route
(
RequestPredicates
.
GET
(
"/match"
),
handlerFunction
);
}
public
RouterFunction
<
ServerResponse
>
noMatch
()
{
HandlerFunction
<
ServerResponse
>
handlerFunction
=
request
->
ServerResponse
.
ok
().
build
();
RouterFunction
<
ServerResponse
>
routerFunction
=
request
->
Mono
.
empty
();
return
RouterFunctions
.
route
(
RequestPredicates
.
GET
(
"/no-match"
),
handlerFunction
);
}
}
}
\ No newline at end of file
spring-webflux/src/test/java/org/springframework/web/reactive/handler/SimpleUrlHandlerMappingTests.java
浏览文件 @
2575c260
/*
* Copyright 2002-201
6
the original author or authors.
* Copyright 2002-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.web.reactive.handler
;
import
java.net.URI
;
...
...
@@ -44,6 +45,7 @@ import static org.springframework.web.reactive.HandlerMapping.PATH_WITHIN_HANDLE
public
class
SimpleUrlHandlerMappingTests
{
@Test
@SuppressWarnings
(
"resource"
)
public
void
handlerMappingJavaConfig
()
throws
Exception
{
AnnotationConfigApplicationContext
wac
=
new
AnnotationConfigApplicationContext
();
wac
.
register
(
WebConfig
.
class
);
...
...
@@ -61,6 +63,7 @@ public class SimpleUrlHandlerMappingTests {
}
@Test
@SuppressWarnings
(
"resource"
)
public
void
handlerMappingXmlConfig
()
throws
Exception
{
ClassPathXmlApplicationContext
wac
=
new
ClassPathXmlApplicationContext
(
"map.xml"
,
getClass
());
wac
.
refresh
();
...
...
@@ -118,7 +121,7 @@ public class SimpleUrlHandlerMappingTests {
@Configuration
static
class
WebConfig
{
@Bean
@SuppressWarnings
(
"unused"
)
public
SimpleUrlHandlerMapping
handlerMapping
()
{
SimpleUrlHandlerMapping
hm
=
new
SimpleUrlHandlerMapping
();
...
...
spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceUrlProviderTests.java
浏览文件 @
2575c260
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -42,7 +42,6 @@ import org.springframework.web.util.pattern.PathPattern;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertThat
;
/**
* Unit tests for {@link ResourceUrlProvider}.
*
...
...
@@ -133,6 +132,7 @@ public class ResourceUrlProviderTests {
}
@Test
// SPR-12592
@SuppressWarnings
(
"resource"
)
public
void
initializeOnce
()
throws
Exception
{
AnnotationConfigWebApplicationContext
context
=
new
AnnotationConfigWebApplicationContext
();
context
.
setServletContext
(
new
MockServletContext
());
...
...
spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ProducesRequestConditionTests.java
浏览文件 @
2575c260
/*
* Copyright 2002-201
6
the original author or authors.
* Copyright 2002-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -21,7 +21,6 @@ import java.util.Collections;
import
org.junit.Test
;
import
org.springframework.mock.http.server.reactive.test.MockServerHttpRequest
;
import
org.springframework.mock.web.test.server.MockServerWebExchange
;
import
org.springframework.web.server.ServerWebExchange
;
...
...
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/CookieValueMethodArgumentResolverTests.java
浏览文件 @
2575c260
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -58,6 +58,7 @@ public class CookieValueMethodArgumentResolverTests {
@Before
@SuppressWarnings
(
"resource"
)
public
void
setup
()
throws
Exception
{
AnnotationConfigApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
context
.
refresh
();
...
...
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ExpressionValueMethodArgumentResolverTests.java
浏览文件 @
2575c260
...
...
@@ -53,6 +53,7 @@ public class ExpressionValueMethodArgumentResolverTests {
@Before
@SuppressWarnings
(
"resource"
)
public
void
setup
()
throws
Exception
{
AnnotationConfigApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
context
.
refresh
();
...
...
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/HttpEntityArgumentResolverTests.java
浏览文件 @
2575c260
...
...
@@ -62,14 +62,14 @@ import static org.springframework.mock.http.server.reactive.test.MockServerHttpR
*/
public
class
HttpEntityArgumentResolverTests
{
private
HttpEntityArgumentResolver
resolver
=
createResolver
();
private
final
HttpEntityArgumentResolver
resolver
=
createResolver
();
private
final
ResolvableMethod
testMethod
=
ResolvableMethod
.
on
(
getClass
()).
named
(
"handle"
).
build
();
private
HttpEntityArgumentResolver
createResolver
()
{
List
<
HttpMessageReader
<?>>
readers
=
new
ArrayList
<>();
readers
.
add
(
new
DecoderHttpMessageReader
<>(
StringDecoder
.
allMimeTypes
(
true
)));
readers
.
add
(
new
DecoderHttpMessageReader
<>(
StringDecoder
.
allMimeTypes
()));
return
new
HttpEntityArgumentResolver
(
readers
,
ReactiveAdapterRegistry
.
getSharedInstance
());
}
...
...
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelAttributeMethodArgumentResolverTests.java
浏览文件 @
2575c260
...
...
@@ -361,6 +361,7 @@ public class ModelAttributeMethodArgumentResolverTests {
}
@SuppressWarnings
(
"unused"
)
private
static
class
Bar
{
private
final
String
name
;
...
...
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelInitializerTests.java
浏览文件 @
2575c260
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -43,7 +43,6 @@ import org.springframework.web.bind.annotation.GetMapping;
import
org.springframework.web.bind.annotation.InitBinder
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.SessionAttributes
;
import
org.springframework.web.bind.support.ConfigurableWebBindingInitializer
;
import
org.springframework.web.bind.support.WebBindingInitializer
;
...
...
@@ -61,6 +60,7 @@ import static org.mockito.Mockito.mock;
/**
* Unit tests for {@link ModelInitializer}.
*
* @author Rossen Stoyanchev
*/
public
class
ModelInitializerTests
{
...
...
@@ -298,7 +298,4 @@ public class ModelInitializerTests {
private
static
final
ReflectionUtils
.
MethodFilter
BINDER_METHODS
=
method
->
AnnotationUtils
.
findAnnotation
(
method
,
InitBinder
.
class
)
!=
null
;
private
static
final
ReflectionUtils
.
MethodFilter
ATTRIBUTE_METHODS
=
method
->
(
AnnotationUtils
.
findAnnotation
(
method
,
RequestMapping
.
class
)
==
null
)
&&
(
AnnotationUtils
.
findAnnotation
(
method
,
ModelAttribute
.
class
)
!=
null
);
}
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestAttributeMethodArgumentResolverTests.java
浏览文件 @
2575c260
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -61,6 +61,7 @@ public class RequestAttributeMethodArgumentResolverTests {
@Before
@SuppressWarnings
(
"resource"
)
public
void
setup
()
throws
Exception
{
AnnotationConfigApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
context
.
refresh
();
...
...
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestBodyArgumentResolverTests.java
浏览文件 @
2575c260
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -69,7 +69,7 @@ public class RequestBodyArgumentResolverTests {
@Before
public
void
setup
()
{
List
<
HttpMessageReader
<?>>
readers
=
new
ArrayList
<>();
readers
.
add
(
new
DecoderHttpMessageReader
<>(
StringDecoder
.
allMimeTypes
(
true
)));
readers
.
add
(
new
DecoderHttpMessageReader
<>(
StringDecoder
.
allMimeTypes
()));
this
.
resolver
=
new
RequestBodyArgumentResolver
(
readers
,
ReactiveAdapterRegistry
.
getSharedInstance
());
}
...
...
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMethodArgumentResolverTests.java
浏览文件 @
2575c260
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -70,6 +70,7 @@ public class RequestHeaderMethodArgumentResolverTests {
@Before
@SuppressWarnings
(
"resource"
)
public
void
setup
()
throws
Exception
{
AnnotationConfigApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
context
.
refresh
();
...
...
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingExceptionHandlingIntegrationTests.java
浏览文件 @
2575c260
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -18,7 +18,6 @@ package org.springframework.web.reactive.result.method.annotation;
import
java.io.IOException
;
import
org.junit.Assume
;
import
org.junit.Test
;
import
org.reactivestreams.Publisher
;
import
reactor.core.publisher.Flux
;
...
...
@@ -30,7 +29,6 @@ import org.springframework.context.annotation.ComponentScan;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.server.reactive.bootstrap.ReactorHttpServer
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RestController
;
...
...
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributeMethodArgumentResolverTests.java
浏览文件 @
2575c260
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -72,6 +72,7 @@ public class SessionAttributeMethodArgumentResolverTests {
@Before
@SuppressWarnings
(
"resource"
)
public
void
setup
()
throws
Exception
{
AnnotationConfigApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
context
.
refresh
();
...
...
spring-webflux/src/test/java/org/springframework/web/reactive/result/view/AbstractViewTests.java
浏览文件 @
2575c260
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -22,7 +22,6 @@ import java.util.Map;
import
io.reactivex.Observable
;
import
io.reactivex.Single
;
import
org.junit.Before
;
import
org.junit.Test
;
import
reactor.core.publisher.Flux
;
import
reactor.core.publisher.Mono
;
...
...
@@ -45,52 +44,47 @@ import static org.junit.Assert.assertNull;
*/
public
class
AbstractViewTests
{
private
MockServerWebExchange
exchange
;
private
MockServerWebExchange
exchange
=
MockServerWebExchange
.
from
(
MockServerHttpRequest
.
get
(
"/"
))
;
@Before
public
void
setup
()
{
this
.
exchange
=
MockServerWebExchange
.
from
(
MockServerHttpRequest
.
get
(
"/"
));
}
@SuppressWarnings
(
"unchecked"
)
@Test
public
void
resolveAsyncAttributes
()
{
@Test
@SuppressWarnings
(
"unchecked"
)
public
void
resolveAsyncAttributes
()
{
TestBean
testBean1
=
new
TestBean
(
"Bean1"
);
TestBean
testBean2
=
new
TestBean
(
"Bean2"
);
Map
<
String
,
Object
>
attributes
=
new
HashMap
<>();
attributes
.
put
(
"attr1"
,
Mono
.
just
(
testBean1
));
attributes
.
put
(
"attr2"
,
Flux
.
just
(
testBean1
,
testBean2
));
attributes
.
put
(
"attr3"
,
Single
.
just
(
testBean2
));
attributes
.
put
(
"attr4"
,
Observable
.
just
(
testBean1
,
testBean2
));
attributes
.
put
(
"attr5"
,
Mono
.
empty
());
TestBean
testBean1
=
new
TestBean
(
"Bean1"
);
TestBean
testBean2
=
new
TestBean
(
"Bean2"
);
Map
<
String
,
Object
>
attributes
=
new
HashMap
<>();
attributes
.
put
(
"attr1"
,
Mono
.
just
(
testBean1
));
attributes
.
put
(
"attr2"
,
Flux
.
just
(
testBean1
,
testBean2
));
attributes
.
put
(
"attr3"
,
Single
.
just
(
testBean2
));
attributes
.
put
(
"attr4"
,
Observable
.
just
(
testBean1
,
testBean2
));
attributes
.
put
(
"attr5"
,
Mono
.
empty
());
TestView
view
=
new
TestView
();
StepVerifier
.
create
(
view
.
render
(
attributes
,
null
,
this
.
exchange
)).
verifyComplete
();
TestView
view
=
new
TestView
();
StepVerifier
.
create
(
view
.
render
(
attributes
,
null
,
this
.
exchange
)).
verifyComplete
();
Map
<
String
,
Object
>
actual
=
view
.
attributes
;
assertEquals
(
testBean1
,
actual
.
get
(
"attr1"
));
assertArrayEquals
(
new
TestBean
[]
{
testBean1
,
testBean2
},
((
List
<
TestBean
>)
actual
.
get
(
"attr2"
)).
toArray
());
assertEquals
(
testBean2
,
actual
.
get
(
"attr3"
));
assertArrayEquals
(
new
TestBean
[]
{
testBean1
,
testBean2
},
((
List
<
TestBean
>)
actual
.
get
(
"attr4"
)).
toArray
());
assertNull
(
actual
.
get
(
"attr5"
));
}
assertArrayEquals
(
new
TestBean
[]
{
testBean1
,
testBean2
},
((
List
<
TestBean
>)
actual
.
get
(
"attr2"
)).
toArray
());
assertEquals
(
testBean2
,
actual
.
get
(
"attr3"
));
assertArrayEquals
(
new
TestBean
[]
{
testBean1
,
testBean2
},
((
List
<
TestBean
>)
actual
.
get
(
"attr4"
)).
toArray
());
assertNull
(
actual
.
get
(
"attr5"
));
}
private
static
class
TestView
extends
AbstractView
{
private
static
class
TestView
extends
AbstractView
{
private
Map
<
String
,
Object
>
attributes
;
private
Map
<
String
,
Object
>
attributes
;
@Override
protected
Mono
<
Void
>
renderInternal
(
Map
<
String
,
Object
>
renderAttributes
,
@Override
protected
Mono
<
Void
>
renderInternal
(
Map
<
String
,
Object
>
renderAttributes
,
MediaType
contentType
,
ServerWebExchange
exchange
)
{
this
.
attributes
=
renderAttributes
;
return
Mono
.
empty
();
}
this
.
attributes
=
renderAttributes
;
return
Mono
.
empty
();
}
}
public
Map
<
String
,
Object
>
getAttributes
()
{
return
this
.
attributes
;
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录