Search in sources :

Example 76 with MockJavaBean

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

the class PropertyDescriptorTest method testSetBound_false.

public void testSetBound_false() 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(false);
    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());
}
Also used : MockJavaBean(org.apache.harmony.beans.tests.support.mock.MockJavaBean) PropertyDescriptor(java.beans.PropertyDescriptor) Method(java.lang.reflect.Method)

Example 77 with MockJavaBean

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

the class PropertyDescriptorTest method testSetWriteMethod_Null.

/**
     * setWriteMethod(null)
     */
public void testSetWriteMethod_Null() 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, writeMethod);
    assertSame(writeMethod, pd.getWriteMethod());
    pd.setWriteMethod(null);
    assertNull(pd.getWriteMethod());
}
Also used : MockJavaBean(org.apache.harmony.beans.tests.support.mock.MockJavaBean) PropertyDescriptor(java.beans.PropertyDescriptor) Method(java.lang.reflect.Method)

Example 78 with MockJavaBean

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

the class PropertyDescriptorTest method testEquals_ReadMethod.

public void testEquals_ReadMethod() throws IntrospectionException, SecurityException, NoSuchMethodException {
    String propertyName = "PropertyOne";
    Class<MockJavaBean> beanClass = MockJavaBean.class;
    Method readMethod = beanClass.getMethod("get" + propertyName, (Class[]) 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)

Example 79 with MockJavaBean

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

the class PropertyDescriptorTest method testSetReadMethod.

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

Example 80 with MockJavaBean

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

the class PropertyDescriptorTest method testEquals.

public void testEquals() throws IntrospectionException, SecurityException, NoSuchMethodException {
    String propertyName = "PropertyOne";
    Class<MockJavaBean> beanClass = MockJavaBean.class;
    PropertyDescriptor pd = new PropertyDescriptor(propertyName, beanClass);
    Method readMethod = beanClass.getMethod("get" + propertyName, (Class[]) null);
    Method writeMethod = beanClass.getMethod("set" + propertyName, new Class[] { String.class });
    PropertyDescriptor pd2 = new PropertyDescriptor(propertyName, readMethod, writeMethod);
    pd.setName("different name");
    assertTrue(pd.equals(pd2));
    assertTrue(pd.equals(pd));
    assertTrue(pd2.equals(pd));
    assertFalse(pd.equals(null));
}
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