ContextResource extends AbstractResource { @Override public int hashCode() { return PRIME * context.hashCode() + getPath().hashCode(); } ContextResource(Context context, String path); @Override String toString(); URL toURL(); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void hash_code() { Context context1 = mockContext(); Context context2 = mockContext(); replay(); Resource r1 = new ContextResource(context1, "foo"); Resource r2 = new ContextResource(context1, "foo"); Resource r3 = new ContextResource(context2, "foo"); Resource r4 = new ContextResource(context1, "bar"); assertTrue(r1.hashCode() == r2.hashCode()); assertFalse(r1.hashCode() == r3.hashCode()); assertFalse(r1.hashCode() == r4.hashCode()); verify(); }