Update tests due to deprecations in Reactor
This commit is contained in:
parent
01b79514da
commit
d0cf90bb8e
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.filter.reactive;
|
||||
|
||||
import java.time.Duration;
|
||||
|
|
@ -33,10 +34,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
* Unit tests for {@link ServerWebExchangeContextFilter}.
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class ServerWebExchangeContextFilterTests {
|
||||
class ServerWebExchangeContextFilterTests {
|
||||
|
||||
@Test
|
||||
public void extractServerWebExchangeFromContext() {
|
||||
void extractServerWebExchangeFromContext() {
|
||||
MyService service = new MyService();
|
||||
|
||||
HttpHandler httpHandler = WebHttpHandlerBuilder
|
||||
|
|
@ -61,7 +62,7 @@ public class ServerWebExchangeContextFilterTests {
|
|||
}
|
||||
|
||||
public Mono<String> service() {
|
||||
return Mono.just("result").subscriberContext(context -> {
|
||||
return Mono.just("result").contextWrite(context -> {
|
||||
ServerWebExchangeContextFilter.get(context).ifPresent(exchangeRef::set);
|
||||
return context;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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,6 +21,7 @@ import java.time.Duration;
|
|||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.core.publisher.MonoProcessor;
|
||||
import reactor.core.publisher.Sinks;
|
||||
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.ReactiveAdapterRegistry;
|
||||
|
|
@ -42,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
|||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class ErrorsMethodArgumentResolverTests {
|
||||
class ErrorsMethodArgumentResolverTests {
|
||||
|
||||
private final ErrorsMethodArgumentResolver resolver =
|
||||
new ErrorsMethodArgumentResolver(ReactiveAdapterRegistry.getSharedInstance());
|
||||
|
|
@ -56,7 +57,7 @@ public class ErrorsMethodArgumentResolverTests {
|
|||
|
||||
|
||||
@Test
|
||||
public void supports() {
|
||||
void supports() {
|
||||
MethodParameter parameter = this.testMethod.arg(Errors.class);
|
||||
assertThat(this.resolver.supportsParameter(parameter)).isTrue();
|
||||
|
||||
|
|
@ -71,7 +72,7 @@ public class ErrorsMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolve() {
|
||||
void resolve() {
|
||||
BindingResult bindingResult = createBindingResult(new Foo(), "foo");
|
||||
this.bindingContext.getModel().asMap().put(BindingResult.MODEL_KEY_PREFIX + "foo", bindingResult);
|
||||
|
||||
|
|
@ -88,9 +89,9 @@ public class ErrorsMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveWithMono() {
|
||||
void resolveWithMono() {
|
||||
BindingResult bindingResult = createBindingResult(new Foo(), "foo");
|
||||
MonoProcessor<BindingResult> monoProcessor = MonoProcessor.create();
|
||||
MonoProcessor<BindingResult> monoProcessor = MonoProcessor.fromSink(Sinks.one());
|
||||
monoProcessor.onNext(bindingResult);
|
||||
this.bindingContext.getModel().asMap().put(BindingResult.MODEL_KEY_PREFIX + "foo", monoProcessor);
|
||||
|
||||
|
|
@ -102,7 +103,7 @@ public class ErrorsMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolveWithMonoOnBindingResultAndModelAttribute() {
|
||||
void resolveWithMonoOnBindingResultAndModelAttribute() {
|
||||
MethodParameter parameter = this.testMethod.arg(BindingResult.class);
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
this.resolver.resolveArgument(parameter, this.bindingContext, this.exchange)
|
||||
|
|
@ -112,7 +113,7 @@ public class ErrorsMethodArgumentResolverTests {
|
|||
}
|
||||
|
||||
@Test // SPR-16187
|
||||
public void resolveWithBindingResultNotFound() {
|
||||
void resolveWithBindingResultNotFound() {
|
||||
MethodParameter parameter = this.testMethod.arg(Errors.class);
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
this.resolver.resolveArgument(parameter, this.bindingContext, this.exchange)
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ public class ReactiveTypeHandlerTests {
|
|||
|
||||
@Test
|
||||
public void deferredResultSubscriberWithNoValues() throws Exception {
|
||||
MonoProcessor<String> monoEmpty = MonoProcessor.create();
|
||||
MonoProcessor<String> monoEmpty = MonoProcessor.fromSink(Sinks.one());
|
||||
testDeferredResultSubscriber(monoEmpty, Mono.class, forClass(String.class), monoEmpty::onComplete, null);
|
||||
}
|
||||
|
||||
|
|
@ -152,7 +152,7 @@ public class ReactiveTypeHandlerTests {
|
|||
IllegalStateException ex = new IllegalStateException();
|
||||
|
||||
// Mono
|
||||
MonoProcessor<String> mono = MonoProcessor.create();
|
||||
MonoProcessor<String> mono = MonoProcessor.fromSink(Sinks.one());
|
||||
testDeferredResultSubscriber(mono, Mono.class, forClass(String.class), () -> mono.onError(ex), ex);
|
||||
|
||||
// RxJava Single
|
||||
|
|
|
|||
Loading…
Reference in New Issue