use of java.beans.MethodDescriptor in project j2objc by google.
the class EventSetDescriptorTest method testEventSetDescriptorStringClassMethodDescriptorArrayMethodMethod_ListenerMDInvalid.
/*
* listenerMethodDescriptors is invalid
*/
public void testEventSetDescriptorStringClassMethodDescriptorArrayMethodMethod_ListenerMDInvalid() throws SecurityException, NoSuchMethodException, IntrospectionException {
String eventSetName = "MockPropertyChange";
Class<?> listenerType = MockPropertyChangeListener.class;
Method[] listenerMethods = { listenerType.getMethod("mockPropertyChange", MockPropertyChangeEvent.class), listenerType.getMethod("mockPropertyChange_Invalid") };
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);
// RI doesn't check parameters of listener methods
EventSetDescriptor esd = new EventSetDescriptor(eventSetName, listenerType, listenerMethodDescriptors, addMethod, removeMethod);
assertEquals(0, esd.getListenerMethods()[1].getParameterTypes().length);
assertEquals(listenerMethodDescriptors[1], esd.getListenerMethodDescriptors()[1]);
}
use of java.beans.MethodDescriptor in project j2objc by google.
the class IntrospectorTest method testGetBeanInfo_StaticMethods.
/*
* Introspect static methods
*/
public void testGetBeanInfo_StaticMethods() throws Exception {
BeanInfo beanInfo = Introspector.getBeanInfo(StaticClazz.class);
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
assertEquals(1, propertyDescriptors.length);
assertTrue(contains("class", Class.class, propertyDescriptors));
MethodDescriptor[] methodDescriptors = beanInfo.getMethodDescriptors();
assertTrue(contains("getStaticMethod", methodDescriptors));
assertTrue(contains("setStaticMethod", methodDescriptors));
beanInfo = Introspector.getBeanInfo(StaticClazzWithProperty.class);
propertyDescriptors = beanInfo.getPropertyDescriptors();
assertEquals(1, propertyDescriptors.length);
methodDescriptors = beanInfo.getMethodDescriptors();
assertTrue(contains("getStaticName", methodDescriptors));
assertTrue(contains("setStaticName", methodDescriptors));
}
use of java.beans.MethodDescriptor in project j2objc by google.
the class EventSetDescriptorTest method testEventSetDescriptorStringClassMethodDescriptorArrayMethodMethod.
/*
* Class under test for void EventSetDescriptor(String, Class,
* MethodDescriptor[], Method, Method)
*/
public void testEventSetDescriptorStringClassMethodDescriptorArrayMethodMethod() 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);
assertEquals(addMethod, esd.getAddListenerMethod());
assertEquals(removeMethod, esd.getRemoveListenerMethod());
assertNull(esd.getGetListenerMethod());
assertEquals(listenerMethods[0], esd.getListenerMethods()[0]);
assertEquals(listenerMethods[1], esd.getListenerMethods()[1]);
assertEquals(2, esd.getListenerMethodDescriptors().length);
assertEquals(listenerMethods[0], esd.getListenerMethodDescriptors()[0].getMethod());
assertEquals(listenerMethods[1], esd.getListenerMethodDescriptors()[1].getMethod());
assertEquals(listenerType, esd.getListenerType());
assertTrue(esd.isInDefaultEventSet());
assertFalse(esd.isUnicast());
}
use of java.beans.MethodDescriptor in project j2objc by google.
the class MethodDescriptorTest method testMethodDescriptorMethod.
/*
* Class under test for void MethodDescriptor(Method)
*/
public void testMethodDescriptorMethod() throws SecurityException, NoSuchMethodException {
String beanName = "MethodDescriptorTest.bean";
MockJavaBean bean = new MockJavaBean(beanName);
Method method = bean.getClass().getMethod("getBeanName", (Class[]) null);
MethodDescriptor md = new MethodDescriptor(method);
assertSame(method, md.getMethod());
assertNull(md.getParameterDescriptors());
assertEquals(method.getName(), md.getDisplayName());
assertEquals(method.getName(), md.getName());
assertEquals(method.getName(), md.getShortDescription());
assertNotNull(md.attributeNames());
assertFalse(md.isExpert());
assertFalse(md.isHidden());
assertFalse(md.isPreferred());
}
use of java.beans.MethodDescriptor in project j2objc by google.
the class MethodDescriptorTest method testMethodDescriptorMethodParameterDescriptorArray.
/*
* Class under test for void MethodDescriptor(Method, ParameterDescriptor[])
*/
public void testMethodDescriptorMethodParameterDescriptorArray() throws SecurityException, NoSuchMethodException {
String beanName = "MethodDescriptorTest.bean";
MockJavaBean bean = new MockJavaBean(beanName);
Method method = bean.getClass().getMethod("setPropertyOne", new Class[] { String.class });
ParameterDescriptor[] pds = new ParameterDescriptor[1];
pds[0] = new ParameterDescriptor();
pds[0].setValue(method.getName(), method.getReturnType());
MethodDescriptor md = new MethodDescriptor(method, pds);
assertSame(method, md.getMethod());
assertSame(pds, md.getParameterDescriptors());
assertEquals(pds[0].getValue(method.getName()), md.getParameterDescriptors()[0].getValue(method.getName()));
assertEquals(method.getName(), md.getDisplayName());
assertEquals(method.getName(), md.getName());
assertEquals(method.getName(), md.getShortDescription());
assertNotNull(md.attributeNames());
assertFalse(md.isExpert());
assertFalse(md.isHidden());
assertFalse(md.isPreferred());
}
Aggregations