當前位置: 首頁>>代碼示例>>Java>>正文


Java MockJavaBean類代碼示例

本文整理匯總了Java中org.apache.harmony.beans.tests.support.mock.MockJavaBean的典型用法代碼示例。如果您正苦於以下問題:Java MockJavaBean類的具體用法?Java MockJavaBean怎麽用?Java MockJavaBean使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MockJavaBean類屬於org.apache.harmony.beans.tests.support.mock包,在下文中一共展示了MockJavaBean類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testMethodDescriptorMethod

import org.apache.harmony.beans.tests.support.mock.MockJavaBean; //導入依賴的package包/類
public void testMethodDescriptorMethod() throws SecurityException,
        NoSuchMethodException {
    String beanName = "MethodDescriptorTest.bean";
    MockJavaBean bean = new MockJavaBean(beanName);
    Method method = bean.getClass()
            .getMethod("getBeanName", (Class[]) null);
    MethodDescriptor md = new MethodDescriptor(method);

    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());
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:22,代碼來源:MethodDescriptorTest.java

示例2: testMethodDescriptorMethodParameterDescriptorArray

import org.apache.harmony.beans.tests.support.mock.MockJavaBean; //導入依賴的package包/類
public void testMethodDescriptorMethodParameterDescriptorArray()
        throws SecurityException, NoSuchMethodException {
    String beanName = "MethodDescriptorTest.bean";
    MockJavaBean bean = new MockJavaBean(beanName);
    Method method = bean.getClass().getMethod("setPropertyOne",
            new Class[] { String.class });
    ParameterDescriptor[] pds = new ParameterDescriptor[1];
    pds[0] = new ParameterDescriptor();
    pds[0].setValue(method.getName(), method.getReturnType());
    MethodDescriptor md = new MethodDescriptor(method, pds);

    assertSame(method, md.getMethod());
    assertSame(pds, md.getParameterDescriptors());
    assertEquals(pds[0].getValue(method.getName()), md
            .getParameterDescriptors()[0].getValue(method.getName()));

    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());
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:27,代碼來源:MethodDescriptorTest.java

示例3: testMethodDescriptorMethodParameterDescriptorArray_PDNull

import org.apache.harmony.beans.tests.support.mock.MockJavaBean; //導入依賴的package包/類
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());
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:22,代碼來源:MethodDescriptorTest.java

示例4: testHashCode

import org.apache.harmony.beans.tests.support.mock.MockJavaBean; //導入依賴的package包/類
public void testHashCode() throws Exception {
    String propertyName = "PropertyFour";
    Class<MockJavaBean> beanClass = MockJavaBean.class;

    Method readMethod = beanClass.getMethod("get" + propertyName,
            (Class[]) null);
    Method writeMethod = beanClass.getMethod("set" + propertyName,
            new Class[] { String[].class });
    Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
            new Class[] { Integer.TYPE });
    Method indexedWriteMethod = beanClass.getMethod("set" + propertyName,
            new Class[] { Integer.TYPE, String.class });

    IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
            propertyName, readMethod, writeMethod, indexedReadMethod,
            indexedWriteMethod);

    IndexedPropertyDescriptor ipd2 = new IndexedPropertyDescriptor(
            propertyName, beanClass);

    assertEquals(ipd, ipd2);
    assertEquals(ipd.hashCode(), ipd2.hashCode());
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:24,代碼來源:IndexedPropertyDescriptorTest.java

示例5: testEquals

import org.apache.harmony.beans.tests.support.mock.MockJavaBean; //導入依賴的package包/類
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));
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:20,代碼來源:PropertyDescriptorTest.java

示例6: testEquals_ReadMethod

import org.apache.harmony.beans.tests.support.mock.MockJavaBean; //導入依賴的package包/類
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));
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:18,代碼來源:PropertyDescriptorTest.java

示例7: testEquals_ReadMethod_Null

import org.apache.harmony.beans.tests.support.mock.MockJavaBean; //導入依賴的package包/類
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));
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:17,代碼來源:PropertyDescriptorTest.java

示例8: testEquals_WriteMethod

import org.apache.harmony.beans.tests.support.mock.MockJavaBean; //導入依賴的package包/類
public void testEquals_WriteMethod() throws IntrospectionException,
        SecurityException, NoSuchMethodException {
    String propertyName = "PropertyOne";
    Class<MockJavaBean> beanClass = MockJavaBean.class;
    Method writeMethod = beanClass.getMethod("set" + propertyName,
            new Class[] { String.class });
    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));
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:18,代碼來源:PropertyDescriptorTest.java

示例9: testEquals_WriteMethod_Null

import org.apache.harmony.beans.tests.support.mock.MockJavaBean; //導入依賴的package包/類
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));
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:17,代碼來源:PropertyDescriptorTest.java

示例10: testPropertyDescriptorStringClassStringString

import org.apache.harmony.beans.tests.support.mock.MockJavaBean; //導入依賴的package包/類
public void testPropertyDescriptorStringClassStringString()
        throws IntrospectionException {
    String propertyName = "PropertyTwo";
    Class<MockJavaBean> beanClass = MockJavaBean.class;
    PropertyDescriptor pd = new PropertyDescriptor(propertyName, beanClass,
            "get" + propertyName, "set" + propertyName);

    assertEquals(Integer.class, pd.getPropertyType());
    assertEquals("get" + propertyName, pd.getReadMethod().getName());
    assertEquals("set" + propertyName, pd.getWriteMethod().getName());

    assertFalse(pd.isBound());
    assertFalse(pd.isConstrained());
    assertNull(pd.getPropertyEditorClass());

    assertEquals(propertyName, pd.getDisplayName());
    assertEquals(propertyName, pd.getName());
    assertEquals(propertyName, pd.getShortDescription());

    assertNotNull(pd.attributeNames());

    assertFalse(pd.isExpert());
    assertFalse(pd.isHidden());
    assertFalse(pd.isPreferred());
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:26,代碼來源:PropertyDescriptorTest.java

示例11: testPropertyDescriptorStringClassStringString_WriteMethodNull

import org.apache.harmony.beans.tests.support.mock.MockJavaBean; //導入依賴的package包/類
public void testPropertyDescriptorStringClassStringString_WriteMethodNull()
        throws IntrospectionException {
    String propertyName = "PropertyTwo";
    Class<MockJavaBean> beanClass = MockJavaBean.class;
    PropertyDescriptor pd = new PropertyDescriptor(propertyName, beanClass,
            "get" + propertyName, null);

    assertEquals(Integer.class, pd.getPropertyType());
    assertEquals("get" + propertyName, pd.getReadMethod().getName());
    assertNull(pd.getWriteMethod());

    assertFalse(pd.isBound());
    assertFalse(pd.isConstrained());
    assertNull(pd.getPropertyEditorClass());

    assertEquals(propertyName, pd.getDisplayName());
    assertEquals(propertyName, pd.getName());
    assertEquals(propertyName, pd.getShortDescription());

    assertNotNull(pd.attributeNames());

    assertFalse(pd.isExpert());
    assertFalse(pd.isHidden());
    assertFalse(pd.isPreferred());
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:26,代碼來源:PropertyDescriptorTest.java

示例12: testSetIndexedWriteMethod_badargtype

import org.apache.harmony.beans.tests.support.mock.MockJavaBean; //導入依賴的package包/類
public void testSetIndexedWriteMethod_badargtype()
        throws IntrospectionException, NoSuchMethodException,
        NoSuchMethodException {
    String propertyName = "PropertyFour";
    Class<MockJavaBean> beanClass = MockJavaBean.class;

    Method readMethod = beanClass.getMethod("get" + propertyName,
            (Class[]) null);
    Method writeMethod = beanClass.getMethod("set" + propertyName,
            new Class[] { String[].class });
    Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
            new Class[] { Integer.TYPE });

    IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
            propertyName, readMethod, writeMethod, indexedReadMethod, null);
    assertNull(ipd.getIndexedWriteMethod());
    Method badArgType = beanClass.getMethod("set" + propertyName,
            new Class[] { Integer.TYPE, Integer.TYPE });
    try {
        ipd.setIndexedWriteMethod(badArgType);
        fail("Should throw IntrospectionException");
    } catch (IntrospectionException e) {
    }
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:25,代碼來源:IndexedPropertyDescriptorTest.java

示例13: testPropertyDescriptorStringMethodMethod_PropertyNameNull

import org.apache.harmony.beans.tests.support.mock.MockJavaBean; //導入依賴的package包/類
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) {
    }

}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:17,代碼來源:PropertyDescriptorTest.java

示例14: testSetIndexedReadMethod_RInvalidArgType

import org.apache.harmony.beans.tests.support.mock.MockJavaBean; //導入依賴的package包/類
public void testSetIndexedReadMethod_RInvalidArgType()
        throws SecurityException, NoSuchMethodException,
        IntrospectionException {
    String propertyName = "PropertyFour";
    Class<MockJavaBean> beanClass = MockJavaBean.class;

    Method readMethod = beanClass.getMethod("get" + propertyName,
            (Class[]) null);
    Method writeMethod = beanClass.getMethod("set" + propertyName,
            new Class[] { String[].class });
    Method indexedReadMethod = beanClass.getMethod("get" + propertyName,
            new Class[] { Integer.TYPE });
    Method indexedWriteMethod = beanClass.getMethod("set" + propertyName,
            new Class[] { Integer.TYPE, String.class });

    IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor(
            propertyName, readMethod, writeMethod, indexedReadMethod,
            indexedWriteMethod);
    assertSame(indexedReadMethod, ipd.getIndexedReadMethod());
    try {
        ipd.setIndexedReadMethod(writeMethod);
        fail("Should throw IntrospectionException.");
    } catch (IntrospectionException e) {
    }
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:26,代碼來源:IndexedPropertyDescriptorTest.java

示例15: testPropertyDescriptorStringMethodMethod_WriteMethodInvalid

import org.apache.harmony.beans.tests.support.mock.MockJavaBean; //導入依賴的package包/類
public void testPropertyDescriptorStringMethodMethod_WriteMethodInvalid()
        throws SecurityException, NoSuchMethodException,
        IntrospectionException {
    String propertyName = "PropertyOne";
    Class<MockJavaBean> beanClass = MockJavaBean.class;
    String anotherProp = "PropertyTwo";

    Method readMethod = beanClass.getMethod("get" + propertyName,
            (Class[]) null);
    Method writeMethod = beanClass.getMethod("set" + anotherProp,
            new Class[] { Integer.class });
    try {
        new PropertyDescriptor(propertyName, readMethod, writeMethod);
        fail("Should throw IntrospectionException.");
    } catch (IntrospectionException e) {
    }

}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:19,代碼來源:PropertyDescriptorTest.java


注:本文中的org.apache.harmony.beans.tests.support.mock.MockJavaBean類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。