use of org.apache.beam.vendor.grpc.v1p43p2.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);
}
use of org.apache.beam.vendor.grpc.v1p43p2.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");
}
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Channel 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");
}
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Channel 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 org.apache.beam.vendor.grpc.v1p43p2.io.grpc.Channel in project grpc-java by grpc.
the class AltsProtocolNegotiatorTest method setup.
@Before
public void setup() throws Exception {
ChannelHandler uncaughtExceptionHandler = new ChannelDuplexHandler() {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
caughtException = cause;
super.exceptionCaught(ctx, cause);
ctx.close();
}
};
TsiHandshakerFactory handshakerFactory = new DelegatingTsiHandshakerFactory(FakeTsiHandshaker.clientHandshakerFactory()) {
@Override
public TsiHandshaker newHandshaker(String authority, ChannelLogger logger) {
return new DelegatingTsiHandshaker(super.newHandshaker(authority, logger)) {
@Override
public TsiPeer extractPeer() throws GeneralSecurityException {
return mockedTsiPeer;
}
@Override
public Object extractPeerObject() throws GeneralSecurityException {
return mockedAltsContext;
}
};
}
};
ManagedChannel fakeChannel = NettyChannelBuilder.forTarget("localhost:8080").build();
ObjectPool<Channel> fakeChannelPool = new FixedObjectPool<Channel>(fakeChannel);
LazyChannel lazyFakeChannel = new LazyChannel(fakeChannelPool);
ChannelHandler altsServerHandler = new ServerAltsProtocolNegotiator(handshakerFactory, lazyFakeChannel).newHandler(grpcHandler);
// On real server, WBAEH fires default ProtocolNegotiationEvent. KickNH provides this behavior.
ChannelHandler handler = new KickNegotiationHandler(altsServerHandler);
channel = new EmbeddedChannel(uncaughtExceptionHandler, handler);
}
Aggregations