use of java.beans.EventSetDescriptor in project groovy by apache.
the class StrangeBeanBeanInfo method getEventSetDescriptors.
public EventSetDescriptor[] getEventSetDescriptors() {
try {
Method[] events = StrangeEventListener.class.getMethods();
Method addListener = StrangeBean.class.getMethod("addStrangeEventListener", new Class[] { StrangeEventListener.class });
Method removeListener = StrangeBean.class.getMethod("removeStrangeEventListener", new Class[] { StrangeEventListener.class });
Method getListeners = StrangeBean.class.getMethod("getStrangeEventListeners", new Class[0]);
return new EventSetDescriptor[] { new EventSetDescriptor("strangeEvent", StrangeEventListener.class, events, addListener, removeListener, getListeners) };
} catch (Exception e) {
e.printStackTrace(System.out);
return super.getEventSetDescriptors();
}
}
use of java.beans.EventSetDescriptor in project j2objc by google.
the class IntrospectorTest method testUnicastEventSetDescriptor.
/**
* The test checks the getEventSetDescriptors method
*
* @throws IntrospectionException
*/
public void testUnicastEventSetDescriptor() throws IntrospectionException {
BeanInfo info = Introspector.getBeanInfo(SampleBean.class);
assertNotNull(info);
EventSetDescriptor[] descriptors = info.getEventSetDescriptors();
assertNotNull(descriptors);
for (EventSetDescriptor descriptor : descriptors) {
Method m = descriptor.getAddListenerMethod();
if (m != null) {
Class<?>[] exceptionTypes = m.getExceptionTypes();
boolean found = false;
for (Class<?> et : exceptionTypes) {
if (et.equals(TooManyListenersException.class)) {
assertTrue(descriptor.isUnicast());
found = true;
break;
}
}
if (!found) {
assertFalse(descriptor.isUnicast());
}
}
}
}
use of java.beans.EventSetDescriptor in project j2objc by google.
the class IntrospectorTest method testGetBeanInfoClassint_IGNORE_ALL_Event.
/*
* FLAG=IGNORE_ALL_BEANINFO;
*/
public void testGetBeanInfoClassint_IGNORE_ALL_Event() throws IntrospectionException {
BeanInfo info = Introspector.getBeanInfo(MockFooSub.class, Introspector.IGNORE_ALL_BEANINFO);
EventSetDescriptor[] esds = info.getEventSetDescriptors();
assertEquals(1, esds.length);
assertTrue(contains("mockPropertyChange", esds));
}
use of java.beans.EventSetDescriptor in project j2objc by google.
the class EventSetDescriptorTest method test_EventSetDescriptor_Constructor.
public void test_EventSetDescriptor_Constructor() throws Exception {
EventSetDescriptor eventSetDescriptor = new EventSetDescriptor((String) null, (Class<?>) null, new MethodDescriptor[] { null, null }, (Method) null, (Method) null);
assertNull(eventSetDescriptor.getName());
assertNull(eventSetDescriptor.getListenerType());
assertNull(eventSetDescriptor.getAddListenerMethod());
assertNull(eventSetDescriptor.getRemoveListenerMethod());
try {
eventSetDescriptor.getListenerMethods();
fail("should throw NullPointerException");
} catch (NullPointerException e) {
// Expected
}
}
use of java.beans.EventSetDescriptor in project j2objc by google.
the class EventSetDescriptorTest method testEventSetDescriptorClassStringClassStringArrayStringString_addListenerMethodNameNull.
/*
* addListenerMethodName==null
*/
public void testEventSetDescriptorClassStringClassStringArrayStringString_addListenerMethodNameNull() throws IntrospectionException {
Class<MockSourceClass> sourceClass = MockSourceClass.class;
String eventSetName = "MockPropertyChange";
Class<?> listenerType = MockPropertyChangeListener.class;
String[] listenerMethodNames = { "mockPropertyChange", "mockPropertyChange2" };
String addMethod = null;
String removeMethod = "removeMockPropertyChangeListener";
EventSetDescriptor esd = new EventSetDescriptor(sourceClass, eventSetName, listenerType, listenerMethodNames, addMethod, removeMethod);
assertNull(esd.getAddListenerMethod());
}
Aggregations