URLString implements Serializable { @Override public boolean equals(Object obj) { if (obj == null) return false; if (!(obj instanceof URLString)) { return false; } URLString u2 = (URLString) obj; return toString().equals(u2.toString()); } protected  URLString();  URLString(String protocol, String host, int port, String file, String username, String password);  URLString(URL url);  URLString(File file);  URLString(String url); @Override String toString(); int getPort(); String getProtocol(); String getFile(); String getRef(); String getHost(); String getUsername(); String getPassword(); URL getURL(); @Override boolean equals(Object obj); @Override int hashCode();  }
@Test public void testEquals() throws Exception { URLString url1 = new URLString("http: URLString url_pw = new URLString("http: assertFalse(url1.equals(new Object())); assertFalse(url1.equals(null)); assertTrue(newInstance().equals(newInstance())); assertEquals(url1, new URLString("http: assertEquals(url1.hashCode(), new URLString("http: assertNotSame(url1, new URLString("http: assertNotSame(url1.hashCode(), new URLString("http: assertNotSame(url1, new URLString("http: assertNotSame(url1.hashCode(), new URLString("http: assertNotSame(url1, new URLString("http: assertNotSame(url1.hashCode(), new URLString("http: assertNotSame(url1, new URLString("https: assertNotSame(url1.hashCode(), new URLString("https: assertNotSame(url1, url_pw); assertNotSame(url1.hashCode(), url_pw.hashCode()); assertEquals(url_pw, new URLString("http: assertEquals(url_pw.hashCode(), new URLString("http: assertNotSame(url_pw, new URLString("http: assertNotSame(url_pw.hashCode(), new URLString("http: assertNotSame(url_pw, new URLString("http: assertNotSame(url_pw.hashCode(), new URLString("http: }