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());
}
use of java.beans.MethodDescriptor in project j2objc by google.
the class EventSetDescriptorTest method testSetUnicast.
public void testSetUnicast() 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);
assertFalse(esd.isUnicast());
esd.setInDefaultEventSet(true);
assertTrue(esd.isInDefaultEventSet());
}
use of java.beans.MethodDescriptor in project j2objc by google.
the class EventSetDescriptorTest method testEventSetDescriptorStringClassMethodDescriptorArrayMethodMethod_ListenerMDNull.
/*
* listenerMethodDescriptors is null
*/
public void testEventSetDescriptorStringClassMethodDescriptorArrayMethodMethod_ListenerMDNull() throws IntrospectionException, NoSuchMethodException {
String eventSetName = "MockPropertyChange";
Class<?> listenerType = MockPropertyChangeListener.class;
Class<MockSourceClass> sourceClass = MockSourceClass.class;
Method addMethod = sourceClass.getMethod("addMockPropertyChangeListener", listenerType);
Method removeMethod = sourceClass.getMethod("removeMockPropertyChangeListener", listenerType);
EventSetDescriptor esd = new EventSetDescriptor(eventSetName, listenerType, (MethodDescriptor[]) null, addMethod, removeMethod);
assertNull(esd.getListenerMethodDescriptors());
assertNull(esd.getListenerMethods());
}
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 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]);
}
Aggregations