Update to latest Reactor snapshot
This commit is contained in:
@@ -45,10 +45,10 @@ public class ReactiveStreamsToCompletableFutureConverter implements GenericConve
|
||||
return null;
|
||||
}
|
||||
else if (CompletableFuture.class.isAssignableFrom(source.getClass())) {
|
||||
return Mono.fromCompletableFuture((CompletableFuture)source);
|
||||
return Mono.fromFuture((CompletableFuture) source);
|
||||
}
|
||||
else if (CompletableFuture.class.isAssignableFrom(targetType.getResolvableType().getRawClass())) {
|
||||
return Mono.from((Publisher)source).toCompletableFuture();
|
||||
return Mono.from((Publisher) source).toFuture();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class ChannelSendOperatorTests {
|
||||
public void errorBeforeFirstItem() throws Exception {
|
||||
IllegalStateException error = new IllegalStateException("boo");
|
||||
Mono<Void> completion = Mono.<String>error(error).as(this::sendOperator);
|
||||
Signal<Void> signal = completion.materialize().get();
|
||||
Signal<Void> signal = completion.materialize().block();
|
||||
|
||||
assertNotNull(signal);
|
||||
assertSame("Unexpected signal: " + signal, error, signal.getThrowable());
|
||||
@@ -66,7 +66,7 @@ public class ChannelSendOperatorTests {
|
||||
@Test
|
||||
public void completionBeforeFirstItem() throws Exception {
|
||||
Mono<Void> completion = Flux.<String>empty().as(this::sendOperator);
|
||||
Signal<Void> signal = completion.materialize().get();
|
||||
Signal<Void> signal = completion.materialize().block();
|
||||
|
||||
assertNotNull(signal);
|
||||
assertTrue("Unexpected signal: " + signal, signal.isOnComplete());
|
||||
@@ -78,7 +78,7 @@ public class ChannelSendOperatorTests {
|
||||
@Test
|
||||
public void writeOneItem() throws Exception {
|
||||
Mono<Void> completion = Flux.just("one").as(this::sendOperator);
|
||||
Signal<Void> signal = completion.materialize().get();
|
||||
Signal<Void> signal = completion.materialize().block();
|
||||
|
||||
assertNotNull(signal);
|
||||
assertTrue("Unexpected signal: " + signal, signal.isOnComplete());
|
||||
@@ -93,7 +93,7 @@ public class ChannelSendOperatorTests {
|
||||
public void writeMultipleItems() throws Exception {
|
||||
List<String> items = Arrays.asList("one", "two", "three");
|
||||
Mono<Void> completion = Flux.fromIterable(items).as(this::sendOperator);
|
||||
Signal<Void> signal = completion.materialize().get();
|
||||
Signal<Void> signal = completion.materialize().block();
|
||||
|
||||
assertNotNull(signal);
|
||||
assertTrue("Unexpected signal: " + signal, signal.isOnComplete());
|
||||
@@ -117,7 +117,7 @@ public class ChannelSendOperatorTests {
|
||||
return i;
|
||||
});
|
||||
Mono<Void> completion = publisher.as(this::sendOperator);
|
||||
Signal<Void> signal = completion.materialize().get();
|
||||
Signal<Void> signal = completion.materialize().block();
|
||||
|
||||
assertNotNull(signal);
|
||||
assertSame("Unexpected signal: " + signal, error, signal.getThrowable());
|
||||
|
||||
@@ -45,7 +45,7 @@ public class ServerHttpResponseTests {
|
||||
@Test
|
||||
public void writeWith() throws Exception {
|
||||
TestServerHttpResponse response = new TestServerHttpResponse();
|
||||
response.writeWith(Flux.just(wrap("a"), wrap("b"), wrap("c"))).get();
|
||||
response.writeWith(Flux.just(wrap("a"), wrap("b"), wrap("c"))).block();
|
||||
|
||||
assertTrue(response.headersWritten);
|
||||
assertTrue(response.cookiesWritten);
|
||||
@@ -60,7 +60,7 @@ public class ServerHttpResponseTests {
|
||||
public void writeWithError() throws Exception {
|
||||
TestServerHttpResponse response = new TestServerHttpResponse();
|
||||
IllegalStateException error = new IllegalStateException("boo");
|
||||
response.writeWith(Flux.error(error)).otherwise(ex -> Mono.empty()).get();
|
||||
response.writeWith(Flux.error(error)).otherwise(ex -> Mono.empty()).block();
|
||||
|
||||
assertFalse(response.headersWritten);
|
||||
assertFalse(response.cookiesWritten);
|
||||
@@ -70,7 +70,7 @@ public class ServerHttpResponseTests {
|
||||
@Test
|
||||
public void setComplete() throws Exception {
|
||||
TestServerHttpResponse response = new TestServerHttpResponse();
|
||||
response.setComplete().get();
|
||||
response.setComplete().block();
|
||||
|
||||
assertTrue(response.headersWritten);
|
||||
assertTrue(response.cookiesWritten);
|
||||
@@ -85,7 +85,7 @@ public class ServerHttpResponseTests {
|
||||
response.getCookies().add(cookie.getName(), cookie);
|
||||
return Mono.empty();
|
||||
});
|
||||
response.writeWith(Flux.just(wrap("a"), wrap("b"), wrap("c"))).get();
|
||||
response.writeWith(Flux.just(wrap("a"), wrap("b"), wrap("c"))).block();
|
||||
|
||||
assertTrue(response.headersWritten);
|
||||
assertTrue(response.cookiesWritten);
|
||||
@@ -102,7 +102,7 @@ public class ServerHttpResponseTests {
|
||||
TestServerHttpResponse response = new TestServerHttpResponse();
|
||||
IllegalStateException error = new IllegalStateException("boo");
|
||||
response.beforeCommit(() -> Mono.error(error));
|
||||
response.writeWith(Flux.just(wrap("a"), wrap("b"), wrap("c"))).get();
|
||||
response.writeWith(Flux.just(wrap("a"), wrap("b"), wrap("c"))).block();
|
||||
|
||||
assertTrue("beforeCommit action errors should be ignored", response.headersWritten);
|
||||
assertTrue("beforeCommit action errors should be ignored", response.cookiesWritten);
|
||||
@@ -122,7 +122,7 @@ public class ServerHttpResponseTests {
|
||||
response.getCookies().add(cookie.getName(), cookie);
|
||||
return Mono.empty();
|
||||
});
|
||||
response.setComplete().get();
|
||||
response.setComplete().block();
|
||||
|
||||
assertTrue(response.headersWritten);
|
||||
assertTrue(response.cookiesWritten);
|
||||
|
||||
@@ -191,7 +191,7 @@ public class DispatcherHandlerErrorTests {
|
||||
WebHandler webHandler = new ExceptionHandlingWebHandler(this.dispatcherHandler, exceptionHandler);
|
||||
Mono<Void> publisher = webHandler.handle(this.exchange);
|
||||
|
||||
publisher.get();
|
||||
publisher.block();
|
||||
assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, this.response.getStatus());
|
||||
}
|
||||
|
||||
@@ -203,13 +203,13 @@ public class DispatcherHandlerErrorTests {
|
||||
webHandler = new ExceptionHandlingWebHandler(webHandler, new ServerError500ExceptionHandler());
|
||||
Mono<Void> publisher = webHandler.handle(this.exchange);
|
||||
|
||||
publisher.get();
|
||||
publisher.block();
|
||||
assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, this.response.getStatus());
|
||||
}
|
||||
|
||||
|
||||
private Throwable awaitErrorSignal(Mono<?> mono) throws Exception {
|
||||
Signal<?> signal = mono.materialize().get();
|
||||
Signal<?> signal = mono.materialize().block();
|
||||
assertEquals("Unexpected signal: " + signal, SignalKind.onError, signal.getType());
|
||||
return signal.getThrowable();
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class ResponseStatusExceptionHandlerTests {
|
||||
Throwable ex = new ResponseStatusException(HttpStatus.BAD_REQUEST, "");
|
||||
Mono<Void> publisher = this.handler.handle(this.exchange, ex);
|
||||
|
||||
publisher.get();
|
||||
publisher.block();
|
||||
assertEquals(HttpStatus.BAD_REQUEST, this.response.getStatus());
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class ResponseStatusExceptionHandlerTests {
|
||||
Throwable ex = new IllegalStateException();
|
||||
Mono<Void> publisher = this.handler.handle(this.exchange, ex);
|
||||
|
||||
Signal<Void> signal = publisher.materialize().get();
|
||||
Signal<Void> signal = publisher.materialize().block();
|
||||
assertNotNull(signal);
|
||||
assertTrue(signal.hasError());
|
||||
assertSame(ex, signal.getThrowable());
|
||||
|
||||
@@ -108,7 +108,7 @@ public class SimpleUrlHandlerMappingTests {
|
||||
throws URISyntaxException {
|
||||
|
||||
ServerWebExchange exchange = createExchange(url);
|
||||
Object actual = handlerMapping.getHandler(exchange).get();
|
||||
Object actual = handlerMapping.getHandler(exchange).block();
|
||||
if (bean != null) {
|
||||
assertNotNull(actual);
|
||||
assertSame(bean, actual);
|
||||
|
||||
@@ -84,7 +84,7 @@ public class HandlerMethodMappingTests {
|
||||
this.mapping.registerMapping(key, this.handler, this.method1);
|
||||
|
||||
Mono<Object> result = this.mapping.getHandler(createExchange(HttpMethod.GET, key));
|
||||
assertEquals(this.method1, ((HandlerMethod) result.get()).getMethod());
|
||||
assertEquals(this.method1, ((HandlerMethod) result.block()).getMethod());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -93,7 +93,7 @@ public class HandlerMethodMappingTests {
|
||||
this.mapping.registerMapping("/f*", this.handler, this.method2);
|
||||
|
||||
Mono<Object> result = this.mapping.getHandler(createExchange(HttpMethod.GET, "/foo"));
|
||||
assertEquals(this.method1, ((HandlerMethod) result.get()).getMethod());
|
||||
assertEquals(this.method1, ((HandlerMethod) result.block()).getMethod());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -140,11 +140,11 @@ public class HandlerMethodMappingTests {
|
||||
String key = "foo";
|
||||
this.mapping.registerMapping(key, this.handler, this.method1);
|
||||
Mono<Object> result = this.mapping.getHandler(createExchange(HttpMethod.GET, key));
|
||||
assertNotNull(result.get());
|
||||
assertNotNull(result.block());
|
||||
|
||||
this.mapping.unregisterMapping(key);
|
||||
result = this.mapping.getHandler(createExchange(HttpMethod.GET, key));
|
||||
assertNull(result.get());
|
||||
assertNull(result.block());
|
||||
assertNull(this.mapping.getMappingRegistry().getMappingsByUrl(key));
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ public class InvocableHandlerMethodTests {
|
||||
new RequestParamMethodArgumentResolver(new GenericConversionService(), null, false)));
|
||||
|
||||
Mono<HandlerResult> mono = hm.invokeForRequest(this.exchange, this.model);
|
||||
HandlerResult value = mono.get();
|
||||
HandlerResult value = mono.block();
|
||||
|
||||
assertNotNull(value);
|
||||
assertEquals("success:null", value.getReturnValue().get());
|
||||
@@ -102,7 +102,7 @@ public class InvocableHandlerMethodTests {
|
||||
addResolver(hm, Mono.just("value1"));
|
||||
|
||||
Mono<HandlerResult> mono = hm.invokeForRequest(this.exchange, this.model);
|
||||
HandlerResult value = mono.get();
|
||||
HandlerResult value = mono.block();
|
||||
|
||||
assertNotNull(value);
|
||||
assertEquals("success:value1", value.getReturnValue().get());
|
||||
@@ -114,7 +114,7 @@ public class InvocableHandlerMethodTests {
|
||||
addResolver(hm, Flux.fromIterable(Arrays.asList("value1", "value2", "value3")));
|
||||
|
||||
Mono<HandlerResult> mono = hm.invokeForRequest(this.exchange, this.model);
|
||||
HandlerResult value = mono.get();
|
||||
HandlerResult value = mono.block();
|
||||
|
||||
assertNotNull(value);
|
||||
assertEquals("success:value1", value.getReturnValue().get());
|
||||
|
||||
@@ -368,7 +368,7 @@ public class RequestMappingInfoHandlerMappingTests {
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
private HandlerMethod getHandler(ServerWebExchange exchange) throws Exception {
|
||||
Mono<Object> handler = this.handlerMapping.getHandler(exchange);
|
||||
return (HandlerMethod) handler.get();
|
||||
return (HandlerMethod) handler.block();
|
||||
}
|
||||
|
||||
private void testHttpMediaTypeNotSupportedException(String url) throws Exception {
|
||||
@@ -389,7 +389,7 @@ public class RequestMappingInfoHandlerMappingTests {
|
||||
ModelMap model = new ExtendedModelMap();
|
||||
Mono<HandlerResult> mono = new InvocableHandlerMethod(handlerMethod).invokeForRequest(exchange, model);
|
||||
|
||||
HandlerResult result = mono.get();
|
||||
HandlerResult result = mono.block();
|
||||
assertNotNull(result);
|
||||
|
||||
Optional<Object> value = result.getReturnValue();
|
||||
|
||||
@@ -103,7 +103,7 @@ public abstract class AbstractRequestAttributesArgumentResolverTests {
|
||||
Foo foo = new Foo();
|
||||
this.exchange.getAttributes().put("foo", foo);
|
||||
mono = this.resolver.resolveArgument(param, null, this.exchange);
|
||||
assertSame(foo, mono.get());
|
||||
assertSame(foo, mono.block());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -112,36 +112,36 @@ public abstract class AbstractRequestAttributesArgumentResolverTests {
|
||||
Foo foo = new Foo();
|
||||
this.exchange.getAttributes().put("specialFoo", foo);
|
||||
Mono<Object> mono = this.resolver.resolveArgument(param, null, this.exchange);
|
||||
assertSame(foo, mono.get());
|
||||
assertSame(foo, mono.block());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveNotRequired() throws Exception {
|
||||
MethodParameter param = initMethodParameter(2);
|
||||
Mono<Object> mono = this.resolver.resolveArgument(param, null, this.exchange);
|
||||
assertNull(mono.get());
|
||||
assertNull(mono.block());
|
||||
|
||||
Foo foo = new Foo();
|
||||
this.exchange.getAttributes().put("foo", foo);
|
||||
mono = this.resolver.resolveArgument(param, null, this.exchange);
|
||||
assertSame(foo, mono.get());
|
||||
assertSame(foo, mono.block());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveOptional() throws Exception {
|
||||
MethodParameter param = initMethodParameter(3);
|
||||
Mono<Object> mono = this.resolver.resolveArgument(param, null, this.exchange);
|
||||
assertNotNull(mono.get());
|
||||
assertEquals(Optional.class, mono.get().getClass());
|
||||
assertFalse(((Optional) mono.get()).isPresent());
|
||||
assertNotNull(mono.block());
|
||||
assertEquals(Optional.class, mono.block().getClass());
|
||||
assertFalse(((Optional) mono.block()).isPresent());
|
||||
|
||||
Foo foo = new Foo();
|
||||
this.exchange.getAttributes().put("foo", foo);
|
||||
mono = this.resolver.resolveArgument(param, null, this.exchange);
|
||||
|
||||
assertNotNull(mono.get());
|
||||
assertEquals(Optional.class, mono.get().getClass());
|
||||
Optional optional = (Optional) mono.get();
|
||||
assertNotNull(mono.block());
|
||||
assertEquals(Optional.class, mono.block().getClass());
|
||||
Optional optional = (Optional) mono.block();
|
||||
assertTrue(optional.isPresent());
|
||||
assertSame(foo, optional.get());
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public class CookieValueMethodArgumentResolverTests {
|
||||
this.exchange.getRequest().getCookies().add(expected.getName(), expected);
|
||||
|
||||
Mono<Object> mono = this.resolver.resolveArgument(this.cookieParameter, null, this.exchange);
|
||||
assertEquals(expected, mono.get());
|
||||
assertEquals(expected, mono.block());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -101,13 +101,13 @@ public class CookieValueMethodArgumentResolverTests {
|
||||
this.exchange.getRequest().getCookies().add(cookie.getName(), cookie);
|
||||
|
||||
Mono<Object> mono = this.resolver.resolveArgument(this.cookieStringParameter, null, this.exchange);
|
||||
assertEquals("Invalid result", cookie.getValue(), mono.get());
|
||||
assertEquals("Invalid result", cookie.getValue(), mono.block());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveCookieDefaultValue() {
|
||||
Mono<Object> mono = this.resolver.resolveArgument(this.cookieStringParameter, null, this.exchange);
|
||||
Object result = mono.get();
|
||||
Object result = mono.block();
|
||||
|
||||
assertTrue(result instanceof String);
|
||||
assertEquals("bar", result);
|
||||
|
||||
@@ -84,7 +84,7 @@ public class ExpressionValueMethodArgumentResolverTests {
|
||||
System.setProperty("systemProperty", "22");
|
||||
try {
|
||||
Mono<Object> mono = this.resolver.resolveArgument(this.paramSystemProperty, null, this.exchange);
|
||||
Object value = mono.get();
|
||||
Object value = mono.block();
|
||||
assertEquals(22, value);
|
||||
}
|
||||
finally {
|
||||
|
||||
@@ -88,7 +88,7 @@ public class PathVariableMapMethodArgumentResolverTests {
|
||||
this.exchange.getAttributes().put(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, uriTemplateVars);
|
||||
|
||||
Mono<Object> mono = this.resolver.resolveArgument(this.paramMap, new ModelMap(), this.exchange);
|
||||
Object result = mono.get();
|
||||
Object result = mono.block();
|
||||
|
||||
assertEquals(uriTemplateVars, result);
|
||||
}
|
||||
@@ -96,7 +96,7 @@ public class PathVariableMapMethodArgumentResolverTests {
|
||||
@Test
|
||||
public void resolveArgumentNoUriVars() throws Exception {
|
||||
Mono<Object> mono = this.resolver.resolveArgument(this.paramMap, new ModelMap(), this.exchange);
|
||||
Object result = mono.get();
|
||||
Object result = mono.block();
|
||||
|
||||
assertEquals(Collections.emptyMap(), result);
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ public class PathVariableMethodArgumentResolverTests {
|
||||
this.exchange.getAttributes().put(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, uriTemplateVars);
|
||||
|
||||
Mono<Object> mono = this.resolver.resolveArgument(this.paramNamedString, new ModelMap(), this.exchange);
|
||||
Object result = mono.get();
|
||||
Object result = mono.block();
|
||||
|
||||
assertTrue(result instanceof String);
|
||||
assertEquals("value", result);
|
||||
|
||||
@@ -97,7 +97,7 @@ public class RequestAttributeMethodArgumentResolverTests {
|
||||
Foo foo = new Foo();
|
||||
this.exchange.getAttributes().put("foo", foo);
|
||||
mono = this.resolver.resolveArgument(param, null, this.exchange);
|
||||
assertSame(foo, mono.get());
|
||||
assertSame(foo, mono.block());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -106,36 +106,36 @@ public class RequestAttributeMethodArgumentResolverTests {
|
||||
Foo foo = new Foo();
|
||||
this.exchange.getAttributes().put("specialFoo", foo);
|
||||
Mono<Object> mono = this.resolver.resolveArgument(param, null, this.exchange);
|
||||
assertSame(foo, mono.get());
|
||||
assertSame(foo, mono.block());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveNotRequired() throws Exception {
|
||||
MethodParameter param = initMethodParameter(2);
|
||||
Mono<Object> mono = this.resolver.resolveArgument(param, null, this.exchange);
|
||||
assertNull(mono.get());
|
||||
assertNull(mono.block());
|
||||
|
||||
Foo foo = new Foo();
|
||||
this.exchange.getAttributes().put("foo", foo);
|
||||
mono = this.resolver.resolveArgument(param, null, this.exchange);
|
||||
assertSame(foo, mono.get());
|
||||
assertSame(foo, mono.block());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveOptional() throws Exception {
|
||||
MethodParameter param = initMethodParameter(3);
|
||||
Mono<Object> mono = this.resolver.resolveArgument(param, null, this.exchange);
|
||||
assertNotNull(mono.get());
|
||||
assertEquals(Optional.class, mono.get().getClass());
|
||||
assertFalse(((Optional) mono.get()).isPresent());
|
||||
assertNotNull(mono.block());
|
||||
assertEquals(Optional.class, mono.block().getClass());
|
||||
assertFalse(((Optional) mono.block()).isPresent());
|
||||
|
||||
Foo foo = new Foo();
|
||||
this.exchange.getAttributes().put("foo", foo);
|
||||
mono = this.resolver.resolveArgument(param, null, this.exchange);
|
||||
|
||||
assertNotNull(mono.get());
|
||||
assertEquals(Optional.class, mono.get().getClass());
|
||||
Optional optional = (Optional) mono.get();
|
||||
assertNotNull(mono.block());
|
||||
assertEquals(Optional.class, mono.block().getClass());
|
||||
Optional optional = (Optional) mono.block();
|
||||
assertTrue(optional.isPresent());
|
||||
assertSame(foo, optional.get());
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ public class RequestHeaderMapMethodArgumentResolverTests {
|
||||
this.exchange.getRequest().getHeaders().add(name, value);
|
||||
|
||||
Mono<Object> mono = this.resolver.resolveArgument(paramMap, null, this.exchange);
|
||||
Object result = mono.get();
|
||||
Object result = mono.block();
|
||||
|
||||
assertTrue(result instanceof Map);
|
||||
assertEquals("Invalid result", expected, result);
|
||||
@@ -113,7 +113,7 @@ public class RequestHeaderMapMethodArgumentResolverTests {
|
||||
expected.add(name, value2);
|
||||
|
||||
Mono<Object> mono = this.resolver.resolveArgument(paramMultiValueMap, null, this.exchange);
|
||||
Object result = mono.get();
|
||||
Object result = mono.block();
|
||||
|
||||
assertTrue(result instanceof MultiValueMap);
|
||||
assertEquals("Invalid result", expected, result);
|
||||
@@ -133,7 +133,7 @@ public class RequestHeaderMapMethodArgumentResolverTests {
|
||||
expected.add(name, value2);
|
||||
|
||||
Mono<Object> mono = this.resolver.resolveArgument(paramHttpHeaders, null, this.exchange);
|
||||
Object result = mono.get();
|
||||
Object result = mono.block();
|
||||
|
||||
assertTrue(result instanceof HttpHeaders);
|
||||
assertEquals("Invalid result", expected, result);
|
||||
|
||||
@@ -109,7 +109,7 @@ public class RequestHeaderMethodArgumentResolverTests {
|
||||
this.exchange.getRequest().getHeaders().add("name", expected);
|
||||
|
||||
Mono<Object> mono = this.resolver.resolveArgument(paramNamedDefaultValueStringHeader, null, this.exchange);
|
||||
Object result = mono.get();
|
||||
Object result = mono.block();
|
||||
assertTrue(result instanceof String);
|
||||
assertEquals(expected, result);
|
||||
}
|
||||
@@ -120,7 +120,7 @@ public class RequestHeaderMethodArgumentResolverTests {
|
||||
this.exchange.getRequest().getHeaders().put("name", Arrays.asList(expected));
|
||||
|
||||
Mono<Object> mono = this.resolver.resolveArgument(paramNamedValueStringArray, null, this.exchange);
|
||||
Object result = mono.get();
|
||||
Object result = mono.block();
|
||||
assertTrue(result instanceof String[]);
|
||||
assertArrayEquals(expected, (String[]) result);
|
||||
}
|
||||
@@ -128,7 +128,7 @@ public class RequestHeaderMethodArgumentResolverTests {
|
||||
@Test
|
||||
public void resolveDefaultValue() throws Exception {
|
||||
Mono<Object> mono = this.resolver.resolveArgument(paramNamedDefaultValueStringHeader, null, this.exchange);
|
||||
Object result = mono.get();
|
||||
Object result = mono.block();
|
||||
assertTrue(result instanceof String);
|
||||
assertEquals("bar", result);
|
||||
}
|
||||
@@ -138,7 +138,7 @@ public class RequestHeaderMethodArgumentResolverTests {
|
||||
System.setProperty("systemProperty", "bar");
|
||||
try {
|
||||
Mono<Object> mono = this.resolver.resolveArgument(paramSystemProperty, null, this.exchange);
|
||||
Object result = mono.get();
|
||||
Object result = mono.block();
|
||||
assertTrue(result instanceof String);
|
||||
assertEquals("bar", result);
|
||||
}
|
||||
@@ -155,7 +155,7 @@ public class RequestHeaderMethodArgumentResolverTests {
|
||||
System.setProperty("systemProperty", "bar");
|
||||
try {
|
||||
Mono<Object> mono = this.resolver.resolveArgument(paramResolvedNameWithExpression, null, this.exchange);
|
||||
Object result = mono.get();
|
||||
Object result = mono.block();
|
||||
assertTrue(result instanceof String);
|
||||
assertEquals(expected, result);
|
||||
}
|
||||
@@ -172,7 +172,7 @@ public class RequestHeaderMethodArgumentResolverTests {
|
||||
System.setProperty("systemProperty", "bar");
|
||||
try {
|
||||
Mono<Object> mono = this.resolver.resolveArgument(paramResolvedNameWithPlaceholder, null, this.exchange);
|
||||
Object result = mono.get();
|
||||
Object result = mono.block();
|
||||
assertTrue(result instanceof String);
|
||||
assertEquals(expected, result);
|
||||
}
|
||||
@@ -196,7 +196,7 @@ public class RequestHeaderMethodArgumentResolverTests {
|
||||
this.exchange.getRequest().getHeaders().add("name", rfc1123val);
|
||||
|
||||
Mono<Object> mono = this.resolver.resolveArgument(paramDate, null, this.exchange);
|
||||
Object result = mono.get();
|
||||
Object result = mono.block();
|
||||
|
||||
assertTrue(result instanceof Date);
|
||||
assertEquals(new Date(rfc1123val), result);
|
||||
@@ -208,7 +208,7 @@ public class RequestHeaderMethodArgumentResolverTests {
|
||||
this.exchange.getRequest().getHeaders().add("name", rfc1123val);
|
||||
|
||||
Mono<Object> mono = this.resolver.resolveArgument(paramInstant, null, this.exchange);
|
||||
Object result = mono.get();
|
||||
Object result = mono.block();
|
||||
|
||||
assertTrue(result instanceof Instant);
|
||||
assertEquals(Instant.from(DateTimeFormatter.RFC_1123_DATE_TIME.parse(rfc1123val)), result);
|
||||
|
||||
@@ -94,7 +94,7 @@ public class RequestParamMapMethodArgumentResolverTests {
|
||||
Map<String, String> expected = Collections.singletonMap(name, value);
|
||||
|
||||
Mono<Object> mono = resolver.resolveArgument(paramMap, null, exchange);
|
||||
Object result = mono.get();
|
||||
Object result = mono.block();
|
||||
|
||||
assertTrue(result instanceof Map);
|
||||
assertEquals(expected, result);
|
||||
@@ -112,7 +112,7 @@ public class RequestParamMapMethodArgumentResolverTests {
|
||||
expected.add(name, value2);
|
||||
|
||||
Mono<Object> mono = this.resolver.resolveArgument(this.paramMultiValueMap, null, this.exchange);
|
||||
Object result = mono.get();
|
||||
Object result = mono.block();
|
||||
|
||||
assertTrue(result instanceof MultiValueMap);
|
||||
assertEquals(expected, result);
|
||||
|
||||
@@ -119,7 +119,7 @@ public class RequestParamMethodArgumentResolverTests {
|
||||
this.exchange.getRequest().getQueryParams().set("name", expected);
|
||||
|
||||
Mono<Object> mono = this.resolver.resolveArgument(this.paramNamedDefaultValueString, null, this.exchange);
|
||||
Object result = mono.get();
|
||||
Object result = mono.block();
|
||||
|
||||
assertTrue(result instanceof String);
|
||||
assertEquals("Invalid result", expected, result);
|
||||
@@ -131,7 +131,7 @@ public class RequestParamMethodArgumentResolverTests {
|
||||
this.exchange.getRequest().getQueryParams().put("name", Arrays.asList(expected));
|
||||
|
||||
Mono<Object> mono = this.resolver.resolveArgument(this.paramNamedStringArray, null, this.exchange);
|
||||
Object result = mono.get();
|
||||
Object result = mono.block();
|
||||
|
||||
assertTrue(result instanceof String[]);
|
||||
assertArrayEquals(expected, (String[]) result);
|
||||
@@ -140,7 +140,7 @@ public class RequestParamMethodArgumentResolverTests {
|
||||
@Test
|
||||
public void resolveDefaultValue() throws Exception {
|
||||
Mono<Object> mono = this.resolver.resolveArgument(paramNamedDefaultValueString, null, this.exchange);
|
||||
Object result = mono.get();
|
||||
Object result = mono.block();
|
||||
|
||||
assertTrue(result instanceof String);
|
||||
assertEquals("Invalid result", "bar", result);
|
||||
@@ -158,7 +158,7 @@ public class RequestParamMethodArgumentResolverTests {
|
||||
public void resolveSimpleTypeParam() throws Exception {
|
||||
this.exchange.getRequest().getQueryParams().set("stringNotAnnot", "plainValue");
|
||||
Mono<Object> mono = this.resolver.resolveArgument(paramStringNotAnnot, null, this.exchange);
|
||||
Object result = mono.get();
|
||||
Object result = mono.block();
|
||||
|
||||
assertTrue(result instanceof String);
|
||||
assertEquals("plainValue", result);
|
||||
@@ -167,7 +167,7 @@ public class RequestParamMethodArgumentResolverTests {
|
||||
@Test // SPR-8561
|
||||
public void resolveSimpleTypeParamToNull() throws Exception {
|
||||
Mono<Object> mono = this.resolver.resolveArgument(paramStringNotAnnot, null, this.exchange);
|
||||
Object result = mono.get();
|
||||
Object result = mono.block();
|
||||
|
||||
assertNull(result);
|
||||
}
|
||||
@@ -176,7 +176,7 @@ public class RequestParamMethodArgumentResolverTests {
|
||||
public void resolveEmptyValueToDefault() throws Exception {
|
||||
this.exchange.getRequest().getQueryParams().set("name", "");
|
||||
Mono<Object> mono = this.resolver.resolveArgument(paramNamedDefaultValueString, null, this.exchange);
|
||||
Object result = mono.get();
|
||||
Object result = mono.block();
|
||||
|
||||
assertEquals("bar", result);
|
||||
}
|
||||
@@ -185,7 +185,7 @@ public class RequestParamMethodArgumentResolverTests {
|
||||
public void resolveEmptyValueWithoutDefault() throws Exception {
|
||||
this.exchange.getRequest().getQueryParams().set("stringNotAnnot", "");
|
||||
Mono<Object> mono = this.resolver.resolveArgument(paramStringNotAnnot, null, this.exchange);
|
||||
Object result = mono.get();
|
||||
Object result = mono.block();
|
||||
|
||||
assertEquals("", result);
|
||||
}
|
||||
@@ -194,7 +194,7 @@ public class RequestParamMethodArgumentResolverTests {
|
||||
public void resolveEmptyValueRequiredWithoutDefault() throws Exception {
|
||||
this.exchange.getRequest().getQueryParams().set("name", "");
|
||||
Mono<Object> mono = this.resolver.resolveArgument(paramRequired, null, this.exchange);
|
||||
Object result = mono.get();
|
||||
Object result = mono.block();
|
||||
|
||||
assertEquals("", result);
|
||||
}
|
||||
@@ -202,13 +202,13 @@ public class RequestParamMethodArgumentResolverTests {
|
||||
@Test
|
||||
public void resolveOptionalParamValue() throws Exception {
|
||||
Mono<Object> mono = this.resolver.resolveArgument(paramOptional, null, this.exchange);
|
||||
Object result = mono.get();
|
||||
Object result = mono.block();
|
||||
|
||||
assertEquals(Optional.empty(), result);
|
||||
|
||||
this.exchange.getRequest().getQueryParams().set("name", "123");
|
||||
mono = resolver.resolveArgument(paramOptional, null, this.exchange);
|
||||
result = mono.get();
|
||||
result = mono.block();
|
||||
|
||||
assertEquals(Optional.class, result.getClass());
|
||||
Optional<?> value = (Optional<?>) result;
|
||||
|
||||
@@ -24,8 +24,6 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.print.attribute.standard.Media;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.reactivestreams.Publisher;
|
||||
|
||||
@@ -47,9 +45,9 @@ import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.reactive.HandlerMapping;
|
||||
import org.springframework.web.reactive.HandlerResult;
|
||||
import org.springframework.web.reactive.HandlerResultHandler;
|
||||
import org.springframework.web.reactive.accept.RequestedContentTypeResolver;
|
||||
import org.springframework.web.reactive.accept.FixedContentTypeResolver;
|
||||
import org.springframework.web.reactive.accept.HeaderContentTypeResolver;
|
||||
import org.springframework.web.reactive.accept.RequestedContentTypeResolver;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import org.springframework.web.server.adapter.DefaultServerWebExchange;
|
||||
import org.springframework.web.server.session.WebSessionManager;
|
||||
@@ -100,7 +98,7 @@ public class ResponseBodyResultHandlerTests {
|
||||
|
||||
ServerWebExchange exchange = createExchange("/foo");
|
||||
HandlerResult result = new HandlerResult(new Object(), "fooValue", ResolvableType.forClass(String.class));
|
||||
handler.handleResult(exchange, result).get();
|
||||
handler.handleResult(exchange, result).block();
|
||||
|
||||
assertEquals(contentType, exchange.getResponse().getHeaders().getContentType());
|
||||
}
|
||||
@@ -114,7 +112,7 @@ public class ResponseBodyResultHandlerTests {
|
||||
HandlerResultHandler handler = createHandler(new StringEncoder(), new JacksonJsonEncoder());
|
||||
|
||||
HandlerResult result = new HandlerResult(new Object(), "fooValue", ResolvableType.forClass(String.class));
|
||||
handler.handleResult(exchange, result).get();
|
||||
handler.handleResult(exchange, result).block();
|
||||
|
||||
assertEquals(MediaType.APPLICATION_JSON, exchange.getResponse().getHeaders().getContentType());
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ public class SessionAttributeMethodArgumentResolverTests {
|
||||
Foo foo = new Foo();
|
||||
when(this.session.getAttribute("foo")).thenReturn(Optional.of(foo));
|
||||
mono = this.resolver.resolveArgument(param, null, this.exchange);
|
||||
assertSame(foo, mono.get());
|
||||
assertSame(foo, mono.block());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -113,36 +113,36 @@ public class SessionAttributeMethodArgumentResolverTests {
|
||||
Foo foo = new Foo();
|
||||
when(this.session.getAttribute("specialFoo")).thenReturn(Optional.of(foo));
|
||||
Mono<Object> mono = this.resolver.resolveArgument(param, null, this.exchange);
|
||||
assertSame(foo, mono.get());
|
||||
assertSame(foo, mono.block());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveNotRequired() throws Exception {
|
||||
MethodParameter param = initMethodParameter(2);
|
||||
Mono<Object> mono = this.resolver.resolveArgument(param, null, this.exchange);
|
||||
assertNull(mono.get());
|
||||
assertNull(mono.block());
|
||||
|
||||
Foo foo = new Foo();
|
||||
when(this.session.getAttribute("foo")).thenReturn(Optional.of(foo));
|
||||
mono = this.resolver.resolveArgument(param, null, this.exchange);
|
||||
assertSame(foo, mono.get());
|
||||
assertSame(foo, mono.block());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resolveOptional() throws Exception {
|
||||
MethodParameter param = initMethodParameter(3);
|
||||
Mono<Object> mono = this.resolver.resolveArgument(param, null, this.exchange);
|
||||
assertNotNull(mono.get());
|
||||
assertEquals(Optional.class, mono.get().getClass());
|
||||
assertFalse(((Optional) mono.get()).isPresent());
|
||||
assertNotNull(mono.block());
|
||||
assertEquals(Optional.class, mono.block().getClass());
|
||||
assertFalse(((Optional) mono.block()).isPresent());
|
||||
|
||||
Foo foo = new Foo();
|
||||
when(this.session.getAttribute("foo")).thenReturn(Optional.of(foo));
|
||||
mono = this.resolver.resolveArgument(param, null, this.exchange);
|
||||
|
||||
assertNotNull(mono.get());
|
||||
assertEquals(Optional.class, mono.get().getClass());
|
||||
Optional optional = (Optional) mono.get();
|
||||
assertNotNull(mono.block());
|
||||
assertEquals(Optional.class, mono.block().getClass());
|
||||
Optional optional = (Optional) mono.block();
|
||||
assertTrue(optional.isPresent());
|
||||
assertSame(foo, optional.get());
|
||||
}
|
||||
|
||||
@@ -48,10 +48,10 @@ public class UrlBasedViewResolverTests {
|
||||
resolver.setApplicationContext(context);
|
||||
|
||||
Mono<View> mono = resolver.resolveViewName("my-view", Locale.US);
|
||||
assertNotNull(mono.get());
|
||||
assertNotNull(mono.block());
|
||||
|
||||
mono = resolver.resolveViewName("not-my-view", Locale.US);
|
||||
assertNull(mono.get());
|
||||
assertNull(mono.block());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ public class ExceptionHandlingHttpHandlerTests {
|
||||
@Test
|
||||
public void handleErrorSignal() throws Exception {
|
||||
WebExceptionHandler exceptionHandler = new BadRequestExceptionHandler();
|
||||
createWebHandler(exceptionHandler).handle(this.exchange).get();
|
||||
createWebHandler(exceptionHandler).handle(this.exchange).block();
|
||||
|
||||
assertEquals(HttpStatus.BAD_REQUEST, this.response.getStatus());
|
||||
}
|
||||
@@ -75,7 +75,7 @@ public class ExceptionHandlingHttpHandlerTests {
|
||||
new BadRequestExceptionHandler(),
|
||||
new UnresolvedExceptionHandler()
|
||||
};
|
||||
createWebHandler(exceptionHandlers).handle(this.exchange).get();
|
||||
createWebHandler(exceptionHandlers).handle(this.exchange).block();
|
||||
|
||||
assertEquals(HttpStatus.BAD_REQUEST, this.response.getStatus());
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public class ExceptionHandlingHttpHandlerTests {
|
||||
@Test
|
||||
public void unresolvedException() throws Exception {
|
||||
WebExceptionHandler exceptionHandler = new UnresolvedExceptionHandler();
|
||||
createWebHandler(exceptionHandler).handle(this.exchange).get();
|
||||
createWebHandler(exceptionHandler).handle(this.exchange).block();
|
||||
|
||||
assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, this.response.getStatus());
|
||||
}
|
||||
@@ -91,7 +91,7 @@ public class ExceptionHandlingHttpHandlerTests {
|
||||
@Test
|
||||
public void thrownExceptionBecomesErrorSignal() throws Exception {
|
||||
WebExceptionHandler exceptionHandler = new BadRequestExceptionHandler();
|
||||
createWebHandler(exceptionHandler).handle(this.exchange).get();
|
||||
createWebHandler(exceptionHandler).handle(this.exchange).block();
|
||||
|
||||
assertEquals(HttpStatus.BAD_REQUEST, this.response.getStatus());
|
||||
}
|
||||
|
||||
@@ -23,20 +23,17 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.core.test.TestSubscriber;
|
||||
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.server.reactive.HttpHandler;
|
||||
import org.springframework.http.server.reactive.MockServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.MockServerHttpResponse;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import org.springframework.web.server.WebExceptionHandler;
|
||||
import org.springframework.web.server.WebFilter;
|
||||
import org.springframework.web.server.WebFilterChain;
|
||||
import org.springframework.web.server.WebHandler;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -70,7 +67,7 @@ public class FilteringWebHandlerTests {
|
||||
TestFilter filter2 = new TestFilter();
|
||||
TestFilter filter3 = new TestFilter();
|
||||
HttpHandler httpHandler = createHttpHandler(webHandler, filter1, filter2, filter3);
|
||||
httpHandler.handle(this.request, this.response).get();
|
||||
httpHandler.handle(this.request, this.response).block();
|
||||
|
||||
assertTrue(filter1.invoked());
|
||||
assertTrue(filter2.invoked());
|
||||
@@ -82,7 +79,7 @@ public class FilteringWebHandlerTests {
|
||||
public void zeroFilters() throws Exception {
|
||||
StubWebHandler webHandler = new StubWebHandler();
|
||||
HttpHandler httpHandler = createHttpHandler(webHandler);
|
||||
httpHandler.handle(this.request, this.response).get();
|
||||
httpHandler.handle(this.request, this.response).block();
|
||||
|
||||
assertTrue(webHandler.invoked());
|
||||
}
|
||||
@@ -94,7 +91,7 @@ public class FilteringWebHandlerTests {
|
||||
ShortcircuitingFilter filter2 = new ShortcircuitingFilter();
|
||||
TestFilter filter3 = new TestFilter();
|
||||
HttpHandler httpHandler = createHttpHandler(webHandler, filter1, filter2, filter3);
|
||||
httpHandler.handle(this.request, this.response).get();
|
||||
httpHandler.handle(this.request, this.response).block();
|
||||
|
||||
assertTrue(filter1.invoked());
|
||||
assertTrue(filter2.invoked());
|
||||
@@ -107,7 +104,7 @@ public class FilteringWebHandlerTests {
|
||||
StubWebHandler webHandler = new StubWebHandler();
|
||||
AsyncFilter filter = new AsyncFilter();
|
||||
HttpHandler httpHandler = createHttpHandler(webHandler, filter);
|
||||
httpHandler.handle(this.request, this.response).get();
|
||||
httpHandler.handle(this.request, this.response).block();
|
||||
|
||||
assertTrue(filter.invoked());
|
||||
assertTrue(webHandler.invoked());
|
||||
@@ -118,7 +115,7 @@ public class FilteringWebHandlerTests {
|
||||
TestExceptionHandler exceptionHandler = new TestExceptionHandler();
|
||||
HttpHandler handler = WebHttpHandlerBuilder.webHandler(new StubWebHandler())
|
||||
.filters(new ExceptionFilter()).exceptionHandlers(exceptionHandler).build();
|
||||
handler.handle(this.request, this.response).get();
|
||||
handler.handle(this.request, this.response).block();
|
||||
|
||||
assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, this.response.getStatus());
|
||||
|
||||
|
||||
@@ -66,32 +66,32 @@ public class DefaultWebSessionManagerTests {
|
||||
@Test
|
||||
public void getSessionWithoutStarting() throws Exception {
|
||||
this.idResolver.setIdsToResolve(Collections.emptyList());
|
||||
WebSession session = this.manager.getSession(this.exchange).get();
|
||||
WebSession session = this.manager.getSession(this.exchange).block();
|
||||
session.save();
|
||||
|
||||
assertFalse(session.isStarted());
|
||||
assertFalse(session.isExpired());
|
||||
assertNull(this.idResolver.getSavedId());
|
||||
assertNull(this.manager.getSessionStore().retrieveSession(session.getId()).get());
|
||||
assertNull(this.manager.getSessionStore().retrieveSession(session.getId()).block());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void startSessionExplicitly() throws Exception {
|
||||
this.idResolver.setIdsToResolve(Collections.emptyList());
|
||||
WebSession session = this.manager.getSession(this.exchange).get();
|
||||
WebSession session = this.manager.getSession(this.exchange).block();
|
||||
session.start();
|
||||
session.save();
|
||||
|
||||
String id = session.getId();
|
||||
assertNotNull(this.idResolver.getSavedId());
|
||||
assertEquals(id, this.idResolver.getSavedId());
|
||||
assertSame(session, this.manager.getSessionStore().retrieveSession(id).get());
|
||||
assertSame(session, this.manager.getSessionStore().retrieveSession(id).block());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void startSessionImplicitly() throws Exception {
|
||||
this.idResolver.setIdsToResolve(Collections.emptyList());
|
||||
WebSession session = this.manager.getSession(this.exchange).get();
|
||||
WebSession session = this.manager.getSession(this.exchange).block();
|
||||
session.getAttributes().put("foo", "bar");
|
||||
session.save();
|
||||
|
||||
@@ -104,7 +104,7 @@ public class DefaultWebSessionManagerTests {
|
||||
this.manager.getSessionStore().storeSession(existing);
|
||||
this.idResolver.setIdsToResolve(Collections.singletonList("1"));
|
||||
|
||||
WebSession actual = this.manager.getSession(this.exchange).get();
|
||||
WebSession actual = this.manager.getSession(this.exchange).block();
|
||||
assertSame(existing, actual);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ public class DefaultWebSessionManagerTests {
|
||||
this.manager.getSessionStore().storeSession(existing);
|
||||
this.idResolver.setIdsToResolve(Collections.singletonList("1"));
|
||||
|
||||
WebSession actual = this.manager.getSession(this.exchange).get();
|
||||
WebSession actual = this.manager.getSession(this.exchange).block();
|
||||
assertNotSame(existing, actual);
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ public class DefaultWebSessionManagerTests {
|
||||
this.manager.getSessionStore().storeSession(existing);
|
||||
this.idResolver.setIdsToResolve(Arrays.asList("1", "2", "3"));
|
||||
|
||||
WebSession actual = this.manager.getSession(this.exchange).get();
|
||||
WebSession actual = this.manager.getSession(this.exchange).block();
|
||||
assertSame(existing, actual);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user