use of org.apache.harmony.beans.tests.support.mock.MockJavaBean in project j2objc by google.
the class IndexedPropertyDescriptorTest method testSetIndexedWriteMethod.
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());
}
use of org.apache.harmony.beans.tests.support.mock.MockJavaBean in project j2objc by google.
the class IndexedPropertyDescriptorTest method testSetIndexedWriteMethod_InvalidIndexType.
public void testSetIndexedWriteMethod_InvalidIndexType() 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("setPropertyFourInvalid2", new Class[] { String.class, String.class });
try {
ipd.setIndexedWriteMethod(badArgType);
fail("Should throw IntrospectionException");
} catch (IntrospectionException e) {
}
ipd = new IndexedPropertyDescriptor("data", NormalBean.class);
ipd.setIndexedReadMethod(null);
try {
ipd.setIndexedWriteMethod(NormalBean.class.getMethod("setData", Integer.TYPE, Integer.TYPE));
fail("should throw IntrospectionException");
} catch (IntrospectionException e) {
// expected
}
}
use of org.apache.harmony.beans.tests.support.mock.MockJavaBean in project j2objc by google.
the class IndexedPropertyDescriptorTest method testSetIndexedReadMethod_RInvalidReturn.
/*
* indexed read method with void return.
*/
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) {
}
}
use of org.apache.harmony.beans.tests.support.mock.MockJavaBean in project j2objc by google.
the class IndexedPropertyDescriptorTest method testIndexedPropertyDescriptorStringClassStringStringStringString_RWNull.
/**
* indexed read/write null
*
*/
public void testIndexedPropertyDescriptorStringClassStringStringStringString_RWNull() throws IntrospectionException {
String propertyName = "PropertyFour";
Class<MockJavaBean> beanClass = MockJavaBean.class;
IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(propertyName, beanClass, null, null, "get" + propertyName, "set" + propertyName);
assertNull(ipd.getReadMethod());
assertNull(ipd.getWriteMethod());
assertEquals(String.class, ipd.getIndexedPropertyType());
assertNull(ipd.getPropertyType());
}
use of org.apache.harmony.beans.tests.support.mock.MockJavaBean in project j2objc by google.
the class IndexedPropertyDescriptorTest method testEquals_ReadMethod.
/*
* Read method
*/
public void testEquals_ReadMethod() throws SecurityException, NoSuchMethodException, IntrospectionException {
String propertyName = "PropertyFour";
Class<MockJavaBean> beanClass = MockJavaBean.class;
Method readMethod = beanClass.getMethod("getPropertyFive", (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);
IndexedPropertyDescriptor ipd2 = new IndexedPropertyDescriptor(propertyName, beanClass);
assertFalse(ipd.equals(ipd2));
}
Aggregations