Search in sources :

Example 21 with CallOptions

use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.CallOptions 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 22 with CallOptions

use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.CallOptions 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)

Example 23 with CallOptions

use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.CallOptions 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 24 with CallOptions

use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.CallOptions in project grpc-java by grpc.

the class BaseAbstractStubTest method withWaitForReady.

@Test
public void withWaitForReady() {
    T stub = create(channel);
    CallOptions callOptions = stub.getCallOptions();
    assertFalse(callOptions.isWaitForReady());
    stub = stub.withWaitForReady();
    callOptions = stub.getCallOptions();
    assertTrue(callOptions.isWaitForReady());
}
Also used : CallOptions(io.grpc.CallOptions) Test(org.junit.Test)

Example 25 with CallOptions

use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.CallOptions in project grpc-java by grpc.

the class LoggingChannelProviderTest method forAddress_interceptorCalled.

@Test
public void forAddress_interceptorCalled() {
    ClientInterceptor interceptor = mock(ClientInterceptor.class, delegatesTo(new NoopInterceptor()));
    InternalLoggingChannelInterceptor.Factory factory = mock(InternalLoggingChannelInterceptor.Factory.class);
    when(factory.create()).thenReturn(interceptor);
    LoggingChannelProvider.init(factory);
    ManagedChannelBuilder<?> builder = ManagedChannelBuilder.forAddress("localhost", 80);
    ManagedChannel channel = builder.build();
    CallOptions callOptions = CallOptions.DEFAULT;
    ClientCall<Void, Void> unused = channel.newCall(method, callOptions);
    verify(interceptor).interceptCall(same(method), same(callOptions), ArgumentMatchers.<Channel>any());
    channel.shutdownNow();
    LoggingChannelProvider.finish();
}
Also used : InternalLoggingChannelInterceptor(io.grpc.observability.interceptors.InternalLoggingChannelInterceptor) ClientInterceptor(io.grpc.ClientInterceptor) ManagedChannel(io.grpc.ManagedChannel) CallOptions(io.grpc.CallOptions) Test(org.junit.Test)

Aggregations

CallOptions (io.grpc.CallOptions)81 Test (org.junit.Test)61 Metadata (io.grpc.Metadata)50 Channel (io.grpc.Channel)36 MethodDescriptor (io.grpc.MethodDescriptor)28 ClientInterceptor (io.grpc.ClientInterceptor)23 ManagedChannel (io.grpc.ManagedChannel)18 ClientStreamTracer (io.grpc.ClientStreamTracer)17 ClientCall (io.grpc.ClientCall)15 PickSubchannelArgs (io.grpc.LoadBalancer.PickSubchannelArgs)11 Status (io.grpc.Status)11 Context (io.grpc.Context)10 Subchannel (io.grpc.LoadBalancer.Subchannel)10 MockClientTransportInfo (io.grpc.internal.TestUtils.MockClientTransportInfo)10 ForwardingSubchannel (io.grpc.util.ForwardingSubchannel)9 SimpleForwardingClientCall (io.grpc.ForwardingClientCall.SimpleForwardingClientCall)8 NoopClientCall (io.grpc.internal.NoopClientCall)8 SocketAddress (java.net.SocketAddress)8 SimpleForwardingClientCallListener (io.grpc.ForwardingClientCallListener.SimpleForwardingClientCallListener)7 ByteString (com.google.protobuf.ByteString)6