use of io.grpc.internal.InternalServer in project grpc-java by grpc.
the class AbstractTransportTest method serverAlreadyListening.
@Test
public void serverAlreadyListening() throws Exception {
client = null;
server.start(serverListener);
InternalServer server2 = newServer(server);
thrown.expect(IOException.class);
server2.start(new MockServerListener());
}
use of io.grpc.internal.InternalServer in project grpc-java by grpc.
the class ProtocolNegotiatorsTest method expectHandshake.
private Object expectHandshake(ChannelCredentials channelCreds, ServerCredentials serverCreds, boolean expectSuccess) throws Exception {
MockServerListener serverListener = new MockServerListener();
ClientTransportFactory clientFactory = NettyChannelBuilder.forAddress("localhost", 0, channelCreds).buildTransportFactory();
InternalServer server = NettyServerBuilder.forPort(0, serverCreds).buildTransportServers(Collections.<ServerStreamTracer.Factory>emptyList());
server.start(serverListener);
ManagedClientTransport.Listener clientTransportListener = mock(ManagedClientTransport.Listener.class);
ManagedClientTransport client = clientFactory.newClientTransport(server.getListenSocketAddress(), new ClientTransportFactory.ClientTransportOptions().setAuthority(TestUtils.TEST_SERVER_HOST), mock(ChannelLogger.class));
callMeMaybe(client.start(clientTransportListener));
Object result;
if (expectSuccess) {
verify(clientTransportListener, timeout(TIMEOUT_SECONDS * 1000)).transportReady();
InternalChannelz.SocketStats stats = serverListener.transports.poll().getStats().get();
assertThat(stats.security).isNotNull();
assertThat(stats.security.tls).isNotNull();
result = stats.security.tls;
} else {
ArgumentCaptor<Status> captor = ArgumentCaptor.forClass(Status.class);
verify(clientTransportListener, timeout(TIMEOUT_SECONDS * 1000)).transportShutdown(captor.capture());
result = captor.getValue();
}
client.shutdownNow(Status.UNAVAILABLE.withDescription("trash it"));
server.shutdown();
assertTrue(serverListener.waitForShutdown(TIMEOUT_SECONDS * 1000, TimeUnit.MILLISECONDS));
verify(clientTransportListener, timeout(TIMEOUT_SECONDS * 1000)).transportTerminated();
clientFactory.close();
return result;
}
Aggregations