use of org.apache.harmony.beans.tests.support.mock.MockJavaBean in project j2objc by google.
the class IndexedPropertyDescriptorTest method testIndexedPropertyDescriptorStringClassStringStringStringString_WNull.
/**
* index write /write null
*/
public void testIndexedPropertyDescriptorStringClassStringStringStringString_WNull() throws IntrospectionException {
String propertyName = "PropertyFour";
Class<MockJavaBean> beanClass = MockJavaBean.class;
IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(propertyName, beanClass, "get" + propertyName, null, "get" + propertyName, null);
assertEquals(String.class, ipd.getIndexedPropertyType());
assertEquals(String[].class, ipd.getPropertyType());
assertNotNull(ipd.getReadMethod());
assertNotNull(ipd.getIndexedReadMethod());
}
use of org.apache.harmony.beans.tests.support.mock.MockJavaBean in project j2objc by google.
the class IndexedPropertyDescriptorTest method testIndexedPropertyDescriptorStringMethodMethodMethodMethod_propEmpty.
/*
* propertyname="";
*/
public void testIndexedPropertyDescriptorStringMethodMethodMethodMethod_propEmpty() throws SecurityException, 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 });
try {
new IndexedPropertyDescriptor("", readMethod, writeMethod, indexedReadMethod, indexedWriteMethod);
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 testIndexedPropertyDescriptorStringClass.
/*
* Class under test for void IndexedPropertyDescriptor(String, Class)
*/
public void testIndexedPropertyDescriptorStringClass() throws IntrospectionException, SecurityException, NoSuchMethodException {
String propertyName = "propertyFour";
Class<MockJavaBean> beanClass = MockJavaBean.class;
IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(propertyName, beanClass);
String capitalName = propertyName.substring(0, 1).toUpperCase() + propertyName.substring(1);
Method readMethod = beanClass.getMethod("get" + capitalName, (Class[]) null);
Method writeMethod = beanClass.getMethod("set" + capitalName, new Class[] { String[].class });
Method indexedReadMethod = beanClass.getMethod("get" + capitalName, new Class[] { Integer.TYPE });
Method indexedWriteMethod = beanClass.getMethod("set" + capitalName, new Class[] { Integer.TYPE, String.class });
assertEquals(readMethod, ipd.getReadMethod());
assertEquals(writeMethod, ipd.getWriteMethod());
assertEquals(indexedReadMethod, ipd.getIndexedReadMethod());
assertEquals(indexedWriteMethod, ipd.getIndexedWriteMethod());
assertEquals(String[].class, ipd.getPropertyType());
assertEquals(String.class, ipd.getIndexedPropertyType());
assertFalse(ipd.isBound());
assertFalse(ipd.isConstrained());
assertEquals(propertyName, ipd.getDisplayName());
assertEquals(propertyName, ipd.getName());
assertEquals(propertyName, ipd.getShortDescription());
assertNotNull(ipd.attributeNames());
assertFalse(ipd.isExpert());
assertFalse(ipd.isHidden());
assertFalse(ipd.isPreferred());
// Regression for HARMONY-1236
try {
new IndexedPropertyDescriptor("0xDFRF", Float.TYPE);
fail("IntrospectionException expected");
} catch (IntrospectionException e) {
// expected
}
}
use of org.apache.harmony.beans.tests.support.mock.MockJavaBean in project j2objc by google.
the class IndexedPropertyDescriptorTest method testSetIndexedReadMethod_invalid.
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) {
}
}
use of org.apache.harmony.beans.tests.support.mock.MockJavaBean in project j2objc by google.
the class IndexedPropertyDescriptorTest method testEquals_ReadMethodNull.
/*
* read method null.
*/
public void testEquals_ReadMethodNull() throws SecurityException, NoSuchMethodException, IntrospectionException {
String propertyName = "PropertyFour";
Class<MockJavaBean> beanClass = MockJavaBean.class;
Method readMethod = 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