Search in sources :

Example 6 with BeanDescriptor

use of java.beans.BeanDescriptor 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)

Example 7 with BeanDescriptor

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

the class IntrospectorTest method testBeanInfo_2.

public void testBeanInfo_2() throws IntrospectionException {
    Class<FakeFox02> beanClass = FakeFox02.class;
    BeanInfo info = Introspector.getBeanInfo(beanClass);
    assertNull(info.getAdditionalBeanInfo());
    BeanDescriptor beanDesc = info.getBeanDescriptor();
    assertEquals("FakeFox02", beanDesc.getName());
    assertEquals(0, info.getEventSetDescriptors().length);
    assertEquals(-1, info.getDefaultEventIndex());
    assertEquals(-1, info.getDefaultPropertyIndex());
    PropertyDescriptor[] propertyDesc = info.getPropertyDescriptors();
    for (PropertyDescriptor element : propertyDesc) {
        if (element.getName().equals("fox02")) {
            assertEquals("fox02.beaninfo", element.getDisplayName());
        }
    }
}
Also used : IndexedPropertyDescriptor(java.beans.IndexedPropertyDescriptor) PropertyDescriptor(java.beans.PropertyDescriptor) BeanDescriptor(java.beans.BeanDescriptor) FakeFox02(org.apache.harmony.beans.tests.support.mock.FakeFox02) BeanInfo(java.beans.BeanInfo) SimpleBeanInfo(java.beans.SimpleBeanInfo) FakeFox01BeanInfo(org.apache.harmony.beans.tests.support.mock.FakeFox01BeanInfo)

Example 8 with BeanDescriptor

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

the class IntrospectorTest method testSetBeanInfoSearchPath_SameClassesInDifferentPackage.

/*
     * @test setBeanInfoSearchPath
     *
     * Change the sequence of the paths in Introspector.searchpaths, check
     * whether the BeanInfo is consistent with the bean class
     */
public void testSetBeanInfoSearchPath_SameClassesInDifferentPackage() throws IntrospectionException {
    // set the search path in the correct sequence
    Introspector.setBeanInfoSearchPath(new String[] { "org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject1.info", "org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject2.info" });
    BeanInfo beanInfo = Introspector.getBeanInfo(org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject1.MockHomonymySubject.class);
    BeanDescriptor beanDesc = beanInfo.getBeanDescriptor();
    assertEquals(beanDesc.getName(), "mocksubject1");
    assertEquals(beanDesc.getBeanClass(), org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject1.MockHomonymySubject.class);
    // set the search path in the reverse sequence
    Introspector.setBeanInfoSearchPath(new String[] { "org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject2.info", "org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject1.info" });
    beanInfo = Introspector.getBeanInfo(org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject1.MockHomonymySubject.class);
    beanDesc = beanInfo.getBeanDescriptor();
    assertEquals(beanDesc.getName(), "mocksubject1");
    assertEquals(beanDesc.getBeanClass(), org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject1.MockHomonymySubject.class);
}
Also used : BeanDescriptor(java.beans.BeanDescriptor) BeanInfo(java.beans.BeanInfo) SimpleBeanInfo(java.beans.SimpleBeanInfo) FakeFox01BeanInfo(org.apache.harmony.beans.tests.support.mock.FakeFox01BeanInfo)

Example 9 with BeanDescriptor

use of java.beans.BeanDescriptor in project jdk8u_jdk by JetBrains.

the class Foo method getBeanDescriptor.

public BeanDescriptor getBeanDescriptor() {
    BeanDescriptor bd = new BeanDescriptor(Foo.class);
    // set a value to ensure that it's unique
    bd.setValue("test", Boolean.TRUE);
    return bd;
}
Also used : BeanDescriptor(java.beans.BeanDescriptor)

Example 10 with BeanDescriptor

use of java.beans.BeanDescriptor in project jdk8u_jdk by JetBrains.

the class WombatBeanInfo method getBeanDescriptor.

public BeanDescriptor getBeanDescriptor() {
    BeanDescriptor bd = new BeanDescriptor(Wombat.class);
    // set a value to ensure that it's unique
    bd.setValue("test", Boolean.TRUE);
    return bd;
}
Also used : BeanDescriptor(java.beans.BeanDescriptor)

Aggregations

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