本文整理汇总了Java中org.apache.harmony.beans.tests.support.SampleBean类的典型用法代码示例。如果您正苦于以下问题:Java SampleBean类的具体用法?Java SampleBean怎么用?Java SampleBean使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SampleBean类属于org.apache.harmony.beans.tests.support包,在下文中一共展示了SampleBean类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testStatic
import org.apache.harmony.beans.tests.support.SampleBean; //导入依赖的package包/类
/**
* The test checks the correct static method is initialized
*/
public void testStatic() throws Exception {
SampleBean theBean = new SampleBean();
Expression expr = new Expression(SampleBean.class, "create",
new Object[] { "hello", theBean });
Object result = expr.getValue();
if (result != null && result instanceof SampleBean) {
SampleBean bean = (SampleBean) result;
assertEquals("hello", bean.getText());
assertEquals(theBean, bean.getObject());
} else {
fail("Cannot instantiate an instance of Bean class by "
+ "static method.");
}
}
示例2: testConstructor
import org.apache.harmony.beans.tests.support.SampleBean; //导入依赖的package包/类
/**
* The test checks the correct constructor is initialized
*/
public void testConstructor() throws Exception {
Expression expr = new Expression(SampleBean.class, "new",
new Object[] { "hello" });
Object result = expr.getValue();
if (result != null && result instanceof SampleBean) {
SampleBean bean = (SampleBean) result;
assertEquals("hello", bean.getText());
} else {
fail("Cannot instantiate an instance of Bean class.");
}
}
示例3: testGetter
import org.apache.harmony.beans.tests.support.SampleBean; //导入依赖的package包/类
/**
* The test checks the correct getter is initialized
*/
public void testGetter() throws Exception {
Expression expr = new Expression(new SampleBean("hello"), "getText",
new Object[] {});
Object result = expr.getValue();
if (result != null && result instanceof String) {
assertEquals("hello", result);
} else {
fail("Result of SampleBean.getText() call is not "
+ "of String type.");
}
}
示例4: testBeanDescriptor
import org.apache.harmony.beans.tests.support.SampleBean; //导入依赖的package包/类
/**
* The test checks the getBeanDescriptor method
*/
public void testBeanDescriptor() throws Exception {
String[] oldBeanInfoSearchPath = Introspector.getBeanInfoSearchPath();
try {
Introspector
.setBeanInfoSearchPath(new String[] { "java.beans.infos" });
BeanInfo info = Introspector.getBeanInfo(SampleBean.class);
assertNotNull(info);
BeanDescriptor descriptor = info.getBeanDescriptor();
assertNotNull(descriptor);
assertEquals(SampleBean.class, descriptor.getBeanClass());
} finally {
Introspector.setBeanInfoSearchPath(oldBeanInfoSearchPath);
}
}
示例5: testUnicastEventSetDescriptor
import org.apache.harmony.beans.tests.support.SampleBean; //导入依赖的package包/类
/**
* The test checks the getEventSetDescriptors method
*
* @throws IntrospectionException
*/
public void testUnicastEventSetDescriptor() throws IntrospectionException {
BeanInfo info = Introspector.getBeanInfo(SampleBean.class);
assertNotNull(info);
EventSetDescriptor[] descriptors = info.getEventSetDescriptors();
assertNotNull(descriptors);
for (EventSetDescriptor descriptor : descriptors) {
Method m = descriptor.getAddListenerMethod();
if (m != null) {
Class<?>[] exceptionTypes = m.getExceptionTypes();
boolean found = false;
for (Class<?> et : exceptionTypes) {
if (et
.equals(TooManyListenersException.class)) {
assertTrue(descriptor.isUnicast());
found = true;
break;
}
}
if (!found) {
assertFalse(descriptor.isUnicast());
}
}
}
}