use of 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");
}
}
use of 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());
}
use of 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();
}
use of io.grpc.CallOptions in project grpc-java by grpc.
the class LoggingChannelProviderTest method forTarget_interceptorCalled.
@Test
public void forTarget_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.forTarget("localhost");
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();
}
use of io.grpc.CallOptions in project grpc-java by grpc.
the class CronetClientStreamTest method withAnnotation.
@Test
public void withAnnotation() {
Object annotation1 = new Object();
Object annotation2 = new Object();
CallOptions callOptions = CronetClientStream.withAnnotation(CallOptions.DEFAULT, annotation1);
callOptions = CronetClientStream.withAnnotation(callOptions, annotation2);
SetStreamFactoryRunnable callback = new SetStreamFactoryRunnable(factory);
CronetClientStream stream = new CronetClientStream("https://www.google.com:443", "cronet", executor, metadata, transport, callback, lock, 100, false, /* alwaysUsePut */
method, StatsTraceContext.NOOP, callOptions, transportTracer, false, false);
callback.setStream(stream);
when(factory.newBidirectionalStreamBuilder(any(String.class), any(BidirectionalStream.Callback.class), any(Executor.class))).thenReturn(builder);
stream.start(clientListener);
verify(builder).addRequestAnnotation(annotation1);
verify(builder).addRequestAnnotation(annotation2);
}
Aggregations