Search in sources :

Example 1 with NoopBlockingStub

use of io.grpc.stub.AbstractBlockingStubTest.NoopBlockingStub in project grpc-java by grpc.

the class AbstractBlockingStubTest method defaultCallOptions.

@Test
public void defaultCallOptions() {
    NoopBlockingStub stub = NoopBlockingStub.newStub(new StubFactory<NoopBlockingStub>() {

        @Override
        public NoopBlockingStub newStub(Channel channel, CallOptions callOptions) {
            return create(channel, callOptions);
        }
    }, channel, CallOptions.DEFAULT);
    assertThat(stub.getCallOptions().getOption(ClientCalls.STUB_TYPE_OPTION)).isEqualTo(StubType.BLOCKING);
}
Also used : Channel(io.grpc.Channel) NoopBlockingStub(io.grpc.stub.AbstractBlockingStubTest.NoopBlockingStub) CallOptions(io.grpc.CallOptions) Test(org.junit.Test)

Example 2 with NoopBlockingStub

use of io.grpc.stub.AbstractBlockingStubTest.NoopBlockingStub in project grpc-java by grpc.

the class AbstractAsyncStubTest method newStub_blockingStub_throwsException.

@Test
@SuppressWarnings("AssertionFailureIgnored")
public void newStub_blockingStub_throwsException() {
    try {
        NoopBlockingStub unused = NoopAsyncStub.newStub(new StubFactory<NoopBlockingStub>() {

            @Override
            public NoopBlockingStub newStub(Channel channel, CallOptions callOptions) {
                return new NoopBlockingStub(channel, callOptions);
            }
        }, channel, CallOptions.DEFAULT);
        fail("should not reach here");
    } catch (AssertionError e) {
        assertThat(e).hasMessageThat().startsWith("Expected AbstractAsyncStub");
    }
}
Also used : Channel(io.grpc.Channel) NoopBlockingStub(io.grpc.stub.AbstractBlockingStubTest.NoopBlockingStub) CallOptions(io.grpc.CallOptions) Test(org.junit.Test)

Example 3 with NoopBlockingStub

use of io.grpc.stub.AbstractBlockingStubTest.NoopBlockingStub in project grpc-java by grpc.

the class AbstractFutureStubTest method newStub_blockingStub_throwsException.

@Test
@SuppressWarnings("AssertionFailureIgnored")
public void newStub_blockingStub_throwsException() {
    try {
        NoopBlockingStub unused = NoopFutureStub.newStub(new StubFactory<NoopBlockingStub>() {

            @Override
            public NoopBlockingStub newStub(Channel channel, CallOptions callOptions) {
                return new NoopBlockingStub(channel, callOptions);
            }
        }, channel, CallOptions.DEFAULT);
        fail("should not reach here");
    } catch (AssertionError e) {
        assertThat(e).hasMessageThat().startsWith("Expected AbstractFutureStub");
    }
}
Also used : Channel(io.grpc.Channel) NoopBlockingStub(io.grpc.stub.AbstractBlockingStubTest.NoopBlockingStub) CallOptions(io.grpc.CallOptions) Test(org.junit.Test)

Aggregations

CallOptions (io.grpc.CallOptions)3 Channel (io.grpc.Channel)3 NoopBlockingStub (io.grpc.stub.AbstractBlockingStubTest.NoopBlockingStub)3 Test (org.junit.Test)3