### Question:
PeerAddress implements Comparable { private void fromString(String addr) { if (addr == null || addr.isEmpty()) { addr = "localhost"; } try { String a = addr.toLowerCase(); if (!a.startsWith("http")) { a = "http: } URL u = new URL(a); hostName = u.getHost(); setHost(hostName); port = u.getPort(); if (port == -1) { port = Constants.DEFAULT_PEER_PORT; } } catch (MalformedURLException ex) { valid = false; } } PeerAddress(int port, String host);  PeerAddress();  PeerAddress(String hostWithPort); String formatIP6Address(String addr); String getHost(); Integer getPort(); final void setPort(Integer port); String getAddrWithPort(); InetAddress getInetAddress(); String getHostName(); boolean isLocal(); @Override int compareTo(Object t); boolean isValid(); @Override String toString();  }### Answer:
@Test public void testFromString() throws MalformedURLException, UnknownHostException { PeerAddress a = new PeerAddress("192.168.0.1"); int port = a.getPort(); String hp = a.getAddrWithPort(); assertEquals(hp, "192.168.0.1" + ":" + Integer.toString(Constants.DEFAULT_PEER_PORT)); assertEquals(port, Constants.DEFAULT_PEER_PORT); a = new PeerAddress("[fe80::d166:519e:5758:d24a]"); hp = a.getAddrWithPort(); assertEquals(hp, "[fe80:0:0:0:d166:519e:5758:d24a]" + ":" + Integer.toString(Constants.DEFAULT_PEER_PORT)); }