Search in sources :

Example 26 with EventSetDescriptor

use of java.beans.EventSetDescriptor in project j2objc by google.

the class EventSetDescriptorTest method testSetUnicast.

public void testSetUnicast() 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);
    assertFalse(esd.isUnicast());
    esd.setInDefaultEventSet(true);
    assertTrue(esd.isInDefaultEventSet());
}
Also used : MockPropertyChangeListener(org.apache.harmony.beans.tests.support.mock.MockPropertyChangeListener) MockPropertyChangeEvent(org.apache.harmony.beans.tests.support.mock.MockPropertyChangeEvent) Method(java.lang.reflect.Method) MethodDescriptor(java.beans.MethodDescriptor) EventSetDescriptor(java.beans.EventSetDescriptor)

Example 27 with EventSetDescriptor

use of java.beans.EventSetDescriptor in project j2objc by google.

the class EventSetDescriptorTest method testEventSetDescriptorStringClassMethodArrayMethodMethodMethod_getListenerMethodInvalid.

/*
     * getListenerMethod is invalid
     */
public void testEventSetDescriptorStringClassMethodArrayMethodMethodMethod_getListenerMethodInvalid() 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 });
    Method getMethod = sourceClass.getMethod("addMockPropertyChangeListener_Invalid", (Class[]) null);
    EventSetDescriptor esd = new EventSetDescriptor(eventSetName, listenerType, listenerMethods, addMethod, removeMethod, getMethod);
    assertEquals(getMethod, esd.getGetListenerMethod());
}
Also used : MockPropertyChangeListener(org.apache.harmony.beans.tests.support.mock.MockPropertyChangeListener) Method(java.lang.reflect.Method) EventSetDescriptor(java.beans.EventSetDescriptor)

Example 28 with EventSetDescriptor

use of java.beans.EventSetDescriptor in project j2objc by google.

the class EventSetDescriptorTest method testEventSetDescriptorStringClassMethodArrayMethodMethod_addListenerMethodNull.

/*
     * addListenerMethod = null
     */
public void testEventSetDescriptorStringClassMethodArrayMethodMethod_addListenerMethodNull() 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 removeMethod = sourceClass.getMethod("removeMockPropertyChangeListener", new Class[] { listenerType });
    EventSetDescriptor esd = new EventSetDescriptor(eventSetName, listenerType, listenerMethods, null, removeMethod);
    assertNull(esd.getAddListenerMethod());
}
Also used : MockPropertyChangeListener(org.apache.harmony.beans.tests.support.mock.MockPropertyChangeListener) Method(java.lang.reflect.Method) EventSetDescriptor(java.beans.EventSetDescriptor)

Example 29 with EventSetDescriptor

use of java.beans.EventSetDescriptor in project j2objc by google.

the class EventSetDescriptorTest method testConstructor_withAnotherListener.

public void testConstructor_withAnotherListener() throws Exception {
    Method[] listenermethods = AnotherObjectListener.class.getDeclaredMethods();
    Method add = AnObject.class.getDeclaredMethod("addEventSetDescriptorTest$AnObjectListener", AnObjectListener.class);
    Method remove = AnObject.class.getDeclaredMethod("removeEventSetDescriptorTest$AnObjectListener", AnObjectListener.class);
    EventSetDescriptor esd = new EventSetDescriptor("something", AnObjectListener.class, listenermethods, add, remove);
    assertNotNull(esd);
}
Also used : Method(java.lang.reflect.Method) EventSetDescriptor(java.beans.EventSetDescriptor)

Example 30 with EventSetDescriptor

use of java.beans.EventSetDescriptor in project j2objc by google.

the class EventSetDescriptorTest method testEventSetDescriptorStringClassMethodArrayMethodMethod_listenerMethodsNull.

/*
     * listenerMethods=null
     */
public void testEventSetDescriptorStringClassMethodArrayMethodMethod_listenerMethodsNull() 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, (Method[]) null, addMethod, removeMethod);
    assertEquals(addMethod, esd.getAddListenerMethod());
    assertEquals(removeMethod, esd.getRemoveListenerMethod());
    assertNull(esd.getGetListenerMethod());
    assertNull(esd.getListenerMethods());
    assertNull(esd.getListenerMethodDescriptors());
    assertEquals(listenerType, esd.getListenerType());
    assertTrue(esd.isInDefaultEventSet());
    assertFalse(esd.isUnicast());
}
Also used : MockPropertyChangeListener(org.apache.harmony.beans.tests.support.mock.MockPropertyChangeListener) Method(java.lang.reflect.Method) EventSetDescriptor(java.beans.EventSetDescriptor)

Aggregations

EventSetDescriptor (java.beans.EventSetDescriptor)55 Method (java.lang.reflect.Method)34 MockPropertyChangeListener (org.apache.harmony.beans.tests.support.mock.MockPropertyChangeListener)31 BeanInfo (java.beans.BeanInfo)10 MethodDescriptor (java.beans.MethodDescriptor)10 IntrospectionException (java.beans.IntrospectionException)9 PropertyDescriptor (java.beans.PropertyDescriptor)6 MockPropertyChangeEvent (org.apache.harmony.beans.tests.support.mock.MockPropertyChangeEvent)6 SimpleBeanInfo (java.beans.SimpleBeanInfo)5 FakeFox01BeanInfo (org.apache.harmony.beans.tests.support.mock.FakeFox01BeanInfo)5 IndexedPropertyDescriptor (java.beans.IndexedPropertyDescriptor)3 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)2 BeanDescriptor (java.beans.BeanDescriptor)2 PrivilegedActionException (java.security.PrivilegedActionException)2 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)2 CachedMethod (org.codehaus.groovy.reflection.CachedMethod)2 GeneratedMetaMethod (org.codehaus.groovy.reflection.GeneratedMetaMethod)2 ClosureMetaMethod (org.codehaus.groovy.runtime.metaclass.ClosureMetaMethod)2 MixinInstanceMetaMethod (org.codehaus.groovy.runtime.metaclass.MixinInstanceMetaMethod)2 NewInstanceMetaMethod (org.codehaus.groovy.runtime.metaclass.NewInstanceMetaMethod)2