public void testAddThenNextThrowsCME() { TripleBunch b = getBunch(); b.add(Triple.create("a P b")); b.add(Triple.create("c Q d")); Iterator it = b.iterator(); it.next(); b.add(Triple.create("change its state")); try { it.next(); fail("should have thrown ConcurrentModificationException"); } catch (ConcurrentModificationException e) { pass(); } }
public void testAddDuringAppThrowsCME() { final TripleBunch b = getBunch(); b.add(Triple.create("a P b")); b.add(Triple.create("c Q d")); StageElement se = new StageElement() { public void run(Domain current) { b.add(Triple.create("S P O")); } }; try { b.app(new Domain(0), se, mob); fail(" should throw CME"); } catch (ConcurrentModificationException e) { pass(); } }