当前位置: 首页>>代码示例>>Java>>正文


Java SampleBean类代码示例

本文整理汇总了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.");
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:19,代码来源:ExpressionTest.java

示例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.");
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:15,代码来源:ExpressionTest.java

示例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.");
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:16,代码来源:ExpressionTest.java

示例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);
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:18,代码来源:IntrospectorTest.java

示例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());
            }
        }
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:32,代码来源:IntrospectorTest.java


注:本文中的org.apache.harmony.beans.tests.support.SampleBean类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。