Search in sources :

Example 1 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)

Example 2 with MockJavaBean

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

the class BeanDescriptorTest method testBeanDescriptorClassClass_CustomizerClassNull.

public void testBeanDescriptorClassClass_CustomizerClassNull() {
    String beanName = "BeanDescriptorTest.bean";
    MockJavaBean bean = new MockJavaBean(beanName);
    Class<? extends MockJavaBean> beanClass = bean.getClass();
    Class<?> cusClass = null;
    BeanDescriptor bd = new BeanDescriptor(beanClass, cusClass);
    assertSame(beanClass, bd.getBeanClass());
    assertNull(bd.getCustomizerClass());
    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)

Example 3 with MockJavaBean

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

the class MethodDescriptorTest method testMethodDescriptorMethodParameterDescriptorArray_PDNull.

public void testMethodDescriptorMethodParameterDescriptorArray_PDNull() throws SecurityException, NoSuchMethodException {
    String beanName = "MethodDescriptorTest.bean";
    MockJavaBean bean = new MockJavaBean(beanName);
    Method method = bean.getClass().getMethod("setPropertyOne", new Class[] { String.class });
    MethodDescriptor md = new MethodDescriptor(method, null);
    assertSame(method, md.getMethod());
    assertNull(md.getParameterDescriptors());
    assertEquals(method.getName(), md.getDisplayName());
    assertEquals(method.getName(), md.getName());
    assertEquals(method.getName(), md.getShortDescription());
    assertNotNull(md.attributeNames());
    assertFalse(md.isExpert());
    assertFalse(md.isHidden());
    assertFalse(md.isPreferred());
}
Also used : MockJavaBean(org.apache.harmony.beans.tests.support.mock.MockJavaBean) Method(java.lang.reflect.Method) MethodDescriptor(java.beans.MethodDescriptor)

Example 4 with MockJavaBean

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

the class PropertyDescriptorTest method testPropertyDescriptorStringMethodMethod_ReadMethodInvalid.

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

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

the class PropertyDescriptorTest method testPropertyDescriptorStringMethodMethod.

/*
     * Class under test for void PropertyDescriptor(String, Method, Method)
     */
public void testPropertyDescriptorStringMethodMethod() 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 });
    PropertyDescriptor pd = new PropertyDescriptor(propertyName, readMethod, writeMethod);
    assertEquals(String.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());
}
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