Search in sources :

Example 6 with MethodDescriptor

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

the class EventSetDescriptorTest method testSetInDefaultEventSet_false.

public void testSetInDefaultEventSet_false() 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);
    assertTrue(esd.isInDefaultEventSet());
    esd.setInDefaultEventSet(false);
    assertFalse(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 7 with MethodDescriptor

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

the class EventSetDescriptorTest method testSetInDefaultEventSet.

public void testSetInDefaultEventSet() 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);
    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 8 with MethodDescriptor

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

the class EventSetDescriptorTest method testSetUnicast_false.

public void testSetUnicast_false() 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);
    assertFalse(esd.isUnicast());
    esd.setInDefaultEventSet(false);
    assertFalse(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 9 with MethodDescriptor

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

the class IntrospectorTest method testGetBeanInfoClassClass_Method.

public void testGetBeanInfoClassClass_Method() throws IntrospectionException {
    BeanInfo info = Introspector.getBeanInfo(MockFoo.class, MockFooStop.class);
    MethodDescriptor[] mds = info.getMethodDescriptors();
    assertEquals(4, mds.length);
    assertTrue(contains("getName", mds));
    assertTrue(contains("setName", mds));
    assertTrue(contains("getComplexLabel", mds));
    assertTrue(contains("setComplexLabel", mds));
    try {
        Introspector.getBeanInfo(MockFoo.class, Serializable.class);
        fail("Shoule throw exception, stopclass must be superclass of given bean");
    } catch (IntrospectionException e) {
    }
}
Also used : BeanInfo(java.beans.BeanInfo) SimpleBeanInfo(java.beans.SimpleBeanInfo) FakeFox01BeanInfo(org.apache.harmony.beans.tests.support.mock.FakeFox01BeanInfo) IntrospectionException(java.beans.IntrospectionException) MethodDescriptor(java.beans.MethodDescriptor)

Example 10 with MethodDescriptor

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

the class IntrospectorTest method testBeanInfo_1.

/*
     * Test Introspection with BeanInfo No immediate BeanInfo Have super
     * BeanInfo
     */
public void testBeanInfo_1() throws IntrospectionException {
    Class<FakeFox011> beanClass = FakeFox011.class;
    BeanInfo info = Introspector.getBeanInfo(beanClass);
    assertNull(info.getAdditionalBeanInfo());
    BeanDescriptor beanDesc = info.getBeanDescriptor();
    assertEquals("FakeFox011", beanDesc.getName());
    assertEquals(0, info.getEventSetDescriptors().length);
    assertEquals(-1, info.getDefaultEventIndex());
    assertEquals(0, info.getDefaultPropertyIndex());
    MethodDescriptor[] methodDesc = info.getMethodDescriptors();
    assertEquals(4, methodDesc.length);
    PropertyDescriptor[] propertyDesc = info.getPropertyDescriptors();
    assertEquals(2, propertyDesc.length);
    for (PropertyDescriptor element : propertyDesc) {
        if (element.getName().equals("class")) {
            assertNull(element.getWriteMethod());
            assertNotNull(element.getReadMethod());
        }
    }
}
Also used : IndexedPropertyDescriptor(java.beans.IndexedPropertyDescriptor) PropertyDescriptor(java.beans.PropertyDescriptor) BeanDescriptor(java.beans.BeanDescriptor) BeanInfo(java.beans.BeanInfo) SimpleBeanInfo(java.beans.SimpleBeanInfo) FakeFox01BeanInfo(org.apache.harmony.beans.tests.support.mock.FakeFox01BeanInfo) FakeFox011(org.apache.harmony.beans.tests.support.mock.FakeFox011) MethodDescriptor(java.beans.MethodDescriptor)

Aggregations

MethodDescriptor (java.beans.MethodDescriptor)26 Method (java.lang.reflect.Method)18 EventSetDescriptor (java.beans.EventSetDescriptor)9 BeanInfo (java.beans.BeanInfo)8 MockPropertyChangeListener (org.apache.harmony.beans.tests.support.mock.MockPropertyChangeListener)7 MockPropertyChangeEvent (org.apache.harmony.beans.tests.support.mock.MockPropertyChangeEvent)6 IndexedPropertyDescriptor (java.beans.IndexedPropertyDescriptor)5 PropertyDescriptor (java.beans.PropertyDescriptor)5 SimpleBeanInfo (java.beans.SimpleBeanInfo)5 FakeFox01BeanInfo (org.apache.harmony.beans.tests.support.mock.FakeFox01BeanInfo)5 ParameterDescriptor (java.beans.ParameterDescriptor)4 BeanDescriptor (java.beans.BeanDescriptor)3 MockJavaBean (org.apache.harmony.beans.tests.support.mock.MockJavaBean)3 IntrospectionException (java.beans.IntrospectionException)2 ArrayList (java.util.ArrayList)2 KeyEvent (java.awt.event.KeyEvent)1 KeyListener (java.awt.event.KeyListener)1 FeatureDescriptor (java.beans.FeatureDescriptor)1 IndexedPropertyChangeEvent (java.beans.IndexedPropertyChangeEvent)1 PropertyChangeEvent (java.beans.PropertyChangeEvent)1