RpcStreamConnection extends RpcConnection { public String getServerIpPort() { String serverIpPort = null; if (!StringUtils.equals(hostIp, UNKNOWN_SERVER_HOST)) { serverIpPort = hostIp; if (hostPort != UNKNOWN_SERVER_PORT) { serverIpPort += ":" + String.valueOf(hostPort); } } else if (hostPort != UNKNOWN_SERVER_PORT) { serverIpPort = Integer.toString(hostPort); } return serverIpPort; } RpcStreamConnection(String serverHost, int serverPort, Properties props,
            ServerStats stats, Charset charset);  RpcStreamConnection(String serverHost, int serverPort, Properties props,
            ServerStats stats, Charset charset, boolean secure);  RpcStreamConnection(String serverHost, int serverPort, Properties props,
            ServerStats stats, Charset charset, Socket socket);  RpcStreamConnection(String serverHost, int serverPort, Properties props,
            ServerStats stats, Charset charset, RpcSocketPool pool);  RpcStreamConnection(String serverHost, int serverPort, Properties props,
            ServerStats stats, Charset charset, Socket socket, boolean secure);  RpcStreamConnection(String serverHost, int serverPort, Properties props,
            ServerStats stats, Charset charset, RpcSocketPool pool, boolean secure);  RpcStreamConnection(String serverHost, int serverPort, Properties props,
            ServerStats stats, Charset charset, Socket socket, RpcSocketPool pool, boolean secure);  RpcStreamConnection(String serverHost, int serverPort, Properties props,
            ServerStats stats, Charset charset, Socket socket, RpcSocketPool pool, boolean secure,
            String rsh); String getServerIpPort(); String getClientIpPort(); void disconnect(final RpcPacketDispatcher dispatcher); RpcPacket getRpcPacket(); RpcPacket getRpcPacket(final RpcPacketFieldRule fieldRule,
            final IFilterCallback filterCallback); int getSystemRecvBufferSize(); int getSystemSendBufferSize(); long putRpcPackets(@Nonnull RpcPacket[] packets); long putRpcPacket(@Nonnull RpcPacket packet); @Override void useConnectionCompression(); static final String TRACE_PREFIX; }
@Test public void given_unknownHostIp_and_validHostPort_when_getServerIpPort() throws Exception { String serverIpPort = mockConnection.getServerIpPort(); assertThat(serverIpPort, is(String.valueOf(serverIpPort))); }
@Test public void given_knownHostIp_and_validHostPort_when_getServerIpPort() throws Exception { String hostIp = "127.0.0.1"; mockConnection.setHostIp(hostIp); String serverIpPort = mockConnection.getServerIpPort(); assertThat(serverIpPort, is(hostIp + ":" + String.valueOf(serverPort))); }
@Test public void given_knownHostIp_and_nonHostPort_when_getServerIpPort() throws Exception { mockConnection.setHostPort(-1); String hostIp = "127.0.0.1"; mockConnection.setHostIp(hostIp); String serverIpPort = mockConnection.getServerIpPort(); assertThat(serverIpPort, is(hostIp)); }