use of java.beans.EventSetDescriptor in project j2objc by google.
the class EventSetDescriptorTest method testEventSetDescriptorClassStringClassStringArrayStringString.
/*
* Class under test for void EventSetDescriptor(Class, String, Class,
* String[], String, String)
*/
public void testEventSetDescriptorClassStringClassStringArrayStringString() throws IntrospectionException {
Class<MockSourceClass> sourceClass = MockSourceClass.class;
String eventSetName = "MockPropertyChange";
Class<?> listenerType = MockPropertyChangeListener.class;
String[] listenerMethodNames = { "mockPropertyChange", "mockPropertyChange2" };
String addMethod = "addMockPropertyChangeListener";
String removeMethod = "removeMockPropertyChangeListener";
EventSetDescriptor esd = new EventSetDescriptor(sourceClass, eventSetName, listenerType, listenerMethodNames, addMethod, removeMethod);
assertEquals(addMethod, esd.getAddListenerMethod().getName());
assertEquals(removeMethod, esd.getRemoveListenerMethod().getName());
assertNull(esd.getGetListenerMethod());
assertEquals(2, esd.getListenerMethods().length);
assertEquals(listenerMethodNames[0], esd.getListenerMethods()[0].getName());
assertEquals(listenerMethodNames[1], esd.getListenerMethods()[1].getName());
assertEquals(MockPropertyChangeEvent.class, esd.getListenerMethods()[1].getParameterTypes()[0]);
assertEquals(2, esd.getListenerMethodDescriptors().length);
assertEquals(listenerMethodNames[0], esd.getListenerMethodDescriptors()[0].getMethod().getName());
assertEquals(listenerMethodNames[1], esd.getListenerMethodDescriptors()[1].getMethod().getName());
assertEquals(listenerType, esd.getListenerType());
assertTrue(esd.isInDefaultEventSet());
assertFalse(esd.isUnicast());
}
use of java.beans.EventSetDescriptor in project j2objc by google.
the class EventSetDescriptorTest method testEventSetDescriptorStringClassMethodArrayMethodMethod_ListenerTypeNull.
/*
* listenerType=null
*/
public void testEventSetDescriptorStringClassMethodArrayMethodMethod_ListenerTypeNull() throws SecurityException, NoSuchMethodException, IntrospectionException {
String eventSetName = "MockPropertyChange";
Class<?> listenerType = MockPropertyChangeListener.class;
Method[] listenerMethods = new Method[] { listenerType.getMethod("mockPropertyChange", MockPropertyChangeEvent.class), listenerType.getMethod("mockPropertyChange2", MockPropertyChangeEvent.class) };
Class<MockSourceClass> sourceClass = MockSourceClass.class;
Method addMethod = sourceClass.getMethod("addMockPropertyChangeListener", listenerType);
Method removeMethod = sourceClass.getMethod("removeMockPropertyChangeListener", listenerType);
EventSetDescriptor esd = new EventSetDescriptor(eventSetName, null, listenerMethods, addMethod, removeMethod);
assertEquals(addMethod, esd.getAddListenerMethod());
assertEquals(removeMethod, esd.getRemoveListenerMethod());
assertNull(esd.getGetListenerMethod());
assertEquals(listenerMethods, esd.getListenerMethods());
assertEquals(2, esd.getListenerMethodDescriptors().length);
assertEquals(listenerMethods[0], esd.getListenerMethodDescriptors()[0].getMethod());
assertEquals(listenerMethods[1], esd.getListenerMethodDescriptors()[1].getMethod());
assertNull(esd.getListenerType());
assertTrue(esd.isInDefaultEventSet());
assertFalse(esd.isUnicast());
}
use of java.beans.EventSetDescriptor in project j2objc by google.
the class EventSetDescriptorTest method testEventSetDescriptorStringClassMethodArrayMethodMethod_listenerMethodsInvalid.
/*
* listenerMethods is invalid
*/
public void testEventSetDescriptorStringClassMethodArrayMethodMethod_listenerMethodsInvalid() throws SecurityException, NoSuchMethodException, IntrospectionException {
String eventSetName = "MockPropertyChange";
Class<?> listenerType = MockPropertyChangeListener.class;
Method[] listenerMethods = new Method[] { listenerType.getMethod("mockPropertyChange", new Class[] { MockPropertyChangeEvent.class }), listenerType.getMethod("mockPropertyChange_Invalid", (Class[]) null) };
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, listenerMethods, addMethod, removeMethod);
assertEquals(listenerMethods, esd.getListenerMethods());
}
use of java.beans.EventSetDescriptor in project j2objc by google.
the class EventSetDescriptorTest method testEventSetDescriptorStringClassMethodArrayMethodMethod_remveListenerMethodNull.
/*
* removeListenerMethod = null
*/
public void testEventSetDescriptorStringClassMethodArrayMethodMethod_remveListenerMethodNull() throws IntrospectionException, NoSuchMethodException {
String eventSetName = "MockPropertyChange";
Class<?> listenerType = MockPropertyChangeListener.class;
Method[] listenerMethods = new Method[] { listenerType.getMethod("mockPropertyChange", new Class[] { MockPropertyChangeEvent.class }), listenerType.getMethod("mockPropertyChange2", new Class[] { MockPropertyChangeEvent.class }) };
EventSetDescriptor esd = new EventSetDescriptor(eventSetName, listenerType, listenerMethods, null, null);
assertNull(esd.getRemoveListenerMethod());
}
use of java.beans.EventSetDescriptor in project j2objc by google.
the class EventSetDescriptorTest method testEventSetDescriptorClassStringClassString_ListenerInvalid.
/*
* ListenerType does not implement any EventListener
*/
public void testEventSetDescriptorClassStringClassString_ListenerInvalid() throws IntrospectionException, SecurityException, NoSuchMethodException {
String eventSetName = "MockPropertyChange";
String listenerMethodName = "mockPropertyChange";
Class<MockSourceClass> sourceClass = MockSourceClass.class;
Class<?> listenerType = MockFakeListener.class;
EventSetDescriptor esd = new EventSetDescriptor(sourceClass, eventSetName, listenerType, listenerMethodName);
String listenerName = getUnQualifiedClassName(listenerType);
Method addMethod = sourceClass.getMethod("add" + listenerName, new Class[] { listenerType });
Method removeMethod = sourceClass.getMethod("remove" + listenerName, new Class[] { listenerType });
assertEquals(addMethod, esd.getAddListenerMethod());
assertEquals(removeMethod, esd.getRemoveListenerMethod());
assertNull(esd.getGetListenerMethod());
assertEquals(1, esd.getListenerMethods().length);
assertEquals(listenerMethodName, esd.getListenerMethods()[0].getName());
assertEquals(1, esd.getListenerMethodDescriptors().length);
assertEquals(listenerMethodName, esd.getListenerMethodDescriptors()[0].getMethod().getName());
assertEquals(listenerType, esd.getListenerType());
assertTrue(esd.isInDefaultEventSet());
assertFalse(esd.isUnicast());
}
Aggregations