Search in sources :

Example 11 with IntrospectionException

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

the class PropertyDescriptorTest method testPropertyDescriptorStringMethodMethod_ReadMethodInvalid.

public void testPropertyDescriptorStringMethodMethod_ReadMethodInvalid() throws SecurityException, NoSuchMethodException, IntrospectionException {
    String propertyName = "PropertyOne";
    Class<MockJavaBean> beanClass = MockJavaBean.class;
    String anotherProp = "PropertyTwo";
    Method readMethod = beanClass.getMethod("get" + anotherProp, (Class[]) null);
    Method writeMethod = beanClass.getMethod("set" + propertyName, new Class[] { String.class });
    try {
        new PropertyDescriptor(propertyName, readMethod, writeMethod);
        fail("Should throw IntrospectionException.");
    } catch (IntrospectionException e) {
    }
}
Also used : MockJavaBean(org.apache.harmony.beans.tests.support.mock.MockJavaBean) PropertyDescriptor(java.beans.PropertyDescriptor) IntrospectionException(java.beans.IntrospectionException) Method(java.lang.reflect.Method)

Example 12 with IntrospectionException

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

the class PropertyDescriptorTest method testPropertyDescriptorStringMethodMethod_PropertyNameNull.

public void testPropertyDescriptorStringMethodMethod_PropertyNameNull() throws SecurityException, NoSuchMethodException, IntrospectionException {
    String propertyName = "PropertyOne";
    Class<MockJavaBean> beanClass = MockJavaBean.class;
    Method readMethod = beanClass.getMethod("get" + propertyName, (Class[]) null);
    Method writeMethod = beanClass.getMethod("set" + propertyName, new Class[] { String.class });
    try {
        new PropertyDescriptor(null, readMethod, writeMethod);
        fail("Should throw IntrospectionException.");
    } catch (IntrospectionException e) {
    }
}
Also used : MockJavaBean(org.apache.harmony.beans.tests.support.mock.MockJavaBean) PropertyDescriptor(java.beans.PropertyDescriptor) IntrospectionException(java.beans.IntrospectionException) Method(java.lang.reflect.Method)

Example 13 with IntrospectionException

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

the class PropertyDescriptorTest method testPropertyDescriptorStringMethodMethod_WriteMethodInvalid.

public void testPropertyDescriptorStringMethodMethod_WriteMethodInvalid() throws SecurityException, NoSuchMethodException, IntrospectionException {
    String propertyName = "PropertyOne";
    Class<MockJavaBean> beanClass = MockJavaBean.class;
    String anotherProp = "PropertyTwo";
    Method readMethod = beanClass.getMethod("get" + propertyName, (Class[]) null);
    Method writeMethod = beanClass.getMethod("set" + anotherProp, new Class[] { Integer.class });
    try {
        new PropertyDescriptor(propertyName, readMethod, writeMethod);
        fail("Should throw IntrospectionException.");
    } catch (IntrospectionException e) {
    }
}
Also used : MockJavaBean(org.apache.harmony.beans.tests.support.mock.MockJavaBean) PropertyDescriptor(java.beans.PropertyDescriptor) IntrospectionException(java.beans.IntrospectionException) Method(java.lang.reflect.Method)

Example 14 with IntrospectionException

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

the class FakeFox02BeanInfo method getPropertyDescriptors.

@Override
public PropertyDescriptor[] getPropertyDescriptors() {
    PropertyDescriptor pd = null;
    try {
        pd = new PropertyDescriptor("fox02", FakeFox02.class);
        pd.setDisplayName("fox02.beaninfo");
    } catch (IntrospectionException e) {
    }
    return new PropertyDescriptor[] { pd };
}
Also used : PropertyDescriptor(java.beans.PropertyDescriptor) IntrospectionException(java.beans.IntrospectionException)

Example 15 with IntrospectionException

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

the class PropertyDescriptorTest method testSetReadMethod_ReadWriteIncompatible.

/**
     * Read method is incompatible with write method getPropertyOn vs.
     * setPropertyTow
     */
public void testSetReadMethod_ReadWriteIncompatible() throws SecurityException, NoSuchMethodException, IntrospectionException {
    Class<MockJavaBean> beanClass = MockJavaBean.class;
    String propertyName = "PropertyOne";
    Method readMethod = beanClass.getMethod("get" + "PropertyOne", (Class[]) null);
    Method writeMethod = beanClass.getMethod("set" + "PropertyTwo", new Class[] { Integer.class });
    PropertyDescriptor pd = new PropertyDescriptor(propertyName, null, writeMethod);
    assertNull(pd.getReadMethod());
    try {
        pd.setReadMethod(readMethod);
        fail("Should throw IntrospectionException.");
    } catch (IntrospectionException e) {
    }
}
Also used : MockJavaBean(org.apache.harmony.beans.tests.support.mock.MockJavaBean) PropertyDescriptor(java.beans.PropertyDescriptor) IntrospectionException(java.beans.IntrospectionException) Method(java.lang.reflect.Method)

Aggregations

IntrospectionException (java.beans.IntrospectionException)112 PropertyDescriptor (java.beans.PropertyDescriptor)66 Method (java.lang.reflect.Method)47 BeanInfo (java.beans.BeanInfo)45 MockJavaBean (org.apache.harmony.beans.tests.support.mock.MockJavaBean)24 InvocationTargetException (java.lang.reflect.InvocationTargetException)18 IndexedPropertyDescriptor (java.beans.IndexedPropertyDescriptor)17 ArrayList (java.util.ArrayList)11 HashMap (java.util.HashMap)10 Field (java.lang.reflect.Field)9 EventSetDescriptor (java.beans.EventSetDescriptor)7 List (java.util.List)6 Map (java.util.Map)6 MessageFormat (java.text.MessageFormat)5 UUID (java.util.UUID)5 Assert (org.springframework.util.Assert)5 ImmutableMap (com.google.common.collect.ImmutableMap)4 Optional (java.util.Optional)4 RecursiveChildrenListManager (cern.gp.explorer.test.helpers.RecursiveChildrenListManager)3 SimpleDemoBean (cern.gp.explorer.test.helpers.SimpleDemoBean)3