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

The following examples show how to use java.beans.IndexedPropertyDescriptor#setIndexedReadMethod() . 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 testSetIndexedReadMethod() 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, null, indexedWriteMethod);
    assertNull(ipd.getIndexedReadMethod());
    ipd.setIndexedReadMethod(indexedReadMethod);
    assertSame(indexedReadMethod, ipd.getIndexedReadMethod());
}
 
Example 2
Source File: IndexedPropertyDescriptorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void testSetIndexedReadMethod_invalid() throws SecurityException,
        NoSuchMethodException, IntrospectionException {
    String propertyName = "PropertyFour";
    Class<MockJavaBean> beanClass = MockJavaBean.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, null, null, indexedReadMethod, indexedWriteMethod);
    Method indexedReadMethod2 = beanClass.getMethod("getPropertySix",
            new Class[] { Integer.TYPE });
    try {
        ipd.setIndexedReadMethod(indexedReadMethod2);
        fail("Should throw IntrospectionException.");
    } catch (IntrospectionException e) {

    }
}
 
Example 3
Source File: IndexedPropertyDescriptorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
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());
}
 
Example 4
Source File: IndexedPropertyDescriptorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
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) {
    }
}
 
Example 5
Source File: IndexedPropertyDescriptorTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void testSetIndexedReadMethod_RInvalidArgType()
        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(writeMethod);
        fail("Should throw IntrospectionException.");
    } catch (IntrospectionException e) {
    }
}
 
Example 6
Source File: IndexedPropertyDescriptorTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
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) {
    }
}
 
Example 7
Source File: IndexedPropertyDescriptorTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
public void testSetIndexedReadMethodFollowANullValue() throws Exception {
    try {
        IndexedPropertyDescriptor i = new IndexedPropertyDescriptor("a",
                DummyBean.class, "readMethod", "writeMethod", null,
                "indexedReadMethod");
        Method irm = DummyBean.class.getDeclaredMethod("indexedReadMethod",
                Integer.TYPE);
        i.setIndexedReadMethod(irm);
        fail("should throw IntrospectionException.");
    } catch (IntrospectionException e) {
        // expected
    }
}