use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Channel in project grpc-java by grpc.
the class AbstractBlockingStubTest method newStub_futureStub_throwsException.
@Test
@SuppressWarnings("AssertionFailureIgnored")
public void newStub_futureStub_throwsException() {
try {
NoopFutureStub unused = NoopBlockingStub.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 AbstractBlockingStub");
}
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Channel in project grpc-java by grpc.
the class AbstractStubTest method defaultCallOptions.
@Test
public void defaultCallOptions() {
NoopStub stub = NoopStub.newStub(new StubFactory<NoopStub>() {
@Override
public NoopStub newStub(Channel channel, CallOptions callOptions) {
return create(channel, callOptions);
}
}, channel, CallOptions.DEFAULT);
assertThat(stub.getCallOptions().getOption(ClientCalls.STUB_TYPE_OPTION)).isNull();
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Channel in project grpc-java by grpc.
the class HeaderServerInterceptorTest method serverHeaderDeliveredToClient.
@Test
public void serverHeaderDeliveredToClient() {
class SpyingClientInterceptor implements ClientInterceptor {
ClientCall.Listener<?> spyListener;
@Override
public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(MethodDescriptor<ReqT, RespT> method, CallOptions callOptions, Channel next) {
return new SimpleForwardingClientCall<ReqT, RespT>(next.newCall(method, callOptions)) {
@Override
public void start(Listener<RespT> responseListener, Metadata headers) {
spyListener = responseListener = mock(ClientCall.Listener.class, delegatesTo(responseListener));
super.start(responseListener, headers);
}
};
}
}
SpyingClientInterceptor clientInterceptor = new SpyingClientInterceptor();
GreeterBlockingStub blockingStub = GreeterGrpc.newBlockingStub(channel).withInterceptors(clientInterceptor);
ArgumentCaptor<Metadata> metadataCaptor = ArgumentCaptor.forClass(Metadata.class);
blockingStub.sayHello(HelloRequest.getDefaultInstance());
assertNotNull(clientInterceptor.spyListener);
verify(clientInterceptor.spyListener).onHeaders(metadataCaptor.capture());
assertEquals("customRespondValue", metadataCaptor.getValue().get(HeaderServerInterceptor.CUSTOM_HEADER_KEY));
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Channel in project brave by openzipkin.
the class BaseITTracingServerInterceptor method createsChildWhenJoinDisabled.
@Test
public void createsChildWhenJoinDisabled() throws IOException {
tracing = tracingBuilder(NEVER_SAMPLE).supportsJoin(false).build();
grpcTracing = GrpcTracing.create(tracing);
init();
TraceContext parent = newTraceContext(SamplingFlags.SAMPLED);
Channel channel = clientWithB3SingleHeader(parent);
GreeterGrpc.newBlockingStub(channel).sayHello(HELLO_REQUEST);
assertChildOf(testSpanHandler.takeRemoteSpan(Span.Kind.SERVER), parent);
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Channel in project brave by openzipkin.
the class BaseITTracingServerInterceptor method reusesPropagatedSpanId.
@Test
public void reusesPropagatedSpanId() {
TraceContext parent = newTraceContext(SamplingFlags.SAMPLED);
Channel channel = clientWithB3SingleHeader(parent);
GreeterGrpc.newBlockingStub(channel).sayHello(HELLO_REQUEST);
assertSameIds(testSpanHandler.takeRemoteSpan(Span.Kind.SERVER), parent);
}
Aggregations