use of java.beans.IntrospectionException in project j2objc by google.
the class IntrospectorTest method testGetBeanInfoClassClass_Method.
public void testGetBeanInfoClassClass_Method() throws IntrospectionException {
BeanInfo info = Introspector.getBeanInfo(MockFoo.class, MockFooStop.class);
MethodDescriptor[] mds = info.getMethodDescriptors();
assertEquals(4, mds.length);
assertTrue(contains("getName", mds));
assertTrue(contains("setName", mds));
assertTrue(contains("getComplexLabel", mds));
assertTrue(contains("setComplexLabel", mds));
try {
Introspector.getBeanInfo(MockFoo.class, Serializable.class);
fail("Shoule throw exception, stopclass must be superclass of given bean");
} catch (IntrospectionException e) {
}
}
use of java.beans.IntrospectionException in project j2objc by google.
the class IndexedPropertyDescriptorTest method testIndexedPropertyDescriptorStringMethodMethodMethodMethod_IndexedRWNull.
public void testIndexedPropertyDescriptorStringMethodMethodMethodMethod_IndexedRWNull() 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 });
try {
new IndexedPropertyDescriptor(propertyName, readMethod, writeMethod, null, null);
fail("Should throw IntrospectionException.");
} catch (IntrospectionException e) {
}
}
use of java.beans.IntrospectionException in project j2objc by google.
the class IndexedPropertyDescriptorTest method testIndexedPropertyDescriptorStringClassStringStringStringString_WriteMethodNull.
public void testIndexedPropertyDescriptorStringClassStringStringStringString_WriteMethodNull() throws IntrospectionException {
String propertyName = "PropertyFour";
Class<MockJavaBean> beanClass = MockJavaBean.class;
IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(propertyName, beanClass, "get" + propertyName, null, "get" + propertyName, "set" + propertyName);
assertNotNull(ipd.getReadMethod());
assertNull(ipd.getWriteMethod());
assertEquals(String.class, ipd.getIndexedPropertyType());
new IndexedPropertyDescriptor(propertyName, beanClass, "get" + propertyName, "set" + propertyName, "", "set" + propertyName);
try {
new IndexedPropertyDescriptor(propertyName, beanClass, "get" + propertyName, "set" + propertyName, "get" + propertyName, "");
fail();
} catch (Exception e) {
}
}
use of java.beans.IntrospectionException in project j2objc by google.
the class IndexedPropertyDescriptorTest method testSetIndexedReadMethod_RInvalidArgs.
/*
* indexed read method without args
*/
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) {
}
}
use of java.beans.IntrospectionException in project j2objc by google.
the class IndexedPropertyDescriptorTest method testIndexedPropertyDescriptorStringMethodMethodMethodMethod_IndexedRWIncompatible.
/*
* IndexedRead/IndexedWrite incompatible
*/
public void testIndexedPropertyDescriptorStringMethodMethodMethodMethod_IndexedRWIncompatible() throws SecurityException, NoSuchMethodException, IntrospectionException {
String propertyName = "PropertyFour";
String anotherProp = "PropertyFive";
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" + anotherProp, 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);
assertEquals(propertyName, ipd.getName());
assertEquals(String[].class, ipd.getPropertyType());
assertEquals(String.class, ipd.getIndexedPropertyType());
indexedReadMethod = beanClass.getMethod("get" + anotherProp, new Class[] { Integer.TYPE, Integer.TYPE });
try {
new IndexedPropertyDescriptor(propertyName, readMethod, writeMethod, indexedReadMethod, indexedWriteMethod);
fail("should throw IntrosecptionException");
} catch (IntrospectionException e) {
// expected
}
}
Aggregations