use of io.grpc.Channel in project grpc-java by grpc.
the class BinaryLogProviderTest method wrapChannel_methodDescriptor.
@Test
public void wrapChannel_methodDescriptor() throws Exception {
final AtomicReference<MethodDescriptor<?, ?>> methodRef = new AtomicReference<>();
Channel channel = new Channel() {
@Override
public <RequestT, ResponseT> ClientCall<RequestT, ResponseT> newCall(MethodDescriptor<RequestT, ResponseT> method, CallOptions callOptions) {
methodRef.set(method);
return new NoopClientCall<>();
}
@Override
public String authority() {
throw new UnsupportedOperationException();
}
};
Channel wChannel = binlogProvider.wrapChannel(channel);
ClientCall<String, Integer> unusedClientCall = wChannel.newCall(method, CallOptions.DEFAULT);
validateWrappedMethod(methodRef.get());
}
use of io.grpc.Channel in project grpc-java by grpc.
the class ServerImplTest method binaryLogInstalled.
@Test
public void binaryLogInstalled() throws Exception {
final SettableFuture<Boolean> intercepted = SettableFuture.create();
final ServerInterceptor interceptor = new ServerInterceptor() {
@Override
public <ReqT, RespT> Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> call, Metadata headers, ServerCallHandler<ReqT, RespT> next) {
intercepted.set(true);
return next.startCall(call, headers);
}
};
builder.binlog = new BinaryLog() {
@Override
public void close() throws IOException {
// noop
}
@Override
public <ReqT, RespT> ServerMethodDefinition<?, ?> wrapMethodDefinition(ServerMethodDefinition<ReqT, RespT> oMethodDef) {
return ServerMethodDefinition.create(oMethodDef.getMethodDescriptor(), InternalServerInterceptors.interceptCallHandlerCreate(interceptor, oMethodDef.getServerCallHandler()));
}
@Override
public Channel wrapChannel(Channel channel) {
return channel;
}
};
createAndStartServer();
basicExchangeHelper(METHOD, "Lots of pizza, please", 314, 50);
assertTrue(intercepted.get());
}
use of io.grpc.Channel in project grpc-java by grpc.
the class AbstractFutureStubTest method defaultCallOptions.
@Test
public void defaultCallOptions() {
NoopFutureStub stub = NoopFutureStub.newStub(new StubFactory<NoopFutureStub>() {
@Override
public NoopFutureStub newStub(Channel channel, CallOptions callOptions) {
return create(channel, callOptions);
}
}, channel, CallOptions.DEFAULT);
assertThat(stub.getCallOptions().getOption(ClientCalls.STUB_TYPE_OPTION)).isEqualTo(StubType.FUTURE);
}
use of 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 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();
}
Aggregations