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


Java BeanContextSupport.add方法代码示例

本文整理汇总了Java中java.beans.beancontext.BeanContextSupport.add方法的典型用法代码示例。如果您正苦于以下问题:Java BeanContextSupport.add方法的具体用法?Java BeanContextSupport.add怎么用?Java BeanContextSupport.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.beans.beancontext.BeanContextSupport的用法示例。


在下文中一共展示了BeanContextSupport.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSerialization_NoPeer

import java.beans.beancontext.BeanContextSupport; //导入方法依赖的package包/类
public void testSerialization_NoPeer() throws IOException,
        ClassNotFoundException {
    BeanContextSupport support = new BeanContextSupport(null, Locale.ITALY,
            true, true);
    support
            .addBeanContextMembershipListener(new MockBeanContextMembershipListener());
    support
            .addBeanContextMembershipListener(new MockBeanContextMembershipListenerS(
                    "l2"));
    support
            .addBeanContextMembershipListener(new MockBeanContextMembershipListenerS(
                    "l3"));
    support
            .addBeanContextMembershipListener(new MockBeanContextMembershipListener());
    support.add("abcd");
    support.add(new MockBeanContextChild());
    support.add(new MockBeanContextChildS("a child"));
    support.add(new MockBeanContextChild());
    support.add("1234");
    support.add(new MockBeanContextProxyS("proxy",
            new MockBeanContextChildS("b child")));

    assertEqualsSerially(support, (BeanContextSupport) SerializationTester
            .getDeserilizedObject(support));
}
 
开发者ID:shannah,项目名称:cn1,代码行数:26,代码来源:BeanContextSupportTest.java

示例2: testSerialization_Compatibility

import java.beans.beancontext.BeanContextSupport; //导入方法依赖的package包/类
public void testSerialization_Compatibility() throws Exception {
    MockBeanContextDelegateS mock = new MockBeanContextDelegateS("main id");
    BeanContextSupport support = mock.support;
    support.addBeanContextMembershipListener(new MockBeanContextMembershipListener());
    support.addBeanContextMembershipListener(new MockBeanContextMembershipListenerS("l2"));
    support.addBeanContextMembershipListener(new MockBeanContextMembershipListenerS("l3"));
    support.addBeanContextMembershipListener(new MockBeanContextMembershipListener());
    support.add("abcd");
    support.add(new MockBeanContextChild());
    support.add(new MockBeanContextChildS("a child"));
    support.add(new MockBeanContextChild());
    support.add("1234");

    MockBeanContextDelegateS serMock = (MockBeanContextDelegateS) SerializationTester
            .readObject(mock, "serialization/java/beans/beancontext/BeanContextSupport.ser");
    assertEquals(mock.id, serMock.id);
    assertSame(mock, mock.support.beanContextChildPeer);
    assertSame(serMock, serMock.support.beanContextChildPeer);
    assertEqualsSerially(mock.support, serMock.support);
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:21,代码来源:BeanContextSupportTest.java

示例3: testSize

import java.beans.beancontext.BeanContextSupport; //导入方法依赖的package包/类
/**
 * @see java.beans.beancontext.BeanContextSupport#size()
 */
public Result testSize() throws Exception {

    // The BeanContext object to be checked by the test
    BeanContextSupport contextForSize = new BeanContextSupport(); 

    // Components that should be added to context
    BeanContextSupport subContext = new BeanContextSupport();                                                                  
    BeanWithBeanContext beanWithContext = new BeanWithBeanContext();        
    BeanContextChildSupport bean = new BeanContextChildSupport();
    
    // Adding the components
    contextForSize.add(subContext);
    contextForSize.add(beanWithContext);
    contextForSize.add(bean);
    
    // It's verified that the BeanContext contains 4 components
    if (contextForSize.size() == 4) {
        return passed();
    } else {
        return failed("testSize() - failed ");
    }
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:26,代码来源:TestSizeBeanContext.java

示例4: testIsContextEmpty

import java.beans.beancontext.BeanContextSupport; //导入方法依赖的package包/类
/**
 * @see java.beans.beancontext.BeanContextSupport#isEmpty()
 */
public Result testIsContextEmpty() throws Exception {

    // The BeanContext object to be checked by the test
    BeanContextSupport context = new BeanContextSupport(); 

    // Components that should be added to context
    BeanContextSupport subContext = new BeanContextSupport();                                                                  
    BeanWithBeanContext beanWithContext = new BeanWithBeanContext();        
    BeanContextChildSupport bean = new BeanContextChildSupport();
    
    // Adding the components
    context.add(subContext);
    context.add(beanWithContext);
    context.add(bean);
    
    // It's verified that the BeanContext isn't empty
    if (!context.isEmpty()) {
        return passed();
    } else {
        return failed("testIsContextEmpty() - failed ");
    }
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:26,代码来源:TestSizeBeanContext.java

示例5: testNullPointerException1

import java.beans.beancontext.BeanContextSupport; //导入方法依赖的package包/类
/**
 * @see java.beans.beancontext.BeanContextMembershipEvent
 */
public Result testNullPointerException1() throws Exception {

    context = new BeanContextSupport();
    
    bean = new BeanContextChildSupport();

    // Adding the component
    context.add(bean);

    Object[] array = null;
    try {
        event = new BeanContextMembershipEvent(bean.getBeanContext(), array);
    } catch (java.lang.NullPointerException e) {
        return passed();
    }
    return failed("testNullPointerException1");
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:21,代码来源:TestBeanContextMembershipEvent.java

示例6: testNullPointerException2

import java.beans.beancontext.BeanContextSupport; //导入方法依赖的package包/类
/**
 * @see java.beans.beancontext.BeanContextMembershipEvent
 */
public Result testNullPointerException2() throws Exception {

    context = new BeanContextSupport();
    bean = new BeanContextChildSupport();

    // Adding the component
    context.add(bean);

    Collection[] array = null;
    try {
        event = new BeanContextMembershipEvent(bean.getBeanContext(), array);
    } catch (java.lang.NullPointerException e) {

        return passed();
    }
    return failed("testNullPointerException2");
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:21,代码来源:TestBeanContextMembershipEvent.java

示例7: testContainsBeanContextMembershipEvent

import java.beans.beancontext.BeanContextSupport; //导入方法依赖的package包/类
/**
 * @see java.beans.beancontext.BeanContextMembershipEvent#contains()
 */
public Result testContainsBeanContextMembershipEvent() throws Exception {

    context = new BeanContextSupport();
    bean = new BeanContextChildSupport();
    sBean = new ServiceBean();

    // Adding the component
    context.add(bean);
    context.add(sBean);

    event = new BeanContextMembershipEvent(bean.getBeanContext(), context
            .toArray());

    if ((event.contains(sBean)) || !(event.contains(context)))
        return passed();
    else
        return failed("testContainsBeanContextMembershipEvent");
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:22,代码来源:TestBeanContextMembershipEvent.java

示例8: testIteratorBeanContextMembershipEvent

import java.beans.beancontext.BeanContextSupport; //导入方法依赖的package包/类
/**
 * @see java.beans.beancontext.BeanContextSupport#iterator()
 */
public Result testIteratorBeanContextMembershipEvent() throws Exception {

    context = new BeanContextSupport();
    bean = new BeanContextChildSupport();
    sBean = new ServiceBean();

    // Adding the component
    context.add(bean);
    context.add(sBean);

    event = new BeanContextMembershipEvent(bean.getBeanContext(), context
            .toArray());

    if ((event.iterator() instanceof java.util.Iterator))
        return passed();
    else
        return failed("testIteratorBeanContextMembershipEvent");
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:22,代码来源:TestBeanContextMembershipEvent.java

示例9: testSizeBeanContextMembershipEvent

import java.beans.beancontext.BeanContextSupport; //导入方法依赖的package包/类
/**
 * @see java.beans.beancontext.BeanContextSupport#size()
 */
public Result testSizeBeanContextMembershipEvent() throws Exception {

    context = new BeanContextSupport();
    bean = new BeanContextChildSupport();
    sBean = new ServiceBean();

    // Adding the component
    context.add(bean);
    context.add(sBean);

    event = new BeanContextMembershipEvent(bean.getBeanContext(), context
            .toArray());
    // System.out.println(event.size());
    if (event.size() == 2)
        return passed();
    else
        return failed("testSizeBeanContextMembershipEvent");
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:22,代码来源:TestBeanContextMembershipEvent.java

示例10: main

import java.beans.beancontext.BeanContextSupport; //导入方法依赖的package包/类
public static void main(String[] args) {
    BeanContextSupport context = new BeanContextSupport(); // The BeanContext
    BeanContextChildSupport bean = new BeanContextChildSupport(); // The JavaBean
    // add the bean to the context
    context.add(bean);
    try {
        context.getResourceAsStream("Readme.txt", bean);
    }
    catch (Exception exception) {
        throw new Error("unexpected exception", exception);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:13,代码来源:Test4233980.java

示例11: testGetResource

import java.beans.beancontext.BeanContextSupport; //导入方法依赖的package包/类
public void testGetResource() {
    MockBeanContextSupport support = new MockBeanContextSupport();
    MockBeanContextChild child = new MockBeanContextChild();
    support.add(child);

    final String RESOURCE_NAME = "org/apache/harmony/beans/tests/support/beancontext/mock/mockdata.txt";
    URL url = support.getResource(RESOURCE_NAME, child);
    assertTrue(url.toString().endsWith(RESOURCE_NAME));
    
    BeanContextSupport beanContextSupport = new BeanContextSupport();
    beanContextSupport.add(child);
    url = beanContextSupport.getResource(RESOURCE_NAME, child);
    assertTrue(url.toString().endsWith(RESOURCE_NAME));
}
 
开发者ID:shannah,项目名称:cn1,代码行数:15,代码来源:BeanContextSupportTest.java

示例12: test_readChildren_NPE_scenario1

import java.beans.beancontext.BeanContextSupport; //导入方法依赖的package包/类
public void test_readChildren_NPE_scenario1() throws Exception {
    BeanContextSupport beanContextSupport = new BeanContextSupport();
    beanContextSupport.add(beanContextSupport);
    assertEquals(1, beanContextSupport.size());
    assertFalse(beanContextSupport.isSerializing());
    try {
        beanContextSupport.readChildren((ObjectInputStream) null);
        fail("should throw NullPointerException");
    } catch (NullPointerException e) {
        // Expected
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:13,代码来源:BeanContextSupportTest.java

示例13: test_readChildren_NPE_scenario4

import java.beans.beancontext.BeanContextSupport; //导入方法依赖的package包/类
public void test_readChildren_NPE_scenario4() throws Exception {
    BeanContextSupport beanContextSupport = new BeanContextSupport();
    beanContextSupport.add("Serializable");
    try {
        beanContextSupport.readChildren((ObjectInputStream) null);
        fail("should throw NullPointerException");
    } catch (NullPointerException e) {
        // Expected
    }
    beanContextSupport.remove("Serializable");
    beanContextSupport.readChildren((ObjectInputStream) null);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:13,代码来源:BeanContextSupportTest.java

示例14: testSize

import java.beans.beancontext.BeanContextSupport; //导入方法依赖的package包/类
public void testSize() {
    @SuppressWarnings("serial")
    class TestBean extends Component implements BeanContextProxy {
        public BeanContextChildSupport childSupport = new BeanContextChildSupport();

        public BeanContextChild getBeanContextProxy() {
            return childSupport;
        }
    }
    
    // Regression test for HARMONY-1829
    BeanContextSupport obj = new BeanContextSupport();
    obj.add(new TestBean());
    assertEquals(2, obj.size());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:16,代码来源:BeanContextSupportTest.java

示例15: testSerialization_Peer

import java.beans.beancontext.BeanContextSupport; //导入方法依赖的package包/类
public void testSerialization_Peer() throws IOException,
        ClassNotFoundException {
    MockBeanContextDelegateS mock = new MockBeanContextDelegateS("main id");
    BeanContextSupport support = mock.support;
    support
            .addBeanContextMembershipListener(new MockBeanContextMembershipListener());
    support
            .addBeanContextMembershipListener(new MockBeanContextMembershipListenerS(
                    "l2"));
    support
            .addBeanContextMembershipListener(new MockBeanContextMembershipListenerS(
                    "l3"));
    support
            .addBeanContextMembershipListener(new MockBeanContextMembershipListener());
    support.add("abcd");
    support.add(new MockBeanContextChild());
    support.add(new MockBeanContextChildS("a child"));
    support.add(new MockBeanContextChild());
    support.add("1234");
    support.add(new MockBeanContextProxyS("proxy",
            new MockBeanContextChildS("b child")));

    MockBeanContextDelegateS serMock = (MockBeanContextDelegateS) SerializationTester
            .getDeserilizedObject(mock);
    assertEquals(mock.id, serMock.id);
    assertSame(mock, mock.support.beanContextChildPeer);
    assertSame(serMock, serMock.support.beanContextChildPeer);
    assertEqualsSerially(mock.support, serMock.support);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:30,代码来源:BeanContextSupportTest.java


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