Search in sources :

Example 96 with IndexedPropertyDescriptor

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

the class IndexedPropertyDescriptorTest method testSetIndexedReadMethod_RInvalidReturn.

/*
     * indexed read method with void return.
     */
public void testSetIndexedReadMethod_RInvalidReturn() 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());
    Method voidMethod = beanClass.getMethod("getPropertyFourInvalid", new Class[] { Integer.TYPE });
    try {
        ipd.setIndexedReadMethod(voidMethod);
        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 97 with IndexedPropertyDescriptor

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

the class IndexedPropertyDescriptorTest method testIndexedPropertyDescriptorStringClassStringStringStringString_RWNull.

/**
     * indexed read/write null
     *
     */
public void testIndexedPropertyDescriptorStringClassStringStringStringString_RWNull() throws IntrospectionException {
    String propertyName = "PropertyFour";
    Class<MockJavaBean> beanClass = MockJavaBean.class;
    IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(propertyName, beanClass, null, null, "get" + propertyName, "set" + propertyName);
    assertNull(ipd.getReadMethod());
    assertNull(ipd.getWriteMethod());
    assertEquals(String.class, ipd.getIndexedPropertyType());
    assertNull(ipd.getPropertyType());
}
Also used : MockJavaBean(org.apache.harmony.beans.tests.support.mock.MockJavaBean) IndexedPropertyDescriptor(java.beans.IndexedPropertyDescriptor)

Example 98 with IndexedPropertyDescriptor

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

the class IndexedPropertyDescriptorTest method testEquals_ReadMethod.

/*
     * Read method
     */
public void testEquals_ReadMethod() throws SecurityException, NoSuchMethodException, IntrospectionException {
    String propertyName = "PropertyFour";
    Class<MockJavaBean> beanClass = MockJavaBean.class;
    Method readMethod = beanClass.getMethod("getPropertyFive", (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);
    IndexedPropertyDescriptor ipd2 = new IndexedPropertyDescriptor(propertyName, beanClass);
    assertFalse(ipd.equals(ipd2));
}
Also used : MockJavaBean(org.apache.harmony.beans.tests.support.mock.MockJavaBean) IndexedPropertyDescriptor(java.beans.IndexedPropertyDescriptor) Method(java.lang.reflect.Method)

Example 99 with IndexedPropertyDescriptor

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

the class IndexedPropertyDescriptorTest method testIndexedPropertyDescriptorStringClassStringStringStringString_IndexedRWIncompatible.

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

Example 100 with IndexedPropertyDescriptor

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

the class IntrospectorTest method test_MixedSimpleClass47.

public void test_MixedSimpleClass47() throws Exception {
    BeanInfo beanInfo = Introspector.getBeanInfo(MixedSimpleClass47.class);
    Method getter = MixedSimpleClass47.class.getMethod("isList", new Class<?>[] {});
    assertEquals(2, beanInfo.getPropertyDescriptors().length);
    for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
        if (propertyName.equals(pd.getName())) {
            assertEquals(getter, pd.getReadMethod());
            assertNull(pd.getWriteMethod());
            assertFalse(pd instanceof IndexedPropertyDescriptor);
        }
    }
}
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)

Aggregations

IndexedPropertyDescriptor (java.beans.IndexedPropertyDescriptor)197 Method (java.lang.reflect.Method)167 PropertyDescriptor (java.beans.PropertyDescriptor)142 BeanInfo (java.beans.BeanInfo)126 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)17 EventSetDescriptor (java.beans.EventSetDescriptor)3 MethodDescriptor (java.beans.MethodDescriptor)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 KeyEvent (java.awt.event.KeyEvent)1 KeyListener (java.awt.event.KeyListener)1 BeanDescriptor (java.beans.BeanDescriptor)1 FeatureDescriptor (java.beans.FeatureDescriptor)1 IndexedPropertyChangeEvent (java.beans.IndexedPropertyChangeEvent)1