use of java.beans.EventSetDescriptor in project j2objc by google.
the class EventSetDescriptorTest method testEventSetDescriptorStringClassMethodArrayMethodMethod_addListenerMethodInvalid.
/*
* addListenerMethod is invalid
*/
public void testEventSetDescriptorStringClassMethodArrayMethodMethod_addListenerMethodInvalid() 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_Invalid", (Class[]) null);
Method removeMethod = sourceClass.getMethod("removeMockPropertyChangeListener", new Class[] { listenerType });
EventSetDescriptor esd = new EventSetDescriptor(eventSetName, listenerType, listenerMethods, addMethod, removeMethod);
assertEquals(addMethod, esd.getAddListenerMethod());
}
use of java.beans.EventSetDescriptor in project j2objc by google.
the class IntrospectorTest method testDefaultEvent.
public void testDefaultEvent() throws IntrospectionException {
Class<?> beanClass = MockClassForDefaultEvent.class;
BeanInfo info = Introspector.getBeanInfo(beanClass);
assertEquals(-1, info.getDefaultEventIndex());
assertEquals(-1, info.getDefaultPropertyIndex());
EventSetDescriptor[] events = info.getEventSetDescriptors();
for (EventSetDescriptor event : events) {
assertFalse(event.isUnicast());
assertTrue(event.isInDefaultEventSet());
assertFalse(event.isExpert());
assertFalse(event.isHidden());
assertFalse(event.isPreferred());
}
}
use of java.beans.EventSetDescriptor in project j2objc by google.
the class EventSetDescriptorTest method testEventSetDescriptorClassStringClassStringArrayStringStringString.
/*
* Class under test for void EventSetDescriptor(Class, String, Class,
* String[], String, String, String)
*/
public void testEventSetDescriptorClassStringClassStringArrayStringStringString() 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 = "getMockPropertyChangeListener";
EventSetDescriptor esd = new EventSetDescriptor(sourceClass, eventSetName, listenerType, listenerMethodNames, addMethod, removeMethod, getMethod);
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-1237
try {
new EventSetDescriptor(Thread.class, "0xABCD", Thread.class, new String[] {}, "aaa", null, "bbb");
fail("IntrospectionException expected");
} catch (IntrospectionException e) {
// expected
}
}
use of java.beans.EventSetDescriptor 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.EventSetDescriptor in project j2objc by google.
the class EventSetDescriptorTest method testEventSetDescriptorStringClassMethodArrayMethodMethod_EventNull.
/*
* eventSetName=null
*/
public void testEventSetDescriptorStringClassMethodArrayMethodMethod_EventNull() throws SecurityException, NoSuchMethodException, IntrospectionException {
String eventSetName = null;
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());
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());
}
Aggregations