@Test public void testDeleteIsCalled() { final AtomicBoolean deleteCalled = new AtomicBoolean(false); Event event = new Event(this) { @Override public void delete() { deleteCalled.set(true); super.delete(); }; }; event.acquire(); assertFalse(deleteCalled.get()); event.release(); assertTrue(deleteCalled.get()); }
@Test(expected = IllegalStateException.class) public void testDeleteFailsIfNoAcquire() { Event event = new Event(this) {}; event.release(); }
@Test public void testCreateEvent() { Event event = new Event(this) {}; assertTrue(event.getSource() == this); }