Search in sources :

Example 86 with MockJavaBean

use of org.apache.harmony.beans.tests.support.mock.MockJavaBean in project j2objc by google.

the class PropertyDescriptorTest method testSetConstrained_true.

public void testSetConstrained_true() throws SecurityException, NoSuchMethodException, IntrospectionException {
    Class<MockJavaBean> beanClass = MockJavaBean.class;
    String propertyName = "PropertyOne";
    Method readMethod = beanClass.getMethod("get" + propertyName, (Class[]) null);
    Method writeMethod = beanClass.getMethod("set" + propertyName, new Class[] { String.class });
    PropertyDescriptor pd = new PropertyDescriptor(propertyName, readMethod, writeMethod);
    pd.setConstrained(true);
    assertTrue(pd.isConstrained());
    assertFalse(pd.isBound());
    assertEquals(propertyName, pd.getDisplayName());
    assertEquals(propertyName, pd.getName());
    assertEquals(propertyName, pd.getShortDescription());
    assertNotNull(pd.attributeNames());
    assertFalse(pd.isExpert());
    assertFalse(pd.isHidden());
    assertFalse(pd.isPreferred());
}
Also used : MockJavaBean(org.apache.harmony.beans.tests.support.mock.MockJavaBean) PropertyDescriptor(java.beans.PropertyDescriptor) Method(java.lang.reflect.Method)

Example 87 with MockJavaBean

use of org.apache.harmony.beans.tests.support.mock.MockJavaBean in project j2objc by google.

the class PropertyDescriptorTest method testSetBound_true.

public void testSetBound_true() throws SecurityException, NoSuchMethodException, IntrospectionException {
    Class<MockJavaBean> beanClass = MockJavaBean.class;
    String propertyName = "PropertyOne";
    Method readMethod = beanClass.getMethod("get" + propertyName, (Class[]) null);
    Method writeMethod = beanClass.getMethod("set" + propertyName, new Class[] { String.class });
    PropertyDescriptor pd = new PropertyDescriptor(propertyName, readMethod, writeMethod);
    pd.setBound(true);
    assertTrue(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());
}
Also used : MockJavaBean(org.apache.harmony.beans.tests.support.mock.MockJavaBean) PropertyDescriptor(java.beans.PropertyDescriptor) Method(java.lang.reflect.Method)

Example 88 with MockJavaBean

use of org.apache.harmony.beans.tests.support.mock.MockJavaBean in project j2objc by google.

the class PropertyDescriptorTest method testPropertyDescriptorStringClassStringString_ReadMethodInvalid.

public void testPropertyDescriptorStringClassStringString_ReadMethodInvalid() throws IntrospectionException {
    String propertyName = "booleanProperty";
    Class<MockJavaBean> beanClass = MockJavaBean.class;
    PropertyDescriptor pd = new PropertyDescriptor(propertyName, beanClass, "getXX", "set" + propertyName);
    assertEquals("getBooleanProperty", pd.getReadMethod().getName());
    assertEquals("setbooleanProperty", pd.getWriteMethod().getName());
}
Also used : MockJavaBean(org.apache.harmony.beans.tests.support.mock.MockJavaBean) PropertyDescriptor(java.beans.PropertyDescriptor)

Example 89 with MockJavaBean

use of org.apache.harmony.beans.tests.support.mock.MockJavaBean in project j2objc by google.

the class PropertyDescriptorTest method testEquals_ReadMethod_Null.

public void testEquals_ReadMethod_Null() throws IntrospectionException, SecurityException, NoSuchMethodException {
    String propertyName = "PropertyOne";
    Class<MockJavaBean> beanClass = MockJavaBean.class;
    Method readMethod = null;
    PropertyDescriptor pd = new PropertyDescriptor(propertyName, readMethod, null);
    String propertyName2 = "PropertyThree";
    Method readMethod2 = beanClass.getMethod("get" + propertyName2, (Class[]) null);
    PropertyDescriptor pd2 = new PropertyDescriptor(propertyName2, readMethod2, null);
    assertFalse(pd.equals(pd2));
}
Also used : MockJavaBean(org.apache.harmony.beans.tests.support.mock.MockJavaBean) PropertyDescriptor(java.beans.PropertyDescriptor) Method(java.lang.reflect.Method)

Aggregations

MockJavaBean (org.apache.harmony.beans.tests.support.mock.MockJavaBean)89 Method (java.lang.reflect.Method)66 IndexedPropertyDescriptor (java.beans.IndexedPropertyDescriptor)49 PropertyDescriptor (java.beans.PropertyDescriptor)34 IntrospectionException (java.beans.IntrospectionException)24 MethodDescriptor (java.beans.MethodDescriptor)3 BeanDescriptor (java.beans.BeanDescriptor)2 ParameterDescriptor (java.beans.ParameterDescriptor)1 PropertyChangeEvent (java.beans.PropertyChangeEvent)1