FileDocCategorySizeDatePackage
MockPropertyChangeListener.javaAPI DocExample2426Thu Jun 27 19:20:24 BST 2002com.oreilly.mock

MockPropertyChangeListener

public class MockPropertyChangeListener extends Object implements PropertyChangeListener

Fields Summary
private List
actualEvents
private List
expectedEvents
private int
expectedEventCount
Constructors Summary
Methods Summary
public voidaddExpectedEvent(java.beans.PropertyChangeEvent e)

        if (this.expectedEvents == null) {
            this.expectedEvents = new ArrayList();
        }
        PropertyChangeEvent eventWithEquals =
                new ComparablePropertyChangeEvent(e);
        this.expectedEvents.add(eventWithEquals);
    
public java.util.ListgetEvents()

        return this.actualEvents;
    
public voidpropertyChange(java.beans.PropertyChangeEvent evt)

        this.actualEvents.add(evt);

        if (this.expectedEventCount > -1
                && this.actualEvents.size() > this.expectedEventCount) {
            Assert.fail("Exceeded the expected event count: "
                    + this.expectedEventCount);
        }
    
public voidsetExpectedEventCount(int expectedCount)


        
        this.expectedEventCount = expectedCount;
    
public voidverify()

        if (this.expectedEventCount > -1) {
            Assert.assertEquals("Actual event count",
                    this.expectedEventCount, this.actualEvents.size());
        }

        if (this.expectedEvents != null) {

            Assert.assertEquals("Actual events",
                    this.expectedEvents, this.actualEvents);
        }