use of java.beans.IndexedPropertyDescriptor 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 java.beans.IndexedPropertyDescriptor 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 java.beans.IndexedPropertyDescriptor 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));
}
use of java.beans.IndexedPropertyDescriptor 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 java.beans.IndexedPropertyDescriptor in project j2objc by google.
the class IntrospectorTest method test_MixedSimpleClass47.
public void test_MixedSimpleClass47() throws Exception {
BeanInfo beanInfo = Introspector.getBeanInfo(MixedSimpleClass47.class);
Method getter = MixedSimpleClass47.class.getMethod("isList", new Class<?>[] {});
assertEquals(2, beanInfo.getPropertyDescriptors().length);
for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
if (propertyName.equals(pd.getName())) {
assertEquals(getter, pd.getReadMethod());
assertNull(pd.getWriteMethod());
assertFalse(pd instanceof IndexedPropertyDescriptor);
}
}
}
Aggregations