Search in sources :

Example 16 with IntrospectionException

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

the class IntrospectorTest method testGetBeanInfoClassClass_Method.

public void testGetBeanInfoClassClass_Method() throws IntrospectionException {
    BeanInfo info = Introspector.getBeanInfo(MockFoo.class, MockFooStop.class);
    MethodDescriptor[] mds = info.getMethodDescriptors();
    assertEquals(4, mds.length);
    assertTrue(contains("getName", mds));
    assertTrue(contains("setName", mds));
    assertTrue(contains("getComplexLabel", mds));
    assertTrue(contains("setComplexLabel", mds));
    try {
        Introspector.getBeanInfo(MockFoo.class, Serializable.class);
        fail("Shoule throw exception, stopclass must be superclass of given bean");
    } catch (IntrospectionException e) {
    }
}
Also used : BeanInfo(java.beans.BeanInfo) SimpleBeanInfo(java.beans.SimpleBeanInfo) FakeFox01BeanInfo(org.apache.harmony.beans.tests.support.mock.FakeFox01BeanInfo) IntrospectionException(java.beans.IntrospectionException) MethodDescriptor(java.beans.MethodDescriptor)

Example 17 with IntrospectionException

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

the class IndexedPropertyDescriptorTest method testIndexedPropertyDescriptorStringMethodMethodMethodMethod_IndexedRWNull.

public void testIndexedPropertyDescriptorStringMethodMethodMethodMethod_IndexedRWNull() 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 });
    try {
        new IndexedPropertyDescriptor(propertyName, readMethod, writeMethod, null, null);
        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 18 with IntrospectionException

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

the class IndexedPropertyDescriptorTest method testIndexedPropertyDescriptorStringClassStringStringStringString_WriteMethodNull.

public void testIndexedPropertyDescriptorStringClassStringStringStringString_WriteMethodNull() throws IntrospectionException {
    String propertyName = "PropertyFour";
    Class<MockJavaBean> beanClass = MockJavaBean.class;
    IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(propertyName, beanClass, "get" + propertyName, null, "get" + propertyName, "set" + propertyName);
    assertNotNull(ipd.getReadMethod());
    assertNull(ipd.getWriteMethod());
    assertEquals(String.class, ipd.getIndexedPropertyType());
    new IndexedPropertyDescriptor(propertyName, beanClass, "get" + propertyName, "set" + propertyName, "", "set" + propertyName);
    try {
        new IndexedPropertyDescriptor(propertyName, beanClass, "get" + propertyName, "set" + propertyName, "get" + propertyName, "");
        fail();
    } catch (Exception e) {
    }
}
Also used : MockJavaBean(org.apache.harmony.beans.tests.support.mock.MockJavaBean) IndexedPropertyDescriptor(java.beans.IndexedPropertyDescriptor) IntrospectionException(java.beans.IntrospectionException)

Example 19 with IntrospectionException

use of java.beans.IntrospectionException 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 20 with IntrospectionException

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

the class IndexedPropertyDescriptorTest method testIndexedPropertyDescriptorStringMethodMethodMethodMethod_IndexedRWIncompatible.

/*
     * IndexedRead/IndexedWrite incompatible
     */
public void testIndexedPropertyDescriptorStringMethodMethodMethodMethod_IndexedRWIncompatible() throws SecurityException, NoSuchMethodException, IntrospectionException {
    String propertyName = "PropertyFour";
    String anotherProp = "PropertyFive";
    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" + anotherProp, 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);
    assertEquals(propertyName, ipd.getName());
    assertEquals(String[].class, ipd.getPropertyType());
    assertEquals(String.class, ipd.getIndexedPropertyType());
    indexedReadMethod = beanClass.getMethod("get" + anotherProp, new Class[] { Integer.TYPE, Integer.TYPE });
    try {
        new IndexedPropertyDescriptor(propertyName, readMethod, writeMethod, indexedReadMethod, indexedWriteMethod);
        fail("should throw IntrosecptionException");
    } catch (IntrospectionException e) {
    // expected
    }
}
Also used : MockJavaBean(org.apache.harmony.beans.tests.support.mock.MockJavaBean) IntrospectionException(java.beans.IntrospectionException) IndexedPropertyDescriptor(java.beans.IndexedPropertyDescriptor) Method(java.lang.reflect.Method)

Aggregations

IntrospectionException (java.beans.IntrospectionException)94 PropertyDescriptor (java.beans.PropertyDescriptor)54 BeanInfo (java.beans.BeanInfo)38 Method (java.lang.reflect.Method)38 MockJavaBean (org.apache.harmony.beans.tests.support.mock.MockJavaBean)24 IndexedPropertyDescriptor (java.beans.IndexedPropertyDescriptor)16 InvocationTargetException (java.lang.reflect.InvocationTargetException)8 HashMap (java.util.HashMap)7 EventSetDescriptor (java.beans.EventSetDescriptor)6 ArrayList (java.util.ArrayList)6 Field (java.lang.reflect.Field)5 RecursiveChildrenListManager (cern.gp.explorer.test.helpers.RecursiveChildrenListManager)3 SimpleDemoBean (cern.gp.explorer.test.helpers.SimpleDemoBean)3 GPNode (cern.gp.nodes.GPNode)3 Map (java.util.Map)3 ResourceBundle (java.util.ResourceBundle)3 TreeExplorer (cern.gp.explorer.TreeExplorer)2 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)2 MethodDescriptor (java.beans.MethodDescriptor)2 SimpleBeanInfo (java.beans.SimpleBeanInfo)2