use of java.beans.MethodDescriptor in project j2objc by google.
the class EventSetDescriptorTest method testSetInDefaultEventSet_false.
public void testSetInDefaultEventSet_false() throws SecurityException, NoSuchMethodException, IntrospectionException {
String eventSetName = "MockPropertyChange";
Class<?> listenerType = MockPropertyChangeListener.class;
Method[] listenerMethods = { listenerType.getMethod("mockPropertyChange", new Class[] { MockPropertyChangeEvent.class }), listenerType.getMethod("mockPropertyChange2", new Class[] { MockPropertyChangeEvent.class }) };
MethodDescriptor[] listenerMethodDescriptors = { new MethodDescriptor(listenerMethods[0]), new MethodDescriptor(listenerMethods[1]) };
Class<MockSourceClass> sourceClass = MockSourceClass.class;
Method addMethod = sourceClass.getMethod("addMockPropertyChangeListener", new Class[] { listenerType });
Method removeMethod = sourceClass.getMethod("removeMockPropertyChangeListener", new Class[] { listenerType });
EventSetDescriptor esd = new EventSetDescriptor(eventSetName, listenerType, listenerMethodDescriptors, addMethod, removeMethod);
assertTrue(esd.isInDefaultEventSet());
esd.setInDefaultEventSet(false);
assertFalse(esd.isInDefaultEventSet());
}
use of java.beans.MethodDescriptor in project j2objc by google.
the class EventSetDescriptorTest method testSetInDefaultEventSet.
public void testSetInDefaultEventSet() 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);
esd.setInDefaultEventSet(true);
assertTrue(esd.isInDefaultEventSet());
}
use of java.beans.MethodDescriptor 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.MethodDescriptor in project j2objc by google.
the class IntrospectorTest method testGetBeanInfoClassClass_Method.
public void testGetBeanInfoClassClass_Method() throws IntrospectionException {
BeanInfo info = Introspector.getBeanInfo(MockFoo.class, MockFooStop.class);
MethodDescriptor[] mds = info.getMethodDescriptors();
assertEquals(4, mds.length);
assertTrue(contains("getName", mds));
assertTrue(contains("setName", mds));
assertTrue(contains("getComplexLabel", mds));
assertTrue(contains("setComplexLabel", mds));
try {
Introspector.getBeanInfo(MockFoo.class, Serializable.class);
fail("Shoule throw exception, stopclass must be superclass of given bean");
} catch (IntrospectionException e) {
}
}
use of java.beans.MethodDescriptor in project j2objc by google.
the class IntrospectorTest method testBeanInfo_1.
/*
* Test Introspection with BeanInfo No immediate BeanInfo Have super
* BeanInfo
*/
public void testBeanInfo_1() throws IntrospectionException {
Class<FakeFox011> beanClass = FakeFox011.class;
BeanInfo info = Introspector.getBeanInfo(beanClass);
assertNull(info.getAdditionalBeanInfo());
BeanDescriptor beanDesc = info.getBeanDescriptor();
assertEquals("FakeFox011", beanDesc.getName());
assertEquals(0, info.getEventSetDescriptors().length);
assertEquals(-1, info.getDefaultEventIndex());
assertEquals(0, info.getDefaultPropertyIndex());
MethodDescriptor[] methodDesc = info.getMethodDescriptors();
assertEquals(4, methodDesc.length);
PropertyDescriptor[] propertyDesc = info.getPropertyDescriptors();
assertEquals(2, propertyDesc.length);
for (PropertyDescriptor element : propertyDesc) {
if (element.getName().equals("class")) {
assertNull(element.getWriteMethod());
assertNotNull(element.getReadMethod());
}
}
}
Aggregations