当前位置: 首页>>代码示例>>Java>>正文


Java Single.test方法代码示例

本文整理汇总了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);
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:11,代码来源:ServerErrorIntegrationTest.java

示例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);
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:11,代码来源:ServerErrorIntegrationTest.java

示例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])>]");
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:28,代码来源:ChainedCallIntegrationTest.java

示例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);
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:11,代码来源:UnexpectedServerErrorIntegrationTest.java

示例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);
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:13,代码来源:UnexpectedServerErrorIntegrationTest.java

示例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");
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:13,代码来源:ReactiveClientStandardServerInteropTest.java

示例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");
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:13,代码来源:ReactiveClientStandardServerInteropTest.java


注:本文中的io.reactivex.Single.test方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。