Search in sources :

Example 16 with Channel

use of io.grpc.Channel 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 17 with Channel

use of io.grpc.Channel 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 18 with Channel

use of io.grpc.Channel in project grpc-java by grpc.

the class AbstractAsyncStubTest method newStub_futureStub_throwsException.

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

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

Example 19 with Channel

use of io.grpc.Channel 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)

Example 20 with Channel

use of io.grpc.Channel 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)

Aggregations

Channel (io.grpc.Channel)60 CallOptions (io.grpc.CallOptions)37 Test (org.junit.Test)33 Metadata (io.grpc.Metadata)25 MethodDescriptor (io.grpc.MethodDescriptor)20 ClientInterceptor (io.grpc.ClientInterceptor)19 ManagedChannel (io.grpc.ManagedChannel)17 ClientCall (io.grpc.ClientCall)14 SocketAddress (java.net.SocketAddress)8 ByteString (com.google.protobuf.ByteString)7 SimpleForwardingClientCall (io.grpc.ForwardingClientCall.SimpleForwardingClientCall)7 NoopClientCall (io.grpc.internal.NoopClientCall)6 AtomicReference (java.util.concurrent.atomic.AtomicReference)6 Duration (com.google.protobuf.Duration)5 ChannelLogger (io.grpc.ChannelLogger)5 Status (io.grpc.Status)5 ClientStreamTracer (io.grpc.ClientStreamTracer)4 ForwardingClientCall (io.grpc.ForwardingClientCall)4 SimpleForwardingClientCallListener (io.grpc.ForwardingClientCallListener.SimpleForwardingClientCallListener)4 Subchannel (io.grpc.LoadBalancer.Subchannel)4