Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#2 PropertyChangeSupport come up with an empty array.

open
nobody
None
5
2009-03-15
2009-03-15
Anonymous
No

The following unit test fails. What is the best way to get support for PropertyChangeSupport?

package net.sf.dynclass;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.HashMap;

import junit.framework.TestCase;

public class TestEventListeners extends TestCase {

public void testEventListeners\(\) throws Exception \{
    HashMap hm = new HashMap\(\);

// the first two properties should be recognized by the
// bean creator; others will be ignored

hm.put("goodProp1", new Integer(17));
hm.put("URL", new Integer(96));
hm.put("OddPropName", ""); // odd because initial capital is confusing

Object bean = BeanCreator.createBeanFromMap(hm);
assertNotNull(bean);

PropertyChangeSupport support = new PropertyChangeSupport(bean);
PropertyChangeListener[] listeners = support.getPropertyChangeListeners();

assertNotNull( listeners );

assertTrue( listeners.length != 0);

return;
}

}

Discussion