public void test(final TestHarness harness)
{
// for 1.4 compatibility it is needed to subclass PropertyEditorSupport because the constructors are
// 'protected' (they are 'public' in 1.5)
pes = new PropertyEditorSupport()
{};
final Object newValue = "new value";
pes.addPropertyChangeListener(new PropertyChangeListener()
{
public void propertyChange(PropertyChangeEvent event)
{
nonNullPropertyChanged = true;
// the PropertyEditorSupport instance should be the event source
// (according to documentation of its zero argument constructor)
harness.check(
event.getSource(),
pes,
"pes1-event-event source");
// the property name for an PropertyEditorSupport object is always null
harness.check(
event.getPropertyName(),
null,
"pes1-event-property name");
// according to documentation of PropertyChangeEvent the old and new value should be
// null if the property name is null.
harness.check(
event.getOldValue(),
null,
"pes1-event-old value");
harness.check(
event.getNewValue(),
null,
"pes1-event-new value");
// at this point the PropertyEditorSupport instance should have been updated to the new value already
harness.check(pes.getValue(), newValue, "pes1-new value");
}
});
// this method should trigger the calling of anonymous PropertyChangeListener above
pes.setValue(newValue);
harness.check(
nonNullPropertyChanged,
"pes1-PropertyChangeListener call");
// creates another PropertyEditorSupport instance for a slightly different test
pes = new PropertyEditorSupport()
{};
pes.addPropertyChangeListener(new PropertyChangeListener()
{