use of java.beans.EventSetDescriptor in project j2objc by google.
the class EventSetDescriptorTest method testEventSetDescriptorStringClassMethodArrayMethodMethod_EventEmpty.
/*
* eventSetName=""
*/
public void testEventSetDescriptorStringClassMethodArrayMethodMethod_EventEmpty() throws SecurityException, NoSuchMethodException, IntrospectionException {
String eventSetName = "";
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, listenerType, listenerMethods, addMethod, removeMethod);
assertEquals(addMethod, esd.getAddListenerMethod());
assertEquals(removeMethod, esd.getRemoveListenerMethod());
assertNull(esd.getGetListenerMethod());
//RI asserts to true here
assertEquals(listenerMethods, esd.getListenerMethods());
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.EventSetDescriptor in project j2objc by google.
the class EventSetDescriptorTest method testEventSetDescriptorStringClassMethodArrayMethodMethodMethod_getListenerMethodNull.
/*
* getListenerMethod is null
*/
public void testEventSetDescriptorStringClassMethodArrayMethodMethodMethod_getListenerMethodNull() 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 }) };
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, null);
assertNull(esd.getGetListenerMethod());
}
use of java.beans.EventSetDescriptor in project j2objc by google.
the class EventSetDescriptorTest method testEventSetDescriptorStringClassMethodArrayMethodMethod.
/*
* Class under test for void EventSetDescriptor(String, Class, Method[],
* Method, Method)
*/
public void testEventSetDescriptorStringClassMethodArrayMethodMethod() throws SecurityException, NoSuchMethodException, IntrospectionException {
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 }) };
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(addMethod, esd.getAddListenerMethod());
assertEquals(removeMethod, esd.getRemoveListenerMethod());
assertNull(esd.getGetListenerMethod());
// RI reports true in the following assertion, so it returns exactly
// the same array as it was specified in the EventSetDescriptor
// constructor.
assertEquals(listenerMethods, esd.getListenerMethods());
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.EventSetDescriptor in project j2objc by google.
the class EventSetDescriptorTest method testEventSetDescriptorClassStringClassString_AmbiguousEvent.
public void testEventSetDescriptorClassStringClassString_AmbiguousEvent() throws IntrospectionException, ClassNotFoundException, IOException, SecurityException, NoSuchMethodException {
String eventSetName = "mockPropertyChange";
String listenerMethodName = eventSetName;
Class<MockSourceClass> sourceClass = MockSourceClass.class;
Class<?> listenerType = org.apache.harmony.beans.tests.support.mock.MockPropertyChangeListener2.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());
}
use of java.beans.EventSetDescriptor in project j2objc by google.
the class EventSetDescriptorTest method testEventSetDescriptorClassStringClassStringArrayStringStringString_getListenerMethodNameNull.
/*
* getListenerMethodName is null
*/
public void testEventSetDescriptorClassStringClassStringArrayStringStringString_getListenerMethodNameNull() 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 = null;
EventSetDescriptor esd = new EventSetDescriptor(sourceClass, eventSetName, listenerType, listenerMethodNames, addMethod, removeMethod, getMethod);
assertNull(esd.getGetListenerMethod());
//Regression for Harmony-1504
try {
new EventSetDescriptor(sourceClass, eventSetName, listenerType, null, addMethod, removeMethod, getMethod);
fail("NullPointerException expected");
} catch (NullPointerException e) {
//expected
}
}
Aggregations