use of org.apache.harmony.beans.tests.support.mock.MockJavaBean in project j2objc by google.
the class IndexedPropertyDescriptorTest method testIndexedPropertyDescriptorStringClassStringStringStringString_IndexedRWIncompatible.
/**
* IndexedRead/IndexedWrite incompatible
*
* @throws IntrospectionException
*
*/
public void testIndexedPropertyDescriptorStringClassStringStringStringString_IndexedRWIncompatible() throws IntrospectionException {
String propertyName = "PropertyFour";
String anotherProp = "PropertyFive";
Class<MockJavaBean> beanClass = MockJavaBean.class;
IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(propertyName, beanClass, "get" + propertyName, "set" + propertyName, "get" + propertyName, "set" + anotherProp);
assertEquals(String.class, ipd.getIndexedPropertyType());
assertEquals(String[].class, ipd.getPropertyType());
assertEquals("set" + anotherProp, ipd.getIndexedWriteMethod().getName());
}
use of org.apache.harmony.beans.tests.support.mock.MockJavaBean in project j2objc by google.
the class IndexedPropertyDescriptorTest method testIndexedPropertyDescriptorStringClassStringStringStringString.
/*
* Class under test for void IndexedPropertyDescriptor(String, Class,
* String, String, String, String)
*/
public void testIndexedPropertyDescriptorStringClassStringStringStringString() throws IntrospectionException, SecurityException, NoSuchMethodException {
String propertyName = "PropertyFour";
Class<MockJavaBean> beanClass = MockJavaBean.class;
IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(propertyName, beanClass, "get" + propertyName, "set" + propertyName, "get" + propertyName, "set" + propertyName);
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 });
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());
//empty method name
new IndexedPropertyDescriptor(propertyName, beanClass, "get" + propertyName, "set" + propertyName, "", "set" + propertyName);
try {
new IndexedPropertyDescriptor("a", MyClass.class, "getA", "setA", "", "setA");
fail("Shoule throw exception");
} catch (IntrospectionException e) {
// expected
}
try {
new IndexedPropertyDescriptor(propertyName, beanClass, "", "set" + propertyName, "get" + propertyName, "set" + propertyName);
fail("Shoule throw exception");
} catch (IntrospectionException e) {
// expected
}
try {
new IndexedPropertyDescriptor(propertyName, beanClass, "get" + propertyName, "", "get" + propertyName, "set" + propertyName);
fail("Shoule throw exception");
} catch (IntrospectionException e) {
// expected
}
try {
new IndexedPropertyDescriptor(propertyName, beanClass, "get" + propertyName, "set" + propertyName, "get" + propertyName, "");
fail("Shoule throw exception");
} catch (IntrospectionException e) {
// expected
}
//null method name
new IndexedPropertyDescriptor(propertyName, beanClass, "get" + propertyName, "set" + propertyName, null, "set" + propertyName);
new IndexedPropertyDescriptor(propertyName, beanClass, null, "set" + propertyName, "get" + propertyName, "set" + propertyName);
new IndexedPropertyDescriptor(propertyName, beanClass, "get" + propertyName, null, "get" + propertyName, "set" + propertyName);
new IndexedPropertyDescriptor(propertyName, beanClass, "get" + propertyName, "set" + propertyName, "get" + propertyName, null);
}
use of org.apache.harmony.beans.tests.support.mock.MockJavaBean in project j2objc by google.
the class IndexedPropertyDescriptorTest method testIndexedPropertyDescriptorStringClassStringStringStringString_allNull.
public void testIndexedPropertyDescriptorStringClassStringStringStringString_allNull() throws IntrospectionException {
String propertyName = "PropertyFour";
Class<MockJavaBean> beanClass = MockJavaBean.class;
IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(propertyName, beanClass, null, null, null, null);
assertNull(ipd.getIndexedPropertyType());
assertNull(ipd.getPropertyType());
assertNull(ipd.getReadMethod());
assertNull(ipd.getIndexedReadMethod());
}
use of org.apache.harmony.beans.tests.support.mock.MockJavaBean in project j2objc by google.
the class IndexedPropertyDescriptorTest method testSetIndexedReadMethod_RInvalidArgType.
/*
* indexed read method with invalid arg type (!Integer.TYPE)
*/
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) {
}
}
use of org.apache.harmony.beans.tests.support.mock.MockJavaBean in project j2objc by google.
the class IndexedPropertyDescriptorTest method testSetIndexedWriteMethod_return.
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());
}
Aggregations