use of java.beans.EventSetDescriptor in project j2objc by google.
the class EventSetDescriptorTest method testSetUnicast_false.
public void testSetUnicast_false() throws SecurityException, NoSuchMethodException, IntrospectionException {
String eventSetName = "MockPropertyChange";
Class<?> listenerType = MockPropertyChangeListener.class;
Method[] listenerMethods = { listenerType.getMethod("mockPropertyChange", MockPropertyChangeEvent.class), listenerType.getMethod("mockPropertyChange2", MockPropertyChangeEvent.class) };
MethodDescriptor[] listenerMethodDescriptors = { new MethodDescriptor(listenerMethods[0]), new MethodDescriptor(listenerMethods[1]) };
Class<MockSourceClass> sourceClass = MockSourceClass.class;
Method addMethod = sourceClass.getMethod("addMockPropertyChangeListener", listenerType);
Method removeMethod = sourceClass.getMethod("removeMockPropertyChangeListener", listenerType);
EventSetDescriptor esd = new EventSetDescriptor(eventSetName, listenerType, listenerMethodDescriptors, addMethod, removeMethod);
assertFalse(esd.isUnicast());
esd.setInDefaultEventSet(false);
assertFalse(esd.isInDefaultEventSet());
}
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 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 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();
}
}
Aggregations