### Question:
ServerImpl extends io.grpc.Server implements InternalInstrumented<ServerStats> { @Override public int getPort() { synchronized (lock) { checkState(started, "Not started"); checkState(!terminated, "Already terminated"); return transportServer.getPort(); } } ServerImpl(
      AbstractServerImplBuilder<?> builder,
      InternalServer transportServer,
      Context rootContext); @Override ServerImpl start(); @Override int getPort(); @Override List<ServerServiceDefinition> getServices(); @Override List<ServerServiceDefinition> getImmutableServices(); @Override List<ServerServiceDefinition> getMutableServices(); @Override ServerImpl shutdown(); @Override ServerImpl shutdownNow(); @Override boolean isShutdown(); @Override boolean awaitTermination(long timeout, TimeUnit unit); @Override void awaitTermination(); @Override boolean isTerminated(); @Override InternalLogId getLogId(); @Override ListenableFuture<ServerStats> getStats(); @Override HandlerRegistry getRegistry(); @Override String toString();  }### Answer:
@Test public void getPort() throws Exception { transportServer = new SimpleServer() { @Override public int getPort() { return 65535; } }; createAndStartServer(); assertThat(server.getPort()).isEqualTo(65535); }
@Test public void getPortBeforeStartedFails() { transportServer = new SimpleServer(); createServer(); thrown.expect(IllegalStateException.class); thrown.expectMessage("started"); server.getPort(); }