Search in sources :

Example 6 with MockJavaBean

use of org.apache.harmony.beans.tests.support.mock.MockJavaBean in project j2objc by google.

the class IndexedPropertyDescriptorTest method testIndexedPropertyDescriptorStringClassStringStringStringString_IndexedWriteMethodNull.

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

Example 7 with MockJavaBean

use of org.apache.harmony.beans.tests.support.mock.MockJavaBean in project j2objc by google.

the class IndexedPropertyDescriptorTest method testIndexedPropertyDescriptorStringMethodMethodMethodMethod_WriteMethodNull.

public void testIndexedPropertyDescriptorStringMethodMethodMethodMethod_WriteMethodNull() throws SecurityException, NoSuchMethodException, IntrospectionException {
    String propertyName = "PropertyFour";
    Class<MockJavaBean> beanClass = MockJavaBean.class;
    Method readMethod = beanClass.getMethod("get" + propertyName, (Class[]) null);
    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, null, indexedReadMethod, indexedWriteMethod);
    assertNull(ipd.getWriteMethod());
    assertEquals(String[].class, ipd.getPropertyType());
    assertEquals(String.class, ipd.getIndexedPropertyType());
}
Also used : MockJavaBean(org.apache.harmony.beans.tests.support.mock.MockJavaBean) IndexedPropertyDescriptor(java.beans.IndexedPropertyDescriptor) Method(java.lang.reflect.Method)

Example 8 with MockJavaBean

use of org.apache.harmony.beans.tests.support.mock.MockJavaBean in project j2objc by google.

the class IndexedPropertyDescriptorTest method testEquals_WriteMethodNull.

/*
     * write method null.
     */
public void testEquals_WriteMethodNull() throws SecurityException, NoSuchMethodException, IntrospectionException {
    String propertyName = "PropertyFour";
    Class<MockJavaBean> beanClass = MockJavaBean.class;
    Method readMethod = beanClass.getMethod("get" + propertyName, (Class[]) null);
    Method writeMethod = null;
    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 9 with MockJavaBean

use of org.apache.harmony.beans.tests.support.mock.MockJavaBean 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)

Example 10 with MockJavaBean

use of org.apache.harmony.beans.tests.support.mock.MockJavaBean in project j2objc by google.

the class IndexedPropertyDescriptorTest method testSetIndexedReadMethod_null.

public void testSetIndexedReadMethod_null() 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());
    ipd.setIndexedReadMethod(null);
    assertNull(ipd.getIndexedReadMethod());
}
Also used : MockJavaBean(org.apache.harmony.beans.tests.support.mock.MockJavaBean) IndexedPropertyDescriptor(java.beans.IndexedPropertyDescriptor) Method(java.lang.reflect.Method)

Aggregations

MockJavaBean (org.apache.harmony.beans.tests.support.mock.MockJavaBean)89 Method (java.lang.reflect.Method)66 IndexedPropertyDescriptor (java.beans.IndexedPropertyDescriptor)49 PropertyDescriptor (java.beans.PropertyDescriptor)34 IntrospectionException (java.beans.IntrospectionException)24 MethodDescriptor (java.beans.MethodDescriptor)3 BeanDescriptor (java.beans.BeanDescriptor)2 ParameterDescriptor (java.beans.ParameterDescriptor)1 PropertyChangeEvent (java.beans.PropertyChangeEvent)1