@Test public void equalsAndHashcode() throws Exception { Throwable throwable = new Throwable(); Exception e1 = new WikiCreationException("message", throwable); Exception e2 = new WikiCreationException("message", throwable); Exception e3 = new WikiCreationException("message", throwable); Exception e4 = new WikiCreationException("message2", throwable); Exception e5 = new WikiCreationException("message", new Throwable()); Exception e6 = new Exception(); assertEquals(e1, e1); assertEquals(e1, e2); assertEquals(e2, e1); assertEquals(e1, e2); assertEquals(e1.hashCode(), e2.hashCode()); assertEquals(e2, e3); assertEquals(e2.hashCode(), e3.hashCode()); assertEquals(e1, e3); assertEquals(e1.hashCode(), e3.hashCode()); assertNotEquals(e4, e1); assertNotEquals(e4.hashCode(), e1.hashCode()); assertNotEquals(e1, e5); assertNotEquals(e5, e1); assertNotEquals(e1.hashCode(), e5.hashCode()); assertNotEquals(e6, e1); assertNotEquals(e1, e6); assertNotEquals(e1.hashCode(), e6.hashCode()); }
@Override public int hashCode() { return getMessage().hashCode() + (getCause() != null ? getCause().hashCode() : 0); }
WikiCreationException extends Exception { @Override public int hashCode() { return getMessage().hashCode() + (getCause() != null ? getCause().hashCode() : 0); } }
WikiCreationException extends Exception { @Override public int hashCode() { return getMessage().hashCode() + (getCause() != null ? getCause().hashCode() : 0); } WikiCreationException(String message);  WikiCreationException(String message, Throwable cause); }
WikiCreationException extends Exception { @Override public int hashCode() { return getMessage().hashCode() + (getCause() != null ? getCause().hashCode() : 0); } WikiCreationException(String message);  WikiCreationException(String message, Throwable cause); @Override boolean equals(Object o); @Override int hashCode(); }
WikiCreationException extends Exception { @Override public int hashCode() { return getMessage().hashCode() + (getCause() != null ? getCause().hashCode() : 0); } WikiCreationException(String message);  WikiCreationException(String message, Throwable cause); @Override boolean equals(Object o); @Override int hashCode();  }