dsto.dfc.test
Class DummyPropertyListener

java.lang.Object
  extended by dsto.dfc.test.DummyPropertyListener
All Implemented Interfaces:
PropertyChangeListener, EventListener

public class DummyPropertyListener
extends Object
implements PropertyChangeListener

Dummy test property change listener for unit tests. Used to see if a particular property change is heard from a source.

Example use:

   MyJavaBean            bean     = new MyJavaBean ();
   DummyPropertyListener listener = new DummyPropertyListener ();
   bean.addPropertyChangeListener (listener);
   
   bean.setProperty ("name", newValue);
   
   assertTrue (listener.heardIt ("name"));
   listener.reset ();
 

Version:
$Revision$
Author:
weberd

Field Summary
static String EMPTY_STRING
           
 
Constructor Summary
DummyPropertyListener()
           
 
Method Summary
 PropertyChangeEvent getEvent()
          Returns the last event heard by the listener.
 String getPropertyName()
          Returns either an empty string or the name of the last property the change event of which was heard.
 boolean heardIt(String name)
          Replies true if a property change event of the name property was heard.
 void propertyChange(PropertyChangeEvent evt)
          Invoked when a bean being listened to fires a property change event.
 void reset()
          Resets the listener so it is ready to hear new events.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_STRING

public static final String EMPTY_STRING
See Also:
Constant Field Values
Constructor Detail

DummyPropertyListener

public DummyPropertyListener()
Method Detail

heardIt

public boolean heardIt(String name)
Replies true if a property change event of the name property was heard.

Parameters:
name - The name of the property we want to know was fired.
Returns:
True if the appropriate event was heard and false if either no event was heard or if the event heard was of a different property.

getPropertyName

public String getPropertyName()
Returns either an empty string or the name of the last property the change event of which was heard.

NB If reset() has been called, the value returned will be an empty string.


getEvent

public PropertyChangeEvent getEvent()
Returns the last event heard by the listener. If no event has been heard or the listener has been reset then null is returned.

Returns:
The last event heard or null, if no event was heard or reset was called.

reset

public void reset()
Resets the listener so it is ready to hear new events.


propertyChange

public void propertyChange(PropertyChangeEvent evt)
Invoked when a bean being listened to fires a property change event.

Specified by:
propertyChange in interface PropertyChangeListener


Copyright © 2008 Commonwealth of Australia