Java Code Examples for java.beans.IndexedPropertyDescriptor#setIndexedWriteMethod()

The following examples show how to use java.beans.IndexedPropertyDescriptor#setIndexedWriteMethod() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IndexedPropertyDescriptorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void testSetIndexedWriteMethod_null() throws IntrospectionException,
        NoSuchMethodException, NoSuchMethodException {
    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(indexedWriteMethod, ipd.getIndexedWriteMethod());
    ipd.setIndexedWriteMethod(null);
    assertNull(ipd.getIndexedWriteMethod());
}
 
Example 2
Source File: IndexedPropertyDescriptorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void testSetIndexedWriteMethod() throws IntrospectionException,
        NoSuchMethodException, NoSuchMethodException {
    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, null);
    assertNull(ipd.getIndexedWriteMethod());
    ipd.setIndexedWriteMethod(indexedWriteMethod);
    assertSame(indexedWriteMethod, ipd.getIndexedWriteMethod());
}
 
Example 3
Source File: IndexedPropertyDescriptorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void testSetIndexedWriteMethod_noargs()
        throws IntrospectionException, NoSuchMethodException,
        NoSuchMethodException {
    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 });

    IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
            propertyName, readMethod, writeMethod, indexedReadMethod, null);
    assertNull(ipd.getIndexedWriteMethod());
    try {
        ipd.setIndexedWriteMethod(indexedReadMethod);
        fail("Should throw IntrospectionException.");
    } catch (IntrospectionException e) {
    }
}
 
Example 4
Source File: IndexedPropertyDescriptorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void testSetIndexedWriteMethod_badargtype()
        throws IntrospectionException, NoSuchMethodException,
        NoSuchMethodException {
    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 });

    IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
            propertyName, readMethod, writeMethod, indexedReadMethod, null);
    assertNull(ipd.getIndexedWriteMethod());
    Method badArgType = beanClass.getMethod("set" + propertyName,
            new Class[] { Integer.TYPE, Integer.TYPE });
    try {
        ipd.setIndexedWriteMethod(badArgType);
        fail("Should throw IntrospectionException");
    } catch (IntrospectionException e) {
    }
}
 
Example 5
Source File: IndexedPropertyDescriptorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void testSetIndexedWriteMethod_return()
        throws IntrospectionException, NoSuchMethodException,
        NoSuchMethodException {
    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 });

    IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
            propertyName, readMethod, writeMethod, indexedReadMethod, null);
    assertNull(ipd.getIndexedWriteMethod());
    Method badArgType = beanClass.getMethod("setPropertyFourInvalid",
            new Class[] { Integer.TYPE, String.class });
    ipd.setIndexedWriteMethod(badArgType);

    assertEquals(String.class, ipd.getIndexedPropertyType());
    assertEquals(String[].class, ipd.getPropertyType());
    assertEquals(Integer.TYPE, ipd.getIndexedWriteMethod().getReturnType());
}