use of java.beans.EventSetDescriptor 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.EventSetDescriptor in project j2objc by google.
the class EventSetDescriptorTest method testEventSetDescriptorClassStringClassStringArrayStringString_listenerMethodNamesEmpty.
public void testEventSetDescriptorClassStringClassStringArrayStringString_listenerMethodNamesEmpty() throws IntrospectionException {
Class<MockSourceClass> sourceClass = MockSourceClass.class;
String eventSetName = "MockPropertyChange";
Class<?> listenerType = MockPropertyChangeListener.class;
String[] listenerMethodNames = {};
String addMethod = "addMockPropertyChangeListener";
String removeMethod = "removeMockPropertyChangeListener";
EventSetDescriptor esd = new EventSetDescriptor(sourceClass, eventSetName, listenerType, listenerMethodNames, addMethod, removeMethod);
assertEquals(0, esd.getListenerMethods().length);
}
use of java.beans.EventSetDescriptor 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.EventSetDescriptor in project j2objc by google.
the class EventSetDescriptorTest method testEventSetDescriptorClassStringClassStringArrayStringString_listenerMethodNamesValid.
public void testEventSetDescriptorClassStringClassStringArrayStringString_listenerMethodNamesValid() throws Exception {
Class<MockSourceClass> sourceClass = MockSourceClass.class;
String eventSetName = "MockPropertyChange";
Class<?> listenerType = MockPropertyChangeValidListener.class;
String[] listenerMethodNames = { "mockPropertyChange_Valid", "mockPropertyChange2" };
String addMethod = "addMockPropertyChangeListener";
String removeMethod = "removeMockPropertyChangeListener";
EventSetDescriptor eventSetDescriptor = new EventSetDescriptor(sourceClass, eventSetName, listenerType, listenerMethodNames, addMethod, removeMethod);
assertEquals(2, eventSetDescriptor.getListenerMethods().length);
}
use of java.beans.EventSetDescriptor in project j2objc by google.
the class EventSetDescriptorTest method testEventSetDescriptorClassStringClassString.
/*
* Class under test for void EventSetDescriptor(Class, String, Class,
* String)
*/
public void testEventSetDescriptorClassStringClassString() throws IntrospectionException, ClassNotFoundException, IOException, SecurityException, NoSuchMethodException {
String eventSetName = "mockPropertyChange";
String listenerMethodName = eventSetName;
Class<MockSourceClass> sourceClass = MockSourceClass.class;
Class<?> listenerType = MockPropertyChangeListener.class;
EventSetDescriptor esd = null;
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());
esd = new EventSetDescriptor(AnObject.class, "something", AnObjectListener.class, "aMethod");
}
Aggregations