HostAndPort implements DataSerializableFixedID { public InetSocketAddress getSocketInetAddress() { if (socketInetAddress.isUnresolved()) { return new InetSocketAddress(socketInetAddress.getHostString(), socketInetAddress.getPort()); } else { return this.socketInetAddress; } } HostAndPort();  HostAndPort(String hostName, int port); InetSocketAddress getSocketInetAddress(); String getHostName(); int getPort(); @Override int hashCode(); @Override boolean equals(Object o); @Override String toString(); InetAddress getAddress(); @Override int getDSFID(); @Override void toData(DataOutput out, SerializationContext context); @Override void fromData(DataInput in, DeserializationContext context); @Override KnownVersion[] getSerializationVersions();  }
@Test public void getSocketInetAddress_returns_resolved_SocketAddress() { HostAndPort locator1 = new HostAndPort("localhost", 8080); InetSocketAddress actual = locator1.getSocketInetAddress(); assertThat(actual.isUnresolved()).isFalse(); }
@Test public void getSocketInentAddress_returns_unresolved_SocketAddress() { HostAndPort locator1 = new HostAndPort("fakelocalhost", 8090); InetSocketAddress actual = locator1.getSocketInetAddress(); assertThat(actual.isUnresolved()) .as("Hostname resolved unexpectedly. Check for DNS hijacking in addition to code errors.") .isTrue(); }