Search in sources :

Example 1 with NoopAsyncStub

use of io.grpc.stub.AbstractAsyncStubTest.NoopAsyncStub in project grpc-java by grpc.

the class AbstractFutureStubTest method newStub_asyncStub_throwsException.

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

            @Override
            public NoopAsyncStub newStub(Channel channel, CallOptions callOptions) {
                return new NoopAsyncStub(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) CallOptions(io.grpc.CallOptions) NoopAsyncStub(io.grpc.stub.AbstractAsyncStubTest.NoopAsyncStub) Test(org.junit.Test)

Example 2 with NoopAsyncStub

use of io.grpc.stub.AbstractAsyncStubTest.NoopAsyncStub in project grpc-java by grpc.

the class AbstractBlockingStubTest method newStub_asyncStub_throwsException.

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

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

Example 3 with NoopAsyncStub

use of io.grpc.stub.AbstractAsyncStubTest.NoopAsyncStub in project grpc-java by grpc.

the class AbstractAsyncStubTest method defaultCallOptions.

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

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

Aggregations

CallOptions (io.grpc.CallOptions)3 Channel (io.grpc.Channel)3 NoopAsyncStub (io.grpc.stub.AbstractAsyncStubTest.NoopAsyncStub)3 Test (org.junit.Test)3