本文整理汇总了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());
}
示例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());
}
示例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());
}
示例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());
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
示例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());
}
示例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());
}
示例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) {
}
}
示例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) {
}
}
示例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) {
}
}
示例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) {
}
}