Search in sources :

Example 41 with MockJavaBean

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

the class PropertyDescriptorTest method testPropertyDescriptorStringMethodMethod_PropertyNameNull.

public void testPropertyDescriptorStringMethodMethod_PropertyNameNull() throws SecurityException, NoSuchMethodException, IntrospectionException {
    String propertyName = "PropertyOne";
    Class<MockJavaBean> beanClass = MockJavaBean.class;
    Method readMethod = beanClass.getMethod("get" + propertyName, (Class[]) null);
    Method writeMethod = beanClass.getMethod("set" + propertyName, new Class[] { String.class });
    try {
        new PropertyDescriptor(null, readMethod, 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 42 with MockJavaBean

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

the class PropertyDescriptorTest method testPropertyDescriptorStringClass_PropertyNameCapital.

public void testPropertyDescriptorStringClass_PropertyNameCapital() throws IntrospectionException {
    String propertyName = "PropertyOne";
    Class<MockJavaBean> beanClass = MockJavaBean.class;
    PropertyDescriptor pd = new PropertyDescriptor(propertyName, beanClass);
    assertEquals(propertyName, pd.getName());
}
Also used : MockJavaBean(org.apache.harmony.beans.tests.support.mock.MockJavaBean) PropertyDescriptor(java.beans.PropertyDescriptor)

Example 43 with MockJavaBean

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

the class PropertyDescriptorTest method testSetWriteMethod_Invalid.

/**
 * write method is incompatible with property name (read method is null)
 */
public void testSetWriteMethod_Invalid() throws SecurityException, NoSuchMethodException, IntrospectionException {
    Class<MockJavaBean> beanClass = MockJavaBean.class;
    String propertyName = "PropertyOne";
    Method writeMethod = beanClass.getMethod("set" + "PropertyTwo", new Class[] { Integer.class });
    PropertyDescriptor pd = new PropertyDescriptor(propertyName, null, null);
    assertNull(pd.getWriteMethod());
    pd.setWriteMethod(writeMethod);
    assertSame(writeMethod, pd.getWriteMethod());
}
Also used : MockJavaBean(org.apache.harmony.beans.tests.support.mock.MockJavaBean) PropertyDescriptor(java.beans.PropertyDescriptor) Method(java.lang.reflect.Method)

Example 44 with MockJavaBean

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

the class PropertyVetoExceptionTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    MockJavaBean myBean = new MockJavaBean("Bean_PropertyVetoExceptionTest");
    event = new PropertyChangeEvent(myBean, "propertyOne", "value_old", "value_one");
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) MockJavaBean(org.apache.harmony.beans.tests.support.mock.MockJavaBean)

Example 45 with MockJavaBean

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

the class BeanDescriptorTest method testBeanDescriptorClass.

/*
     * Class under test for void BeanDescriptor(Class)
     */
public void testBeanDescriptorClass() {
    String beanName = "BeanDescriptorTest.bean";
    MockJavaBean bean = new MockJavaBean(beanName);
    Class<? extends MockJavaBean> beanClass = bean.getClass();
    BeanDescriptor bd = new BeanDescriptor(beanClass);
    assertSame(beanClass, bd.getBeanClass());
    String displayName = beanClass.getName().substring(beanClass.getName().lastIndexOf('.') + 1);
    assertEquals(displayName, bd.getDisplayName());
    assertEquals(displayName, bd.getName());
    assertEquals(displayName, bd.getShortDescription());
    assertNotNull(bd.attributeNames());
    assertFalse(bd.isExpert());
    assertFalse(bd.isHidden());
    assertFalse(bd.isPreferred());
}
Also used : MockJavaBean(org.apache.harmony.beans.tests.support.mock.MockJavaBean) BeanDescriptor(java.beans.BeanDescriptor)

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