package nl.tudelft.simulation.event.util; import java.util.ArrayList; import java.util.List; import junit.framework.Assert; import junit.framework.TestCase; import nl.tudelft.simulation.event.EventInterface; import nl.tudelft.simulation.event.EventListenerInterface; /** * The test script for the EventIterator class. *

* (c) copyright 2002-2005-2004 Delft University of Technology , the * Netherlands.
* See for project information www.simulation.tudelft.nl
* License of use: Lesser General Public License (LGPL) , no * warranty. * @author Peter Jacobs * @version $Revision: 1.2 $ $Date: 2010/08/10 11:38:12 $ * @since 1.5 */ public class EventIteratorTest extends TestCase implements EventListenerInterface { /** a check on the removed state. */ private boolean removed = false; /** TEST_METHOD is the name of the test method. */ public static final String TEST_METHOD = "test"; /** * constructs a new EventIteratorTest. */ public EventIteratorTest() { this(TEST_METHOD); } /** * constructs a new EventIteratorTest. * @param method the name of the test method */ public EventIteratorTest(final String method) { super(method); } /** * tests the classes in the reference class. */ public void test() { List list = new ArrayList(); list.add(new Object()); EventIterator iterator = new EventIterator(list.iterator()); iterator.next(); iterator.addListener(this, EventIterator.OBJECT_REMOVED_EVENT); iterator.remove(); Assert.assertTrue(this.removed); } /** {@inheritDoc} */ @Override public void notify(final EventInterface event) { if (event.getType().equals(EventIterator.OBJECT_REMOVED_EVENT)) { this.removed = true; } } }