use of java.beans.IntrospectionException 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 java.beans.IntrospectionException in project j2objc by google.
the class IndexedPropertyDescriptorTest method testSetIndexedMethodNullNull.
public void testSetIndexedMethodNullNull() throws Exception {
try {
IndexedPropertyDescriptor i = new IndexedPropertyDescriptor("a", NormalBean.class, "getData", "setData", null, "setData");
i.setIndexedWriteMethod(null);
fail("should throw IntrospectionException.");
} catch (IntrospectionException e) {
// expected
}
try {
IndexedPropertyDescriptor i = new IndexedPropertyDescriptor("a", NormalBean.class, "getData", "setData", "getData", null);
i.setIndexedReadMethod(null);
fail("should throw IntrospectionException.");
} catch (IntrospectionException e) {
// expected
}
}
use of java.beans.IntrospectionException 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 java.beans.IntrospectionException 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 java.beans.IntrospectionException 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) {
}
}
Aggregations