Search in sources :

Example 31 with IndexedPropertyDescriptor

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

the class IntrospectorTest method test_MixedBooleanSimpleClass40.

public void test_MixedBooleanSimpleClass40() throws Exception {
    BeanInfo info = Introspector.getBeanInfo(MixedBooleanSimpleClass40.class);
    Method setter = MixedBooleanSimpleClass40.class.getDeclaredMethod("setList", int.class, boolean.class);
    for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
        if (propertyName.equals(pd.getName())) {
            assertTrue(pd instanceof IndexedPropertyDescriptor);
            assertNull(pd.getReadMethod());
            assertNull(pd.getWriteMethod());
            assertNull(((IndexedPropertyDescriptor) pd).getIndexedReadMethod());
            assertEquals(setter, ((IndexedPropertyDescriptor) pd).getIndexedWriteMethod());
            break;
        }
    }
}
Also used : IndexedPropertyDescriptor(java.beans.IndexedPropertyDescriptor) PropertyDescriptor(java.beans.PropertyDescriptor) BeanInfo(java.beans.BeanInfo) SimpleBeanInfo(java.beans.SimpleBeanInfo) FakeFox01BeanInfo(org.apache.harmony.beans.tests.support.mock.FakeFox01BeanInfo) IndexedPropertyDescriptor(java.beans.IndexedPropertyDescriptor) Method(java.lang.reflect.Method)

Example 32 with IndexedPropertyDescriptor

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

the class IntrospectorTest method test_MixedSimpleClass60.

public void test_MixedSimpleClass60() throws Exception {
    BeanInfo beanInfo = Introspector.getBeanInfo(MixedSimpleClass60.class);
    Method getter = MixedSimpleClass60.class.getMethod("getList", new Class<?>[] { int.class });
    Method setter = MixedSimpleClass60.class.getMethod("setList", new Class<?>[] { int.class, boolean.class });
    assertEquals(2, beanInfo.getPropertyDescriptors().length);
    for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
        if (propertyName.equals(pd.getName())) {
            assertNull(pd.getReadMethod());
            assertNull(pd.getWriteMethod());
            assertTrue(pd instanceof IndexedPropertyDescriptor);
            assertEquals(getter, ((IndexedPropertyDescriptor) pd).getIndexedReadMethod());
            assertEquals(setter, ((IndexedPropertyDescriptor) pd).getIndexedWriteMethod());
        }
    }
}
Also used : IndexedPropertyDescriptor(java.beans.IndexedPropertyDescriptor) PropertyDescriptor(java.beans.PropertyDescriptor) BeanInfo(java.beans.BeanInfo) SimpleBeanInfo(java.beans.SimpleBeanInfo) FakeFox01BeanInfo(org.apache.harmony.beans.tests.support.mock.FakeFox01BeanInfo) IndexedPropertyDescriptor(java.beans.IndexedPropertyDescriptor) Method(java.lang.reflect.Method)

Example 33 with IndexedPropertyDescriptor

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

the class IntrospectorTest method test_MixedBooleanExtendClass5.

public void test_MixedBooleanExtendClass5() throws Exception {
    BeanInfo info = Introspector.getBeanInfo(MixedBooleanExtendClass5.class);
    Method getter = MixedBooleanSimpleClass1.class.getDeclaredMethod("isList");
    for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
        if (propertyName.equals(pd.getName())) {
            assertFalse(pd instanceof IndexedPropertyDescriptor);
            assertEquals(getter, pd.getReadMethod());
            assertNull(pd.getWriteMethod());
            break;
        }
    }
}
Also used : IndexedPropertyDescriptor(java.beans.IndexedPropertyDescriptor) PropertyDescriptor(java.beans.PropertyDescriptor) BeanInfo(java.beans.BeanInfo) SimpleBeanInfo(java.beans.SimpleBeanInfo) FakeFox01BeanInfo(org.apache.harmony.beans.tests.support.mock.FakeFox01BeanInfo) IndexedPropertyDescriptor(java.beans.IndexedPropertyDescriptor) Method(java.lang.reflect.Method)

Example 34 with IndexedPropertyDescriptor

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

the class IndexedPropertyDescriptorTest method testSetIndexedReadMethod_RInvalidArgs.

/*
     * indexed read method without args
     */
public void testSetIndexedReadMethod_RInvalidArgs() throws SecurityException, NoSuchMethodException, IntrospectionException {
    String propertyName = "PropertyFour";
    Class<MockJavaBean> beanClass = MockJavaBean.class;
    Method readMethod = beanClass.getMethod("get" + propertyName, (Class[]) null);
    Method writeMethod = beanClass.getMethod("set" + propertyName, new Class[] { String[].class });
    Method indexedReadMethod = beanClass.getMethod("get" + propertyName, new Class[] { Integer.TYPE });
    Method indexedWriteMethod = beanClass.getMethod("set" + propertyName, new Class[] { Integer.TYPE, String.class });
    IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(propertyName, readMethod, writeMethod, indexedReadMethod, indexedWriteMethod);
    assertSame(indexedReadMethod, ipd.getIndexedReadMethod());
    try {
        ipd.setIndexedReadMethod(readMethod);
        fail("Should throw IntrospectionException.");
    } catch (IntrospectionException e) {
    }
}
Also used : MockJavaBean(org.apache.harmony.beans.tests.support.mock.MockJavaBean) IntrospectionException(java.beans.IntrospectionException) IndexedPropertyDescriptor(java.beans.IndexedPropertyDescriptor) Method(java.lang.reflect.Method)

Example 35 with IndexedPropertyDescriptor

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

the class IndexedPropertyDescriptorTest method testIndexedPropertyDescriptorStringClassStringStringStringString_RWIncompatible.

/*
     * read/write incompatible
     *
     */
public void testIndexedPropertyDescriptorStringClassStringStringStringString_RWIncompatible() throws IntrospectionException {
    String propertyName = "PropertyFour";
    String anotherProp = "PropertyFive";
    Class<MockJavaBean> beanClass = MockJavaBean.class;
    IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(propertyName, beanClass, "get" + propertyName, "set" + anotherProp, "get" + propertyName, "set" + propertyName);
    assertEquals(String.class, ipd.getIndexedPropertyType());
    assertEquals(String[].class, ipd.getPropertyType());
    assertEquals("set" + anotherProp, ipd.getWriteMethod().getName());
}
Also used : MockJavaBean(org.apache.harmony.beans.tests.support.mock.MockJavaBean) IndexedPropertyDescriptor(java.beans.IndexedPropertyDescriptor)

Aggregations

IndexedPropertyDescriptor (java.beans.IndexedPropertyDescriptor)201 Method (java.lang.reflect.Method)171 PropertyDescriptor (java.beans.PropertyDescriptor)144 BeanInfo (java.beans.BeanInfo)127 SimpleBeanInfo (java.beans.SimpleBeanInfo)126 FakeFox01BeanInfo (org.apache.harmony.beans.tests.support.mock.FakeFox01BeanInfo)126 MockJavaBean (org.apache.harmony.beans.tests.support.mock.MockJavaBean)49 IntrospectionException (java.beans.IntrospectionException)21 EventSetDescriptor (java.beans.EventSetDescriptor)3 MethodDescriptor (java.beans.MethodDescriptor)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 PropertyInfo (cern.gp.beans.PropertyInfo)1 CachingStrategy (cern.gp.nodes.cache.CachingStrategy)1 NoCachingStrategy (cern.gp.nodes.cache.NoCachingStrategy)1 StickyCachingStrategy (cern.gp.nodes.cache.StickyCachingStrategy)1 TimeLimitedCachingStrategy (cern.gp.nodes.cache.TimeLimitedCachingStrategy)1 BugException (freemarker.core.BugException)1 KeyEvent (java.awt.event.KeyEvent)1