Skip to content

Commit d0cf90b

Browse files
committed
Update tests due to deprecations in Reactor
1 parent 01b7951 commit d0cf90b

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

spring-web/src/test/java/org/springframework/web/filter/reactive/ServerWebExchangeContextFilterTests.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.web.filter.reactive;
1718

1819
import java.time.Duration;
@@ -33,10 +34,10 @@
3334
* Unit tests for {@link ServerWebExchangeContextFilter}.
3435
* @author Rossen Stoyanchev
3536
*/
36-
public class ServerWebExchangeContextFilterTests {
37+
class ServerWebExchangeContextFilterTests {
3738

3839
@Test
39-
public void extractServerWebExchangeFromContext() {
40+
void extractServerWebExchangeFromContext() {
4041
MyService service = new MyService();
4142

4243
HttpHandler httpHandler = WebHttpHandlerBuilder
@@ -61,7 +62,7 @@ public ServerWebExchange getExchange() {
6162
}
6263

6364
public Mono<String> service() {
64-
return Mono.just("result").subscriberContext(context -> {
65+
return Mono.just("result").contextWrite(context -> {
6566
ServerWebExchangeContextFilter.get(context).ifPresent(exchangeRef::set);
6667
return context;
6768
});

spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ErrorsMethodArgumentResolverTests.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@
2121
import org.junit.jupiter.api.Test;
2222
import reactor.core.publisher.Mono;
2323
import reactor.core.publisher.MonoProcessor;
24+
import reactor.core.publisher.Sinks;
2425

2526
import org.springframework.core.MethodParameter;
2627
import org.springframework.core.ReactiveAdapterRegistry;
@@ -42,7 +43,7 @@
4243
*
4344
* @author Rossen Stoyanchev
4445
*/
45-
public class ErrorsMethodArgumentResolverTests {
46+
class ErrorsMethodArgumentResolverTests {
4647

4748
private final ErrorsMethodArgumentResolver resolver =
4849
new ErrorsMethodArgumentResolver(ReactiveAdapterRegistry.getSharedInstance());
@@ -56,7 +57,7 @@ public class ErrorsMethodArgumentResolverTests {
5657

5758

5859
@Test
59-
public void supports() {
60+
void supports() {
6061
MethodParameter parameter = this.testMethod.arg(Errors.class);
6162
assertThat(this.resolver.supportsParameter(parameter)).isTrue();
6263

@@ -71,7 +72,7 @@ public void supports() {
7172
}
7273

7374
@Test
74-
public void resolve() {
75+
void resolve() {
7576
BindingResult bindingResult = createBindingResult(new Foo(), "foo");
7677
this.bindingContext.getModel().asMap().put(BindingResult.MODEL_KEY_PREFIX + "foo", bindingResult);
7778

@@ -88,9 +89,9 @@ private BindingResult createBindingResult(Foo target, String name) {
8889
}
8990

9091
@Test
91-
public void resolveWithMono() {
92+
void resolveWithMono() {
9293
BindingResult bindingResult = createBindingResult(new Foo(), "foo");
93-
MonoProcessor<BindingResult> monoProcessor = MonoProcessor.create();
94+
MonoProcessor<BindingResult> monoProcessor = MonoProcessor.fromSink(Sinks.one());
9495
monoProcessor.onNext(bindingResult);
9596
this.bindingContext.getModel().asMap().put(BindingResult.MODEL_KEY_PREFIX + "foo", monoProcessor);
9697

@@ -102,7 +103,7 @@ public void resolveWithMono() {
102103
}
103104

104105
@Test
105-
public void resolveWithMonoOnBindingResultAndModelAttribute() {
106+
void resolveWithMonoOnBindingResultAndModelAttribute() {
106107
MethodParameter parameter = this.testMethod.arg(BindingResult.class);
107108
assertThatIllegalStateException().isThrownBy(() ->
108109
this.resolver.resolveArgument(parameter, this.bindingContext, this.exchange)
@@ -112,7 +113,7 @@ public void resolveWithMonoOnBindingResultAndModelAttribute() {
112113
}
113114

114115
@Test // SPR-16187
115-
public void resolveWithBindingResultNotFound() {
116+
void resolveWithBindingResultNotFound() {
116117
MethodParameter parameter = this.testMethod.arg(Errors.class);
117118
assertThatIllegalStateException().isThrownBy(() ->
118119
this.resolver.resolveArgument(parameter, this.bindingContext, this.exchange)

spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ReactiveTypeHandlerTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public void deferredResultSubscriberWithOneValue() throws Exception {
125125

126126
@Test
127127
public void deferredResultSubscriberWithNoValues() throws Exception {
128-
MonoProcessor<String> monoEmpty = MonoProcessor.create();
128+
MonoProcessor<String> monoEmpty = MonoProcessor.fromSink(Sinks.one());
129129
testDeferredResultSubscriber(monoEmpty, Mono.class, forClass(String.class), monoEmpty::onComplete, null);
130130
}
131131

@@ -152,7 +152,7 @@ public void deferredResultSubscriberWithError() throws Exception {
152152
IllegalStateException ex = new IllegalStateException();
153153

154154
// Mono
155-
MonoProcessor<String> mono = MonoProcessor.create();
155+
MonoProcessor<String> mono = MonoProcessor.fromSink(Sinks.one());
156156
testDeferredResultSubscriber(mono, Mono.class, forClass(String.class), () -> mono.onError(ex), ex);
157157

158158
// RxJava Single

0 commit comments

Comments
 (0)