Java Code Examples for io.grpc.internal.testing.TestUtils#testServerAddress()

The following examples show how to use io.grpc.internal.testing.TestUtils#testServerAddress() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NettyClientTransportTest.java    From grpc-nebula-java with Apache License 2.0 6 votes vote down vote up
private void startServer(int maxStreamsPerConnection, int maxHeaderListSize) throws IOException {
  server = new NettyServer(
      TestUtils.testServerAddress(0),
      NioServerSocketChannel.class,
      new HashMap<ChannelOption<?>, Object>(),
      group, group, negotiator,
      Collections.<ServerStreamTracer.Factory>emptyList(),
      TransportTracer.getDefaultFactory(),
      maxStreamsPerConnection,
      DEFAULT_WINDOW_SIZE, DEFAULT_MAX_MESSAGE_SIZE, maxHeaderListSize,
      DEFAULT_SERVER_KEEPALIVE_TIME_NANOS, DEFAULT_SERVER_KEEPALIVE_TIMEOUT_NANOS,
      MAX_CONNECTION_IDLE_NANOS_DISABLED,
      MAX_CONNECTION_AGE_NANOS_DISABLED, MAX_CONNECTION_AGE_GRACE_NANOS_INFINITE, true, 0,
      channelz);
  server.start(serverListener);
  address = TestUtils.testServerAddress(server.getPort());
  authority = GrpcUtil.authorityFromHostAndPort(address.getHostString(), address.getPort());
}
 
Example 2
Source File: NettyClientTransportTest.java    From grpc-java with Apache License 2.0 6 votes vote down vote up
private void startServer(int maxStreamsPerConnection, int maxHeaderListSize) throws IOException {
  server = new NettyServer(
      TestUtils.testServerAddress(new InetSocketAddress(0)),
      new ReflectiveChannelFactory<>(NioServerSocketChannel.class),
      new HashMap<ChannelOption<?>, Object>(),
      new HashMap<ChannelOption<?>, Object>(),
      new FixedObjectPool<>(group), new FixedObjectPool<>(group), false, negotiator,
      Collections.<ServerStreamTracer.Factory>emptyList(),
      TransportTracer.getDefaultFactory(),
      maxStreamsPerConnection,
      false,
      DEFAULT_WINDOW_SIZE, DEFAULT_MAX_MESSAGE_SIZE, maxHeaderListSize,
      DEFAULT_SERVER_KEEPALIVE_TIME_NANOS, DEFAULT_SERVER_KEEPALIVE_TIMEOUT_NANOS,
      MAX_CONNECTION_IDLE_NANOS_DISABLED,
      MAX_CONNECTION_AGE_NANOS_DISABLED, MAX_CONNECTION_AGE_GRACE_NANOS_INFINITE, true, 0,
      channelz);
  server.start(serverListener);
  address = TestUtils.testServerAddress((InetSocketAddress) server.getListenSocketAddress());
  authority = GrpcUtil.authorityFromHostAndPort(address.getHostString(), address.getPort());
}
 
Example 3
Source File: NettyClientTransportTest.java    From grpc-nebula-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testToString() throws Exception {
  address = TestUtils.testServerAddress(12345);
  authority = GrpcUtil.authorityFromHostAndPort(address.getHostString(), address.getPort());
  String s = newTransport(newNegotiator()).toString();
  transports.clear();
  assertTrue("Unexpected: " + s, s.contains("NettyClientTransport"));
  assertTrue("Unexpected: " + s, s.contains(address.toString()));
}
 
Example 4
Source File: NettyClientTransportTest.java    From grpc-nebula-java with Apache License 2.0 5 votes vote down vote up
@Test
public void getAttributes_negotiatorHandler() throws Exception {
  address = TestUtils.testServerAddress(12345);
  authority = GrpcUtil.authorityFromHostAndPort(address.getHostString(), address.getPort());

  NettyClientTransport transport = newTransport(new NoopProtocolNegotiator());
  callMeMaybe(transport.start(clientTransportListener));

  assertEquals(Attributes.EMPTY, transport.getAttributes());
}
 
Example 5
Source File: NettyClientTransportTest.java    From grpc-nebula-java with Apache License 2.0 5 votes vote down vote up
@Test
public void getEagAttributes_negotiatorHandler() throws Exception {
  address = TestUtils.testServerAddress(12345);
  authority = GrpcUtil.authorityFromHostAndPort(address.getHostString(), address.getPort());

  NoopProtocolNegotiator npn = new NoopProtocolNegotiator();
  eagAttributes = Attributes.newBuilder()
      .set(Attributes.Key.create("trash"), "value")
      .build();
  NettyClientTransport transport = newTransport(npn);
  callMeMaybe(transport.start(clientTransportListener));

  // EAG Attributes are available before the negotiation is complete
  assertSame(eagAttributes, npn.grpcHandler.getEagAttributes());
}
 
Example 6
Source File: NettyClientTransportTest.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testToString() throws Exception {
  address = TestUtils.testServerAddress(new InetSocketAddress(12345));
  authority = GrpcUtil.authorityFromHostAndPort(address.getHostString(), address.getPort());
  String s = newTransport(newNegotiator()).toString();
  transports.clear();
  assertTrue("Unexpected: " + s, s.contains("NettyClientTransport"));
  assertTrue("Unexpected: " + s, s.contains(address.toString()));
}
 
Example 7
Source File: NettyClientTransportTest.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
@Test
public void getAttributes_negotiatorHandler() throws Exception {
  address = TestUtils.testServerAddress(new InetSocketAddress(12345));
  authority = GrpcUtil.authorityFromHostAndPort(address.getHostString(), address.getPort());

  NettyClientTransport transport = newTransport(new NoopProtocolNegotiator());
  callMeMaybe(transport.start(clientTransportListener));

  assertNotNull(transport.getAttributes());
}
 
Example 8
Source File: NettyClientTransportTest.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
@Test
public void getEagAttributes_negotiatorHandler() throws Exception {
  address = TestUtils.testServerAddress(new InetSocketAddress(12345));
  authority = GrpcUtil.authorityFromHostAndPort(address.getHostString(), address.getPort());

  NoopProtocolNegotiator npn = new NoopProtocolNegotiator();
  eagAttributes = Attributes.newBuilder()
      .set(Attributes.Key.create("trash"), "value")
      .build();
  NettyClientTransport transport = newTransport(npn);
  callMeMaybe(transport.start(clientTransportListener));

  // EAG Attributes are available before the negotiation is complete
  assertSame(eagAttributes, npn.grpcHandler.getEagAttributes());
}