Search in sources :

Example 46 with EventSetDescriptor

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

the class EventSetDescriptorTest method testEventSetDescriptorStringClassMethodArrayMethodMethod_removeListenerMethodInvalid.

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

Example 47 with EventSetDescriptor

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

the class EventSetDescriptorTest method testEventSetDescriptorStringClassMethodArrayMethodMethodMethod.

/*
     * Class under test for void EventSetDescriptor(String, Class, Method[],
     * Method, Method, Method)
     */
public void testEventSetDescriptorStringClassMethodArrayMethodMethodMethod() 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 });
    Method getMethod = sourceClass.getMethod("getMockPropertyChangeListener", new Class[] { listenerType });
    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 48 with EventSetDescriptor

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

the class EventSetDescriptorTest method testEventSetDescriptorClassStringClassString_EventInvalid.

/*
     * Event is not a subclass of java.util.EventObject.
     */
public void testEventSetDescriptorClassStringClassString_EventInvalid() throws IntrospectionException {
    String eventSetName = "MockFake";
    String listenerMethodName = "mockNotAEventObject";
    Class<MockSourceClass> sourceClass = MockSourceClass.class;
    Class<?> listenerType = MockPropertyChangeListener.class;
    EventSetDescriptor esd = new EventSetDescriptor(sourceClass, eventSetName, listenerType, listenerMethodName);
    assertEquals(listenerMethodName, esd.getListenerMethods()[0].getName());
}
Also used : MockPropertyChangeListener(org.apache.harmony.beans.tests.support.mock.MockPropertyChangeListener) EventSetDescriptor(java.beans.EventSetDescriptor)

Example 49 with EventSetDescriptor

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

the class IntrospectorTest method testIllegalEventSetDescriptor.

/**
     * The test checks the getEventSetDescriptors method
     *
     * @throws IntrospectionException
     */
public void testIllegalEventSetDescriptor() throws IntrospectionException {
    BeanInfo info = Introspector.getBeanInfo(MisprintBean.class);
    assertNotNull(info);
    EventSetDescriptor[] descriptors = info.getEventSetDescriptors();
    assertNotNull(descriptors);
    assertEquals(0, descriptors.length);
}
Also used : BeanInfo(java.beans.BeanInfo) SimpleBeanInfo(java.beans.SimpleBeanInfo) FakeFox01BeanInfo(org.apache.harmony.beans.tests.support.mock.FakeFox01BeanInfo) EventSetDescriptor(java.beans.EventSetDescriptor)

Example 50 with EventSetDescriptor

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

the class IntrospectorTest method testEventSetDescriptorWithoutAddListenerMethod.

/**
     * The test checks the getEventSetDescriptors method
     *
     * @throws IntrospectionException
     */
public void testEventSetDescriptorWithoutAddListenerMethod() throws IntrospectionException {
    BeanInfo info = Introspector.getBeanInfo(OtherBean.class);
    EventSetDescriptor[] descriptors;
    assertNotNull(info);
    descriptors = info.getEventSetDescriptors();
    assertNotNull(descriptors);
    assertEquals(1, descriptors.length);
    assertTrue(contains("sample", descriptors));
}
Also used : BeanInfo(java.beans.BeanInfo) SimpleBeanInfo(java.beans.SimpleBeanInfo) FakeFox01BeanInfo(org.apache.harmony.beans.tests.support.mock.FakeFox01BeanInfo) 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