Search in sources :

Example 81 with MockJavaBean

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

the class PropertyDescriptorTest method testSetConstrained_false.

public void testSetConstrained_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.setConstrained(false);
    assertFalse(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 82 with MockJavaBean

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

the class PropertyDescriptorTest method testSetReadMethod_Null.

public void testSetReadMethod_Null() 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, readMethod, null);
    assertSame(readMethod, pd.getReadMethod());
    pd.setReadMethod(null);
    assertNull(pd.getReadMethod());
}
Also used : MockJavaBean(org.apache.harmony.beans.tests.support.mock.MockJavaBean) PropertyDescriptor(java.beans.PropertyDescriptor) Method(java.lang.reflect.Method)

Example 83 with MockJavaBean

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

the class PropertyDescriptorTest method testEquals_WriteMethod_Null.

public void testEquals_WriteMethod_Null() throws IntrospectionException, SecurityException, NoSuchMethodException {
    String propertyName = "PropertyOne";
    Class<MockJavaBean> beanClass = MockJavaBean.class;
    Method writeMethod = null;
    PropertyDescriptor pd = new PropertyDescriptor(propertyName, null, writeMethod);
    String propertyName2 = "PropertyThree";
    Method writeMethod2 = beanClass.getMethod("set" + propertyName2, new Class[] { String.class });
    PropertyDescriptor pd2 = new PropertyDescriptor(propertyName2, null, writeMethod2);
    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 84 with MockJavaBean

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

the class PropertyDescriptorTest method testSetWriteMethod_Invalid_NoArgs.

/**
     * write method without argument
     */
public void testSetWriteMethod_Invalid_NoArgs() throws SecurityException, NoSuchMethodException, IntrospectionException {
    Class<MockJavaBean> beanClass = MockJavaBean.class;
    String propertyName = "PropertyOne";
    Method writeMethod = beanClass.getMethod("get" + "PropertyTwo", (Class[]) null);
    PropertyDescriptor pd = new PropertyDescriptor(propertyName, null, null);
    assertNull(pd.getWriteMethod());
    try {
        pd.setWriteMethod(writeMethod);
        fail("Should throw IntrospectionException.");
    } catch (IntrospectionException e) {
    }
}
Also used : MockJavaBean(org.apache.harmony.beans.tests.support.mock.MockJavaBean) PropertyDescriptor(java.beans.PropertyDescriptor) IntrospectionException(java.beans.IntrospectionException) Method(java.lang.reflect.Method)

Example 85 with MockJavaBean

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

the class PropertyDescriptorTest method testSetReadMethod_Invalid_withArg.

/**
     * String invalidGetMethod(String arg)
     */
public void testSetReadMethod_Invalid_withArg() throws SecurityException, NoSuchMethodException, IntrospectionException {
    Class<MockJavaBean> beanClass = MockJavaBean.class;
    String propertyName = "PropertyOne";
    Method readMethod = beanClass.getMethod("invalidGetMethod", new Class[] { String.class });
    PropertyDescriptor pd = new PropertyDescriptor(propertyName, null, null);
    assertNull(pd.getReadMethod());
    try {
        pd.setReadMethod(readMethod);
        fail("Should throw IntrospectionException.");
    } catch (IntrospectionException e) {
    }
}
Also used : MockJavaBean(org.apache.harmony.beans.tests.support.mock.MockJavaBean) PropertyDescriptor(java.beans.PropertyDescriptor) IntrospectionException(java.beans.IntrospectionException) 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