Servlet { @Override public int hashCode() { assertHostState(); final int prime = 31; int result = 1; result = prime * result + ((contextRoot == null) ? 0 : contextRoot.hashCode()); result = prime * result + ((host == null) ? 0 : host.hashCode()); result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + port; return result; } Servlet(String name, String contextRoot); String getName(); String getContextRoot(); URI getBaseURI(); URI getFullURI(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test(expected = IllegalStateException.class) public void testHashCodeForNullHost() { servlet.hashCode(); }
@Test public void testHashCodeForNonNullHost() { try { servletWithParent.hashCode(); } catch (IllegalStateException e) { failOnUnexpectedException(e); } }