use of java.beans.EventSetDescriptor in project j2objc by google.
the class EventSetDescriptorTest method main.
public static void main(String[] args) throws Exception {
try {
// No need to do anything clever, there's only one method and it's
// the one we want.
// Swap these two lines to make Harmony pass.
//Method[] listenermethods = AnObjectListener.class.getDeclaredMethods();
Method[] listenermethods = AnotherObjectListener.class.getDeclaredMethods();
Method add = AnObject.class.getDeclaredMethod("addEventSetDescriptorTest3$AnObjectListener", AnObjectListener.class);
Method remove = AnObject.class.getDeclaredMethod("removeEventSetDescriptorTest3$AnObjectListener", AnObjectListener.class);
EventSetDescriptor esd = new EventSetDescriptor("something", AnObjectListener.class, listenermethods, add, remove);
System.out.println("Test passed.");
} catch (Exception e) {
e.printStackTrace();
System.out.println("Test failed.");
}
}
use of java.beans.EventSetDescriptor in project j2objc by google.
the class EventSetDescriptorTest method testEventSetDescriptorClassStringClassStringArrayStringStringString_getListenerMethodNameInvalid.
/*
* getListenerMethodName is invalid (return void)
*/
public void testEventSetDescriptorClassStringClassStringArrayStringStringString_getListenerMethodNameInvalid() throws IntrospectionException {
Class<MockSourceClass> sourceClass = MockSourceClass.class;
String eventSetName = "MockPropertyChange";
Class<?> listenerType = MockPropertyChangeListener.class;
String[] listenerMethodNames = { "mockPropertyChange", "mockPropertyChange2" };
String addMethod = "addMockPropertyChangeListener";
String removeMethod = "removeMockPropertyChangeListener";
String getMethod = addMethod;
EventSetDescriptor esd = new EventSetDescriptor(sourceClass, eventSetName, listenerType, listenerMethodNames, addMethod, removeMethod, getMethod);
assertNull(esd.getGetListenerMethod());
}
use of java.beans.EventSetDescriptor 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.EventSetDescriptor in project j2objc by google.
the class EventSetDescriptorTest method testEventSetDescriptorClassStringClassStringArrayStringString_eventNull.
/*
* Event is null
*/
public void testEventSetDescriptorClassStringClassStringArrayStringString_eventNull() 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(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());
//Regression for HARMONY-1504
try {
new EventSetDescriptor(sourceClass, null, listenerType, listenerMethodNames, addMethod, removeMethod);
fail("NullPointerException expected");
} catch (NullPointerException e) {
//expected
}
}
use of java.beans.EventSetDescriptor 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