Add support for RxJava 3
Closes gh-24170
This commit is contained in:
@@ -30,7 +30,7 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.rxjava3.core.Single;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
@@ -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.
|
||||
@@ -24,7 +24,7 @@ import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.rxjava3.core.Single;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
@@ -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,16 +21,15 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import io.reactivex.BackpressureStrategy;
|
||||
import io.reactivex.Flowable;
|
||||
import io.reactivex.Maybe;
|
||||
import io.reactivex.rxjava3.core.BackpressureStrategy;
|
||||
import io.reactivex.rxjava3.core.Flowable;
|
||||
import io.reactivex.rxjava3.core.Maybe;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.core.Single;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
import rx.Observable;
|
||||
import rx.RxReactiveStreams;
|
||||
import rx.Single;
|
||||
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.ReactiveAdapterRegistry;
|
||||
@@ -80,12 +79,10 @@ public class HttpEntityMethodArgumentResolverTests {
|
||||
testSupports(this.testMethod.arg(httpEntityType(String.class)));
|
||||
testSupports(this.testMethod.arg(httpEntityType(Mono.class, String.class)));
|
||||
testSupports(this.testMethod.arg(httpEntityType(Single.class, String.class)));
|
||||
testSupports(this.testMethod.arg(httpEntityType(io.reactivex.Single.class, String.class)));
|
||||
testSupports(this.testMethod.arg(httpEntityType(Maybe.class, String.class)));
|
||||
testSupports(this.testMethod.arg(httpEntityType(CompletableFuture.class, String.class)));
|
||||
testSupports(this.testMethod.arg(httpEntityType(Flux.class, String.class)));
|
||||
testSupports(this.testMethod.arg(httpEntityType(Observable.class, String.class)));
|
||||
testSupports(this.testMethod.arg(httpEntityType(io.reactivex.Observable.class, String.class)));
|
||||
testSupports(this.testMethod.arg(httpEntityType(Flowable.class, String.class)));
|
||||
testSupports(this.testMethod.arg(forClassWithGenerics(RequestEntity.class, String.class)));
|
||||
}
|
||||
@@ -132,17 +129,6 @@ public class HttpEntityMethodArgumentResolverTests {
|
||||
ResolvableType type = httpEntityType(Single.class, String.class);
|
||||
HttpEntity<Single<String>> entity = resolveValueWithEmptyBody(type);
|
||||
|
||||
StepVerifier.create(RxReactiveStreams.toPublisher(entity.getBody()))
|
||||
.expectNextCount(0)
|
||||
.expectError(ServerWebInputException.class)
|
||||
.verify();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void emptyBodyWithRxJava2Single() {
|
||||
ResolvableType type = httpEntityType(io.reactivex.Single.class, String.class);
|
||||
HttpEntity<io.reactivex.Single<String>> entity = resolveValueWithEmptyBody(type);
|
||||
|
||||
StepVerifier.create(entity.getBody().toFlowable())
|
||||
.expectNextCount(0)
|
||||
.expectError(ServerWebInputException.class)
|
||||
@@ -150,7 +136,7 @@ public class HttpEntityMethodArgumentResolverTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void emptyBodyWithRxJava2Maybe() {
|
||||
public void emptyBodyWithMaybe() {
|
||||
ResolvableType type = httpEntityType(Maybe.class, String.class);
|
||||
HttpEntity<Maybe<String>> entity = resolveValueWithEmptyBody(type);
|
||||
|
||||
@@ -165,17 +151,6 @@ public class HttpEntityMethodArgumentResolverTests {
|
||||
ResolvableType type = httpEntityType(Observable.class, String.class);
|
||||
HttpEntity<Observable<String>> entity = resolveValueWithEmptyBody(type);
|
||||
|
||||
StepVerifier.create(RxReactiveStreams.toPublisher(entity.getBody()))
|
||||
.expectNextCount(0)
|
||||
.expectComplete()
|
||||
.verify();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void emptyBodyWithRxJava2Observable() {
|
||||
ResolvableType type = httpEntityType(io.reactivex.Observable.class, String.class);
|
||||
HttpEntity<io.reactivex.Observable<String>> entity = resolveValueWithEmptyBody(type);
|
||||
|
||||
StepVerifier.create(entity.getBody().toFlowable(BackpressureStrategy.BUFFER))
|
||||
.expectNextCount(0)
|
||||
.expectComplete()
|
||||
@@ -230,22 +205,12 @@ public class HttpEntityMethodArgumentResolverTests {
|
||||
ResolvableType type = httpEntityType(Single.class, String.class);
|
||||
HttpEntity<Single<String>> httpEntity = resolveValue(exchange, type);
|
||||
|
||||
assertThat(httpEntity.getHeaders()).isEqualTo(exchange.getRequest().getHeaders());
|
||||
assertThat(httpEntity.getBody().toBlocking().value()).isEqualTo("line1");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void httpEntityWithRxJava2SingleBody() {
|
||||
ServerWebExchange exchange = postExchange("line1");
|
||||
ResolvableType type = httpEntityType(io.reactivex.Single.class, String.class);
|
||||
HttpEntity<io.reactivex.Single<String>> httpEntity = resolveValue(exchange, type);
|
||||
|
||||
assertThat(httpEntity.getHeaders()).isEqualTo(exchange.getRequest().getHeaders());
|
||||
assertThat(httpEntity.getBody().blockingGet()).isEqualTo("line1");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void httpEntityWithRxJava2MaybeBody() {
|
||||
public void httpEntityWithMaybeBody() {
|
||||
ServerWebExchange exchange = postExchange("line1");
|
||||
ResolvableType type = httpEntityType(Maybe.class, String.class);
|
||||
HttpEntity<Maybe<String>> httpEntity = resolveValue(exchange, type);
|
||||
@@ -335,10 +300,8 @@ public class HttpEntityMethodArgumentResolverTests {
|
||||
HttpEntity<Mono<String>> monoBody,
|
||||
HttpEntity<Flux<String>> fluxBody,
|
||||
HttpEntity<Single<String>> singleBody,
|
||||
HttpEntity<io.reactivex.Single<String>> rxJava2SingleBody,
|
||||
HttpEntity<Maybe<String>> rxJava2MaybeBody,
|
||||
HttpEntity<Maybe<String>> maybeBody,
|
||||
HttpEntity<Observable<String>> observableBody,
|
||||
HttpEntity<io.reactivex.Observable<String>> rxJava2ObservableBody,
|
||||
HttpEntity<Flowable<String>> flowableBody,
|
||||
HttpEntity<CompletableFuture<String>> completableFutureBody,
|
||||
RequestEntity<String> requestEntity,
|
||||
|
||||
@@ -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.
|
||||
@@ -29,15 +29,15 @@ import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import io.reactivex.Flowable;
|
||||
import io.reactivex.Maybe;
|
||||
import io.reactivex.rxjava3.core.Flowable;
|
||||
import io.reactivex.rxjava3.core.Maybe;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.core.Single;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
import rx.Observable;
|
||||
import rx.Single;
|
||||
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.ResolvableType;
|
||||
@@ -140,21 +140,11 @@ public class MessageReaderArgumentResolverTests {
|
||||
MethodParameter param = this.testMethod.arg(type);
|
||||
Single<TestBean> single = resolveValue(param, body);
|
||||
|
||||
assertThat(single.toBlocking().value()).isEqualTo(new TestBean("f1", "b1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rxJava2SingleTestBean() throws Exception {
|
||||
String body = "{\"bar\":\"b1\",\"foo\":\"f1\"}";
|
||||
ResolvableType type = forClassWithGenerics(io.reactivex.Single.class, TestBean.class);
|
||||
MethodParameter param = this.testMethod.arg(type);
|
||||
io.reactivex.Single<TestBean> single = resolveValue(param, body);
|
||||
|
||||
assertThat(single.blockingGet()).isEqualTo(new TestBean("f1", "b1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rxJava2MaybeTestBean() throws Exception {
|
||||
public void maybeTestBean() throws Exception {
|
||||
String body = "{\"bar\":\"b1\",\"foo\":\"f1\"}";
|
||||
ResolvableType type = forClassWithGenerics(Maybe.class, TestBean.class);
|
||||
MethodParameter param = this.testMethod.arg(type);
|
||||
@@ -170,16 +160,6 @@ public class MessageReaderArgumentResolverTests {
|
||||
MethodParameter param = this.testMethod.arg(type);
|
||||
Observable<?> observable = resolveValue(param, body);
|
||||
|
||||
assertThat(observable.toList().toBlocking().first()).isEqualTo(Arrays.asList(new TestBean("f1", "b1"), new TestBean("f2", "b2")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rxJava2ObservableTestBean() throws Exception {
|
||||
String body = "[{\"bar\":\"b1\",\"foo\":\"f1\"},{\"bar\":\"b2\",\"foo\":\"f2\"}]";
|
||||
ResolvableType type = forClassWithGenerics(io.reactivex.Observable.class, TestBean.class);
|
||||
MethodParameter param = this.testMethod.arg(type);
|
||||
io.reactivex.Observable<?> observable = resolveValue(param, body);
|
||||
|
||||
assertThat(observable.toList().blockingGet()).isEqualTo(Arrays.asList(new TestBean("f1", "b1"), new TestBean("f2", "b2")));
|
||||
}
|
||||
|
||||
@@ -324,10 +304,8 @@ public class MessageReaderArgumentResolverTests {
|
||||
@Validated Mono<TestBean> monoTestBean,
|
||||
@Validated Flux<TestBean> fluxTestBean,
|
||||
Single<TestBean> singleTestBean,
|
||||
io.reactivex.Single<TestBean> rxJava2SingleTestBean,
|
||||
Maybe<TestBean> rxJava2MaybeTestBean,
|
||||
Maybe<TestBean> maybeTestBean,
|
||||
Observable<TestBean> observableTestBean,
|
||||
io.reactivex.Observable<TestBean> rxJava2ObservableTestBean,
|
||||
Flowable<TestBean> flowableTestBean,
|
||||
CompletableFuture<TestBean> futureTestBean,
|
||||
TestBean testBean,
|
||||
|
||||
@@ -27,13 +27,13 @@ import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import io.reactivex.Flowable;
|
||||
import io.reactivex.rxjava3.core.Completable;
|
||||
import io.reactivex.rxjava3.core.Flowable;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
import rx.Completable;
|
||||
import rx.Observable;
|
||||
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.codec.ByteBufferEncoder;
|
||||
@@ -117,11 +117,11 @@ public class MessageWriterResultHandlerTests {
|
||||
testVoid(Completable.complete(), on(TestController.class).resolveReturnType(Completable.class));
|
||||
testVoid(Observable.empty(), on(TestController.class).resolveReturnType(Observable.class, Void.class));
|
||||
|
||||
MethodParameter type = on(TestController.class).resolveReturnType(io.reactivex.Completable.class);
|
||||
testVoid(io.reactivex.Completable.complete(), type);
|
||||
MethodParameter type = on(TestController.class).resolveReturnType(Completable.class);
|
||||
testVoid(Completable.complete(), type);
|
||||
|
||||
type = on(TestController.class).resolveReturnType(io.reactivex.Observable.class, Void.class);
|
||||
testVoid(io.reactivex.Observable.empty(), type);
|
||||
type = on(TestController.class).resolveReturnType(Observable.class, Void.class);
|
||||
testVoid(Observable.empty(), type);
|
||||
|
||||
type = on(TestController.class).resolveReturnType(Flowable.class, Void.class);
|
||||
testVoid(Flowable.empty(), type);
|
||||
@@ -274,14 +274,10 @@ public class MessageWriterResultHandlerTests {
|
||||
|
||||
Completable completable() { return null; }
|
||||
|
||||
io.reactivex.Completable rxJava2Completable() { return null; }
|
||||
|
||||
Flux<Void> fluxVoid() { return null; }
|
||||
|
||||
Observable<Void> observableVoid() { return null; }
|
||||
|
||||
io.reactivex.Observable<Void> rxJava2ObservableVoid() { return null; }
|
||||
|
||||
Flowable<Void> flowableVoid() { return null; }
|
||||
|
||||
OutputStream outputStream() { return null; }
|
||||
|
||||
@@ -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,12 +21,11 @@ import java.time.Duration;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
import io.reactivex.rxjava3.core.Single;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
import rx.RxReactiveStreams;
|
||||
import rx.Single;
|
||||
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.ReactiveAdapterRegistry;
|
||||
@@ -134,7 +133,7 @@ public class ModelAttributeMethodArgumentResolverTests {
|
||||
testBindFoo("fooSingle", parameter, single -> {
|
||||
boolean condition = single instanceof Single;
|
||||
assertThat(condition).as(single.getClass().getName()).isTrue();
|
||||
Object value = ((Single<?>) single).toBlocking().value();
|
||||
Object value = ((Single<?>) single).blockingGet();
|
||||
assertThat(value.getClass()).isEqualTo(Foo.class);
|
||||
return (Foo) value;
|
||||
});
|
||||
@@ -257,7 +256,7 @@ public class ModelAttributeMethodArgumentResolverTests {
|
||||
assertThat(value).isNotNull();
|
||||
boolean condition = value instanceof Single;
|
||||
assertThat(condition).isTrue();
|
||||
return Mono.from(RxReactiveStreams.toPublisher((Single<?>) value));
|
||||
return Mono.from(((Single<?>) value).toFlowable());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -23,10 +23,10 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.reactivex.rxjava3.core.Single;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
import rx.Single;
|
||||
|
||||
import org.springframework.context.support.StaticApplicationContext;
|
||||
import org.springframework.core.MethodIntrospector;
|
||||
@@ -122,7 +122,7 @@ public class ModelInitializerTests {
|
||||
assertThat(((Mono<TestBean>) value).block(TIMEOUT).getName()).isEqualTo("Mono Bean");
|
||||
|
||||
value = model.get("singleBean");
|
||||
assertThat(((Single<TestBean>) value).toBlocking().value().getName()).isEqualTo("Single Bean");
|
||||
assertThat(((Single<TestBean>) value).blockingGet().getName()).isEqualTo("Single Bean");
|
||||
|
||||
value = model.get("voidMethodBean");
|
||||
assertThat(((TestBean) value).getName()).isEqualTo("Void Method Bean");
|
||||
|
||||
@@ -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.
|
||||
@@ -18,7 +18,7 @@ package org.springframework.web.reactive.result.method.annotation;
|
||||
|
||||
import java.security.Principal;
|
||||
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.rxjava3.core.Single;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -19,7 +19,7 @@ package org.springframework.web.reactive.result.method.annotation;
|
||||
import java.time.Duration;
|
||||
import java.util.Optional;
|
||||
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.rxjava3.core.Single;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@@ -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.
|
||||
@@ -22,15 +22,15 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import io.reactivex.Maybe;
|
||||
import io.reactivex.rxjava3.core.BackpressureStrategy;
|
||||
import io.reactivex.rxjava3.core.Maybe;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.core.Single;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
import rx.Observable;
|
||||
import rx.RxReactiveStreams;
|
||||
import rx.Single;
|
||||
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.ReactiveAdapterRegistry;
|
||||
@@ -150,14 +150,14 @@ public class RequestBodyMethodArgumentResolverTests {
|
||||
public void emptyBodyWithSingle() {
|
||||
MethodParameter param = this.testMethod.annot(requestBody()).arg(Single.class, String.class);
|
||||
Single<String> single = resolveValueWithEmptyBody(param);
|
||||
StepVerifier.create(RxReactiveStreams.toPublisher(single))
|
||||
StepVerifier.create(single.toFlowable())
|
||||
.expectNextCount(0)
|
||||
.expectError(ServerWebInputException.class)
|
||||
.verify();
|
||||
|
||||
param = this.testMethod.annot(requestBody().notRequired()).arg(Single.class, String.class);
|
||||
single = resolveValueWithEmptyBody(param);
|
||||
StepVerifier.create(RxReactiveStreams.toPublisher(single))
|
||||
StepVerifier.create(single.toFlowable())
|
||||
.expectNextCount(0)
|
||||
.expectError(ServerWebInputException.class)
|
||||
.verify();
|
||||
@@ -184,14 +184,14 @@ public class RequestBodyMethodArgumentResolverTests {
|
||||
public void emptyBodyWithObservable() {
|
||||
MethodParameter param = this.testMethod.annot(requestBody()).arg(Observable.class, String.class);
|
||||
Observable<String> observable = resolveValueWithEmptyBody(param);
|
||||
StepVerifier.create(RxReactiveStreams.toPublisher(observable))
|
||||
StepVerifier.create(observable.toFlowable(BackpressureStrategy.BUFFER))
|
||||
.expectNextCount(0)
|
||||
.expectError(ServerWebInputException.class)
|
||||
.verify();
|
||||
|
||||
param = this.testMethod.annot(requestBody().notRequired()).arg(Observable.class, String.class);
|
||||
observable = resolveValueWithEmptyBody(param);
|
||||
StepVerifier.create(RxReactiveStreams.toPublisher(observable))
|
||||
StepVerifier.create(observable.toFlowable(BackpressureStrategy.BUFFER))
|
||||
.expectNextCount(0)
|
||||
.expectComplete()
|
||||
.verify();
|
||||
@@ -248,19 +248,15 @@ public class RequestBodyMethodArgumentResolverTests {
|
||||
@RequestBody Mono<String> mono,
|
||||
@RequestBody Flux<String> flux,
|
||||
@RequestBody Single<String> single,
|
||||
@RequestBody io.reactivex.Single<String> rxJava2Single,
|
||||
@RequestBody Maybe<String> rxJava2Maybe,
|
||||
@RequestBody Observable<String> obs,
|
||||
@RequestBody io.reactivex.Observable<String> rxjava2Obs,
|
||||
@RequestBody Maybe<String> maybe,
|
||||
@RequestBody Observable<String> observable,
|
||||
@RequestBody CompletableFuture<String> future,
|
||||
@RequestBody(required = false) String stringNotRequired,
|
||||
@RequestBody(required = false) Mono<String> monoNotRequired,
|
||||
@RequestBody(required = false) Flux<String> fluxNotRequired,
|
||||
@RequestBody(required = false) Single<String> singleNotRequired,
|
||||
@RequestBody(required = false) io.reactivex.Single<String> rxJava2SingleNotRequired,
|
||||
@RequestBody(required = false) Maybe<String> rxJava2MaybeNotRequired,
|
||||
@RequestBody(required = false) Observable<String> obsNotRequired,
|
||||
@RequestBody(required = false) io.reactivex.Observable<String> rxjava2ObsNotRequired,
|
||||
@RequestBody(required = false) Maybe<String> maybeNotRequired,
|
||||
@RequestBody(required = false) Observable<String> observableNotRequired,
|
||||
@RequestBody(required = false) CompletableFuture<String> futureNotRequired,
|
||||
@RequestBody(required = false) Map<?, ?> mapNotRequired,
|
||||
String notAnnotated) {}
|
||||
|
||||
@@ -26,14 +26,14 @@ import java.util.concurrent.CompletableFuture;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import io.reactivex.Flowable;
|
||||
import io.reactivex.Maybe;
|
||||
import io.reactivex.rxjava3.core.Completable;
|
||||
import io.reactivex.rxjava3.core.Flowable;
|
||||
import io.reactivex.rxjava3.core.Maybe;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.core.Single;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import rx.Completable;
|
||||
import rx.Observable;
|
||||
import rx.Single;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
@@ -118,15 +118,7 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq
|
||||
startServer(httpServer);
|
||||
|
||||
String expected = "Hello!";
|
||||
assertThat(performGet("/raw-response/observable", new HttpHeaders(), String.class).getBody()).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@ParameterizedHttpServerTest
|
||||
public void byteBufferResponseBodyWithRxJava2Observable(HttpServer httpServer) throws Exception {
|
||||
startServer(httpServer);
|
||||
|
||||
String expected = "Hello!";
|
||||
assertThat(performGet("/raw-response/rxjava2-observable",
|
||||
assertThat(performGet("/raw-response/observable",
|
||||
new HttpHeaders(), String.class).getBody()).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@@ -317,18 +309,10 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq
|
||||
}
|
||||
|
||||
@ParameterizedHttpServerTest
|
||||
public void personTransformWithRxJava2Single(HttpServer httpServer) throws Exception {
|
||||
public void personTransformWithMaybe(HttpServer httpServer) throws Exception {
|
||||
startServer(httpServer);
|
||||
|
||||
assertThat(performPost("/person-transform/rxjava2-single", JSON, new Person("Robert"),
|
||||
JSON, Person.class).getBody()).isEqualTo(new Person("ROBERT"));
|
||||
}
|
||||
|
||||
@ParameterizedHttpServerTest
|
||||
public void personTransformWithRxJava2Maybe(HttpServer httpServer) throws Exception {
|
||||
startServer(httpServer);
|
||||
|
||||
assertThat(performPost("/person-transform/rxjava2-maybe", JSON, new Person("Robert"),
|
||||
assertThat(performPost("/person-transform/maybe", JSON, new Person("Robert"),
|
||||
JSON, Person.class).getBody()).isEqualTo(new Person("ROBERT"));
|
||||
}
|
||||
|
||||
@@ -359,15 +343,6 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq
|
||||
assertThat(performPost("/person-transform/observable", JSON, req, JSON, PERSON_LIST).getBody()).isEqualTo(res);
|
||||
}
|
||||
|
||||
@ParameterizedHttpServerTest
|
||||
public void personTransformWithRxJava2Observable(HttpServer httpServer) throws Exception {
|
||||
startServer(httpServer);
|
||||
|
||||
List<?> req = asList(new Person("Robert"), new Person("Marie"));
|
||||
List<?> res = asList(new Person("ROBERT"), new Person("MARIE"));
|
||||
assertThat(performPost("/person-transform/rxjava2-observable", JSON, req, JSON, PERSON_LIST).getBody()).isEqualTo(res);
|
||||
}
|
||||
|
||||
@ParameterizedHttpServerTest
|
||||
public void personTransformWithFlowable(HttpServer httpServer) throws Exception {
|
||||
startServer(httpServer);
|
||||
@@ -421,17 +396,6 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq
|
||||
assertThat(getApplicationContext().getBean(PersonCreateController.class).persons.size()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@ParameterizedHttpServerTest
|
||||
public void personCreateWithRxJava2Single(HttpServer httpServer) throws Exception {
|
||||
startServer(httpServer);
|
||||
|
||||
ResponseEntity<Void> entity = performPost(
|
||||
"/person-create/rxjava2-single", JSON, new Person("Robert"), null, Void.class);
|
||||
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(getApplicationContext().getBean(PersonCreateController.class).persons.size()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@ParameterizedHttpServerTest
|
||||
public void personCreateWithFluxJson(HttpServer httpServer) throws Exception {
|
||||
startServer(httpServer);
|
||||
@@ -465,17 +429,6 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq
|
||||
assertThat(getApplicationContext().getBean(PersonCreateController.class).persons.size()).isEqualTo(2);
|
||||
}
|
||||
|
||||
@ParameterizedHttpServerTest
|
||||
public void personCreateWithRxJava2ObservableJson(HttpServer httpServer) throws Exception {
|
||||
startServer(httpServer);
|
||||
|
||||
ResponseEntity<Void> entity = performPost("/person-create/rxjava2-observable", JSON,
|
||||
asList(new Person("Robert"), new Person("Marie")), null, Void.class);
|
||||
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(getApplicationContext().getBean(PersonCreateController.class).persons.size()).isEqualTo(2);
|
||||
}
|
||||
|
||||
@ParameterizedHttpServerTest
|
||||
public void personCreateWithObservableXml(HttpServer httpServer) throws Exception {
|
||||
startServer(httpServer);
|
||||
@@ -487,18 +440,6 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq
|
||||
assertThat(getApplicationContext().getBean(PersonCreateController.class).persons.size()).isEqualTo(2);
|
||||
}
|
||||
|
||||
@ParameterizedHttpServerTest
|
||||
public void personCreateWithRxJava2ObservableXml(HttpServer httpServer) throws Exception {
|
||||
startServer(httpServer);
|
||||
|
||||
People people = new People(new Person("Robert"), new Person("Marie"));
|
||||
String url = "/person-create/rxjava2-observable";
|
||||
ResponseEntity<Void> response = performPost(url, APPLICATION_XML, people, null, Void.class);
|
||||
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(getApplicationContext().getBean(PersonCreateController.class).persons.size()).isEqualTo(2);
|
||||
}
|
||||
|
||||
@ParameterizedHttpServerTest
|
||||
public void personCreateWithFlowableJson(HttpServer httpServer) throws Exception {
|
||||
startServer(httpServer);
|
||||
@@ -567,11 +508,6 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq
|
||||
return Observable.just(ByteBuffer.wrap("Hello!".getBytes()));
|
||||
}
|
||||
|
||||
@GetMapping("/rxjava2-observable")
|
||||
public io.reactivex.Observable<ByteBuffer> getRxJava2Observable() {
|
||||
return io.reactivex.Observable.just(ByteBuffer.wrap("Hello!".getBytes()));
|
||||
}
|
||||
|
||||
@GetMapping("/flowable")
|
||||
public Flowable<ByteBuffer> getFlowable() {
|
||||
return Flowable.just(ByteBuffer.wrap("Hello!".getBytes()));
|
||||
@@ -670,9 +606,8 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq
|
||||
}
|
||||
|
||||
@PostMapping("/completable-future")
|
||||
public CompletableFuture<Person> transformCompletableFuture(
|
||||
@RequestBody CompletableFuture<Person> personFuture) {
|
||||
return personFuture.thenApply(person -> new Person(person.getName().toUpperCase()));
|
||||
public CompletableFuture<Person> transformCompletableFuture(@RequestBody CompletableFuture<Person> future) {
|
||||
return future.thenApply(person -> new Person(person.getName().toUpperCase()));
|
||||
}
|
||||
|
||||
@PostMapping("/mono")
|
||||
@@ -685,21 +620,14 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq
|
||||
return personFuture.map(person -> new Person(person.getName().toUpperCase()));
|
||||
}
|
||||
|
||||
@PostMapping("/rxjava2-single")
|
||||
public io.reactivex.Single<Person> transformRxJava2Single(@RequestBody io.reactivex.Single<Person> personFuture) {
|
||||
return personFuture.map(person -> new Person(person.getName().toUpperCase()));
|
||||
}
|
||||
|
||||
@PostMapping("/rxjava2-maybe")
|
||||
public Maybe<Person> transformRxJava2Maybe(@RequestBody Maybe<Person> personFuture) {
|
||||
@PostMapping("/maybe")
|
||||
public Maybe<Person> transformMaybe(@RequestBody Maybe<Person> personFuture) {
|
||||
return personFuture.map(person -> new Person(person.getName().toUpperCase()));
|
||||
}
|
||||
|
||||
@PostMapping("/publisher")
|
||||
public Publisher<Person> transformPublisher(@RequestBody Publisher<Person> persons) {
|
||||
return Flux
|
||||
.from(persons)
|
||||
.map(person -> new Person(person.getName().toUpperCase()));
|
||||
return Flux.from(persons).map(person -> new Person(person.getName().toUpperCase()));
|
||||
}
|
||||
|
||||
@PostMapping("/flux")
|
||||
@@ -712,11 +640,6 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq
|
||||
return persons.map(person -> new Person(person.getName().toUpperCase()));
|
||||
}
|
||||
|
||||
@PostMapping("/rxjava2-observable")
|
||||
public io.reactivex.Observable<Person> transformObservable(@RequestBody io.reactivex.Observable<Person> persons) {
|
||||
return persons.map(person -> new Person(person.getName().toUpperCase()));
|
||||
}
|
||||
|
||||
@PostMapping("/flowable")
|
||||
public Flowable<Person> transformFlowable(@RequestBody Flowable<Person> persons) {
|
||||
return persons.map(person -> new Person(person.getName().toUpperCase()));
|
||||
@@ -743,11 +666,6 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq
|
||||
|
||||
@PostMapping("/single")
|
||||
public Completable createWithSingle(@RequestBody Single<Person> single) {
|
||||
return single.map(persons::add).toCompletable();
|
||||
}
|
||||
|
||||
@PostMapping("/rxjava2-single")
|
||||
public io.reactivex.Completable createWithRxJava2Single(@RequestBody io.reactivex.Single<Person> single) {
|
||||
return single.map(persons::add).ignoreElement();
|
||||
}
|
||||
|
||||
@@ -757,19 +675,12 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq
|
||||
}
|
||||
|
||||
@PostMapping("/observable")
|
||||
public Observable<Void> createWithObservable(@RequestBody Observable<Person> observable) {
|
||||
return observable.toList().doOnNext(persons::addAll).flatMap(document -> Observable.empty());
|
||||
}
|
||||
|
||||
@PostMapping("/rxjava2-observable")
|
||||
public io.reactivex.Completable createWithRxJava2Observable(
|
||||
@RequestBody io.reactivex.Observable<Person> observable) {
|
||||
|
||||
public Completable createWithObservable(@RequestBody Observable<Person> observable) {
|
||||
return observable.toList().doOnSuccess(persons::addAll).ignoreElement();
|
||||
}
|
||||
|
||||
@PostMapping("/flowable")
|
||||
public io.reactivex.Completable createWithFlowable(@RequestBody Flowable<Person> flowable) {
|
||||
public Completable createWithFlowable(@RequestBody Flowable<Person> flowable) {
|
||||
return flowable.toList().doOnSuccess(persons::addAll).ignoreElement();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -20,11 +20,11 @@ import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.core.Completable;
|
||||
import io.reactivex.rxjava3.core.Single;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
import rx.Completable;
|
||||
import rx.Single;
|
||||
|
||||
import org.springframework.core.codec.ByteBufferEncoder;
|
||||
import org.springframework.core.codec.CharSequenceEncoder;
|
||||
|
||||
@@ -28,13 +28,13 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import io.reactivex.rxjava3.core.Completable;
|
||||
import io.reactivex.rxjava3.core.Single;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
import rx.Completable;
|
||||
import rx.Single;
|
||||
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.ResolvableType;
|
||||
|
||||
@@ -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.
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.web.reactive.result.method.annotation;
|
||||
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.rxjava3.core.Single;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
|
||||
@@ -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,8 +21,8 @@ import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.core.Single;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@@ -26,11 +26,11 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import io.reactivex.rxjava3.core.Completable;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
import rx.Completable;
|
||||
|
||||
import org.springframework.context.support.StaticApplicationContext;
|
||||
import org.springframework.core.MethodParameter;
|
||||
|
||||
@@ -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.
|
||||
@@ -19,7 +19,7 @@ package org.springframework.web.reactive.function.server
|
||||
import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import io.reactivex.Flowable
|
||||
import io.reactivex.rxjava3.core.Flowable
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
|
||||
Reference in New Issue
Block a user