Search in sources :

Example 1 with FakeFox

use of org.apache.harmony.beans.tests.support.mock.FakeFox in project j2objc by google.

the class IntrospectorTest method testGetBeanInfoClass_no_BeanInfo.

/*
     * Class under test for BeanInfo getBeanInfo(Class) No XXXXBeanInfo + test
     * cache info
     */
public void testGetBeanInfoClass_no_BeanInfo() throws IntrospectionException {
    Class<FakeFox> beanClass = FakeFox.class;
    BeanInfo info = Introspector.getBeanInfo(beanClass);
    assertNull(info.getAdditionalBeanInfo());
    BeanDescriptor beanDesc = info.getBeanDescriptor();
    assertEquals("FakeFox", beanDesc.getName());
    assertEquals(0, info.getEventSetDescriptors().length);
    assertEquals(-1, info.getDefaultEventIndex());
    assertEquals(-1, info.getDefaultPropertyIndex());
    MethodDescriptor[] methodDesc = info.getMethodDescriptors();
    Method[] methods = beanClass.getMethods();
    assertEquals(methods.length, methodDesc.length);
    ArrayList<Method> methodList = new ArrayList<Method>();
    for (Method element : methods) {
        methodList.add(element);
    }
    for (MethodDescriptor element : methodDesc) {
        assertTrue(methodList.contains(element.getMethod()));
    }
    PropertyDescriptor[] propertyDesc = info.getPropertyDescriptors();
    assertEquals(1, propertyDesc.length);
    for (PropertyDescriptor element : propertyDesc) {
        if (element.getName().equals("class")) {
            assertNull(element.getWriteMethod());
            assertNotNull(element.getReadMethod());
        }
    }
    BeanInfo cacheInfo = Introspector.getBeanInfo(FakeFox.class);
    assertSame(info, cacheInfo);
}
Also used : IndexedPropertyDescriptor(java.beans.IndexedPropertyDescriptor) PropertyDescriptor(java.beans.PropertyDescriptor) BeanDescriptor(java.beans.BeanDescriptor) FakeFox(org.apache.harmony.beans.tests.support.mock.FakeFox) BeanInfo(java.beans.BeanInfo) SimpleBeanInfo(java.beans.SimpleBeanInfo) FakeFox01BeanInfo(org.apache.harmony.beans.tests.support.mock.FakeFox01BeanInfo) ArrayList(java.util.ArrayList) Method(java.lang.reflect.Method) MethodDescriptor(java.beans.MethodDescriptor)

Aggregations

BeanDescriptor (java.beans.BeanDescriptor)1 BeanInfo (java.beans.BeanInfo)1 IndexedPropertyDescriptor (java.beans.IndexedPropertyDescriptor)1 MethodDescriptor (java.beans.MethodDescriptor)1 PropertyDescriptor (java.beans.PropertyDescriptor)1 SimpleBeanInfo (java.beans.SimpleBeanInfo)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 FakeFox (org.apache.harmony.beans.tests.support.mock.FakeFox)1 FakeFox01BeanInfo (org.apache.harmony.beans.tests.support.mock.FakeFox01BeanInfo)1