### Question:
ServerName implements Comparable<ServerName> { public ServerName(final String hostname, final int port, final long startcode) { this.hostname = hostname; this.port = port; this.startcode = startcode; this.servername = getServerName(hostname, port, startcode); } ServerName(final String hostname, final int port, final long startcode);  ServerName(final String serverName);  ServerName(final String hostAndPort, final long startCode); static String parseHostname(final String serverName); static int parsePort(final String serverName); static long parseStartcode(final String serverName); @Override String toString(); synchronized byte [] getVersionedBytes(); String getServerName(); String getHostname(); int getPort(); long getStartcode(); static String getServerName(String hostName, int port, long startcode); static String getServerName(final String hostAndPort,
      final long startcode); String getHostAndPort(); static long getServerStartcodeFromServerName(final String serverName); static String getServerNameLessStartCode(String inServerName); @Override int compareTo(ServerName other); @Override int hashCode(); @Override boolean equals(Object o); static ServerName findServerWithSameHostnamePort(final Collection<ServerName> names,
      final ServerName serverName); static boolean isSameHostnameAndPort(final ServerName left,
      final ServerName right); static ServerName parseVersionedServerName(final byte [] versionedBytes); static ServerName parseServerName(final String str); static final int NON_STARTCODE; static final String SERVERNAME_SEPARATOR; static Pattern SERVERNAME_PATTERN; static final String UNKNOWN_SERVERNAME; }### Answer:
@Test public void testServerName() { ServerName sn = new ServerName("www.example.org", 1234, 5678); ServerName sn2 = new ServerName("www.example.org", 1234, 5678); ServerName sn3 = new ServerName("www.example.org", 1234, 56789); assertTrue(sn.equals(sn2)); assertFalse(sn.equals(sn3)); assertEquals(sn.hashCode(), sn2.hashCode()); assertNotSame(sn.hashCode(), sn3.hashCode()); assertEquals(sn.toString(), ServerName.getServerName("www.example.org", 1234, 5678)); assertEquals(sn.toString(), ServerName.getServerName("www.example.org:1234", 5678)); assertEquals(sn.toString(), "www.example.org" + ServerName.SERVERNAME_SEPARATOR + "1234" + ServerName.SERVERNAME_SEPARATOR + "5678"); }