use of org.apache.harmony.beans.tests.support.mock.MockJavaBean in project j2objc by google.
the class PropertyDescriptorTest method testPropertyDescriptorStringMethodMethod_ReadMethodNull.
public void testPropertyDescriptorStringMethodMethod_ReadMethodNull() throws SecurityException, NoSuchMethodException, IntrospectionException {
String propertyName = "PropertyOne";
Class<MockJavaBean> beanClass = MockJavaBean.class;
Method readMethod = null;
Method writeMethod = beanClass.getMethod("set" + propertyName, new Class[] { String.class });
PropertyDescriptor pd = new PropertyDescriptor(propertyName, readMethod, writeMethod);
assertEquals(String.class, pd.getPropertyType());
assertNull(pd.getReadMethod());
assertEquals("set" + propertyName, pd.getWriteMethod().getName());
assertFalse(pd.isBound());
assertFalse(pd.isConstrained());
assertEquals(propertyName, pd.getDisplayName());
assertEquals(propertyName, pd.getName());
assertEquals(propertyName, pd.getShortDescription());
assertNotNull(pd.attributeNames());
assertFalse(pd.isExpert());
assertFalse(pd.isHidden());
assertFalse(pd.isPreferred());
}
use of org.apache.harmony.beans.tests.support.mock.MockJavaBean in project j2objc by google.
the class PropertyDescriptorTest method testSetWriteMethod.
/**
* normal input
*/
public void testSetWriteMethod() throws SecurityException, NoSuchMethodException, IntrospectionException {
Class<MockJavaBean> beanClass = MockJavaBean.class;
String propertyName = "PropertyOne";
Method writeMethod = beanClass.getMethod("set" + propertyName, new Class[] { String.class });
PropertyDescriptor pd = new PropertyDescriptor(propertyName, null, null);
assertNull(pd.getWriteMethod());
pd.setWriteMethod(writeMethod);
assertSame(writeMethod, pd.getWriteMethod());
}
use of org.apache.harmony.beans.tests.support.mock.MockJavaBean in project j2objc by google.
the class PropertyDescriptorTest method testPropertyDescriptorStringClassStringString.
/*
* Class under test for void PropertyDescriptor(String, Class, String,
* String)
*/
public void testPropertyDescriptorStringClassStringString() throws IntrospectionException {
String propertyName = "PropertyTwo";
Class<MockJavaBean> beanClass = MockJavaBean.class;
PropertyDescriptor pd = new PropertyDescriptor(propertyName, beanClass, "get" + propertyName, "set" + propertyName);
assertEquals(Integer.class, pd.getPropertyType());
assertEquals("get" + propertyName, pd.getReadMethod().getName());
assertEquals("set" + propertyName, pd.getWriteMethod().getName());
assertFalse(pd.isBound());
assertFalse(pd.isConstrained());
assertEquals(propertyName, pd.getDisplayName());
assertEquals(propertyName, pd.getName());
assertEquals(propertyName, pd.getShortDescription());
assertNotNull(pd.attributeNames());
assertFalse(pd.isExpert());
assertFalse(pd.isHidden());
assertFalse(pd.isPreferred());
}
use of org.apache.harmony.beans.tests.support.mock.MockJavaBean in project j2objc by google.
the class PropertyDescriptorTest method testSetReadMethod_ReadWriteIncompatible.
/**
* Read method is incompatible with write method getPropertyOn vs.
* setPropertyTow
*/
public void testSetReadMethod_ReadWriteIncompatible() throws SecurityException, NoSuchMethodException, IntrospectionException {
Class<MockJavaBean> beanClass = MockJavaBean.class;
String propertyName = "PropertyOne";
Method readMethod = beanClass.getMethod("get" + "PropertyOne", (Class[]) null);
Method writeMethod = beanClass.getMethod("set" + "PropertyTwo", new Class[] { Integer.class });
PropertyDescriptor pd = new PropertyDescriptor(propertyName, null, writeMethod);
assertNull(pd.getReadMethod());
try {
pd.setReadMethod(readMethod);
fail("Should throw IntrospectionException.");
} catch (IntrospectionException e) {
}
}
use of org.apache.harmony.beans.tests.support.mock.MockJavaBean in project j2objc by google.
the class PropertyDescriptorTest method testSetReadMethod_Invalid.
/**
* Read method is incompatible with property name getPropertyTwo vs.
* PropertyOne (writeMethod=null)
*/
public void testSetReadMethod_Invalid() throws SecurityException, NoSuchMethodException, IntrospectionException {
Class<MockJavaBean> beanClass = MockJavaBean.class;
String propertyName = "PropertyOne";
Method readMethod = beanClass.getMethod("get" + "PropertyTwo", (Class[]) null);
PropertyDescriptor pd = new PropertyDescriptor(propertyName, null, null);
assertNull(pd.getReadMethod());
pd.setReadMethod(readMethod);
assertSame(readMethod, pd.getReadMethod());
}
Aggregations