本文整理汇总了Java中io.reactivex.Single.test方法的典型用法代码示例。如果您正苦于以下问题:Java Single.test方法的具体用法?Java Single.test怎么用?Java Single.test使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.reactivex.Single
的用法示例。
在下文中一共展示了Single.test方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: oneToOne
import io.reactivex.Single; //导入方法依赖的package包/类
@Test
public void oneToOne() {
RxGreeterGrpc.RxGreeterStub stub = RxGreeterGrpc.newRxStub(channel);
Single<HelloResponse> resp = stub.sayHello(Single.just(HelloRequest.getDefaultInstance()));
TestObserver<HelloResponse> test = resp.test();
test.awaitTerminalEvent(3, TimeUnit.SECONDS);
test.assertError(t -> t instanceof StatusRuntimeException);
test.assertError(t -> ((StatusRuntimeException)t).getStatus() == Status.INTERNAL);
}
示例2: manyToOne
import io.reactivex.Single; //导入方法依赖的package包/类
@Test
public void manyToOne() {
RxGreeterGrpc.RxGreeterStub stub = RxGreeterGrpc.newRxStub(channel);
Single<HelloResponse> resp = stub.sayHelloReqStream(Flowable.just(HelloRequest.getDefaultInstance()));
TestObserver<HelloResponse> test = resp.test();
test.awaitTerminalEvent(3, TimeUnit.SECONDS);
test.assertError(t -> t instanceof StatusRuntimeException);
test.assertError(t -> ((StatusRuntimeException)t).getStatus() == Status.INTERNAL);
}
示例3: servicesCanCallOtherServices
import io.reactivex.Single; //导入方法依赖的package包/类
@Test
public void servicesCanCallOtherServices() throws InterruptedException {
RxGreeterGrpc.RxGreeterStub stub = RxGreeterGrpc.newRxStub(channel);
Single<HelloRequest> input = Single.just(request("X"));
Single<HelloRequest> one = stub.sayHello(input)
.map(ChainedCallIntegrationTest::bridge)
.doOnSuccess(System.out::println);
Flowable<HelloRequest> two = stub.sayHelloRespStream(one)
.map(ChainedCallIntegrationTest::bridge)
.doOnNext(System.out::println);
Flowable<HelloRequest> three = stub.sayHelloBothStream(two)
.map(ChainedCallIntegrationTest::bridge)
.doOnNext(System.out::println);
Single<HelloRequest> four = stub.sayHelloReqStream(three)
.map(ChainedCallIntegrationTest::bridge)
.doOnSuccess(System.out::println);
Single<String> five = stub.sayHello(four)
.map(HelloResponse::getMessage)
.doOnSuccess(System.out::println);
TestObserver<String> test = five.test();
test.awaitTerminalEvent(2, TimeUnit.SECONDS);
test.assertComplete();
test.assertValue("[<{[X]}> :: </[X]/> :: <\\[X]\\> :: <([X])>]");
}
示例4: oneToOne
import io.reactivex.Single; //导入方法依赖的package包/类
@Test
public void oneToOne() {
RxGreeterGrpc.RxGreeterStub stub = RxGreeterGrpc.newRxStub(channel);
Single<HelloResponse> resp = stub.sayHello(Single.just(HelloRequest.getDefaultInstance()));
TestObserver<HelloResponse> test = resp.test();
test.awaitTerminalEvent(3, TimeUnit.SECONDS);
test.assertError(t -> t instanceof StatusRuntimeException);
test.assertError(t -> ((StatusRuntimeException)t).getStatus().getCode() == Status.Code.INTERNAL);
}
示例5: manyToOne
import io.reactivex.Single; //导入方法依赖的package包/类
@Test
public void manyToOne() {
RxGreeterGrpc.RxGreeterStub stub = RxGreeterGrpc.newRxStub(channel);
Flowable<HelloRequest> req = Flowable.just(HelloRequest.getDefaultInstance());
Single<HelloResponse> resp = stub.sayHelloReqStream(req);
TestObserver<HelloResponse> test = resp.test();
test.awaitTerminalEvent(3, TimeUnit.SECONDS);
test.assertError(t -> t instanceof StatusRuntimeException);
// Flowable requests get canceled when unexpected errors happen
test.assertError(t -> ((StatusRuntimeException)t).getStatus().getCode() == Status.Code.CANCELLED);
}
示例6: oneToOne
import io.reactivex.Single; //导入方法依赖的package包/类
@Test
public void oneToOne() {
RxGreeterGrpc.RxGreeterStub stub = RxGreeterGrpc.newRxStub(channel);
Single<String> rxRequest = Single.just("World");
Single<String> rxResponse = stub.sayHello(rxRequest.map(this::toRequest)).map(this::fromResponse);
TestObserver<String> test = rxResponse.test();
test.awaitTerminalEvent(1, TimeUnit.SECONDS);
test.assertNoErrors();
test.assertValue("Hello World");
}
示例7: manyToOne
import io.reactivex.Single; //导入方法依赖的package包/类
@Test
public void manyToOne() {
RxGreeterGrpc.RxGreeterStub stub = RxGreeterGrpc.newRxStub(channel);
Flowable<String> rxRequest = Flowable.just("A", "B", "C");
Single<String> rxResponse = stub.sayHelloReqStream(rxRequest.map(this::toRequest)).map(this::fromResponse);
TestObserver<String> test = rxResponse.test();
test.awaitTerminalEvent(1, TimeUnit.SECONDS);
test.assertNoErrors();
test.assertValue("Hello A and B and C");
}