Java 类java.beans.beancontext.BeanContextServicesSupport 实例源码

项目:cn1    文件:BeanContextEventTest.java   
public void testSerialization() throws Exception {
    final BeanContextServicesSupport ctx = new BeanContextServicesSupport(
            null, Locale.FRANCE, false, false);
    final BeanContextServicesSupport ctx2 = new BeanContextServicesSupport(
            ctx, Locale.ITALY, true, true);
    BeanContextEvent event = new MockBeanContextEvent(ctx2);
    event.setPropagatedFrom(ctx);
    SerializationTest.verifySelf(event, new SerializableAssert(){
        public void assertDeserialized(Serializable arg0, Serializable arg1) {
            BeanContextEvent e1 = (BeanContextEvent)arg0;
            BeanContextEvent e2 = (BeanContextEvent)arg1;
            assertNull((BeanContextServicesSupport)e2.getSource());
            assertNotNull((BeanContextServicesSupport)e1.getSource());
            assertEqualsSerially((BeanContextServicesSupport)e1.getPropagatedFrom(), (BeanContextServicesSupport)e2.getPropagatedFrom());
            assertEqualsSerially(ctx, (BeanContextServicesSupport)e2.getPropagatedFrom());
        }
    });
}
项目:cn1    文件:BeanContextEventTest.java   
public void testSerializationComptibility() throws Exception {
    final BeanContextServicesSupport ctx = new BeanContextServicesSupport(
            null, Locale.ITALY, true, true);
    final BeanContextServicesSupport ctx2 = new BeanContextServicesSupport(
            null, Locale.CHINA, true, true);

    BeanContextEvent event = new MockBeanContextEvent(ctx);
    event.setPropagatedFrom(ctx2);
    SerializationTest.verifyGolden(this, event, new SerializableAssert(){
        public void assertDeserialized(Serializable arg0, Serializable arg1) {
            BeanContextEvent e1 = (BeanContextEvent)arg0;
            BeanContextEvent e2 = (BeanContextEvent)arg1;
            assertNull((BeanContextServicesSupport)e2.getSource());
            assertNotNull((BeanContextServicesSupport)e1.getSource());
            assertEqualsSerially((BeanContextServicesSupport)e1.getPropagatedFrom(), (BeanContextServicesSupport)e2.getPropagatedFrom());
            assertEqualsSerially(ctx2, (BeanContextServicesSupport)e2.getPropagatedFrom());
        }
    });
}
项目:cn1    文件:BeanContextServicesSupportTest.java   
public void testSerialization() throws IOException, ClassNotFoundException {
    BeanContextServicesSupport support = new BeanContextServicesSupport(
            null, Locale.ITALY, true, true);
    support
            .addBeanContextServicesListener(new MockBeanContextServicesListener());
    support
            .addBeanContextServicesListener(new MockBeanContextServicesListenerS(
                    "l2"));
    support
            .addBeanContextServicesListener(new MockBeanContextServicesListenerS(
                    "l3"));
    support
            .addBeanContextServicesListener(new MockBeanContextServicesListener());
    support.addService(Collection.class,
            new MockBeanContextServiceProvider());
    support.addService(List.class,
            new MockBeanContextServiceProviderS("p1"));
    support
            .addService(Set.class,
                    new MockBeanContextServiceProviderS("p2"));
    support.addService(Map.class, new MockBeanContextServiceProvider());

    assertEqualsSerially(support,
            (BeanContextServicesSupport) SerializationTester
                    .getDeserilizedObject(support));
}
项目:cn1    文件:BeanContextServicesSupportTest.java   
public void test_serviceRevoked_LBeanContextServiceRevokedEvent() {
    BeanContextServicesSupport support = new BeanContextServicesSupport();

    support.add(new MySupport());
    support.addBeanContextServicesListener(new MyListener());
    Class c = Object.class;

    support.addService(c, new MyProvider());

    BeanContextServiceRevokedEvent revokeEvent = new BeanContextServiceRevokedEvent(
            support, c, false);

    support.serviceRevoked(revokeEvent);
       assertEquals(0, serviceRevoked);
       assertEquals(2, serviceAvailable);

}
项目:cn1    文件:BeanContextServicesSupportTest.java   
public void test_serviceAvailable_LBeanContextServiceRevokedEvent() {
    BeanContextServicesSupport support = new BeanContextServicesSupport();

    support.add(new MySupport());
    support.addBeanContextServicesListener(new MyListener());
    Class c = Object.class;

    support.addService(c, new MyProvider());

    BeanContextServiceAvailableEvent availableEvent = new BeanContextServiceAvailableEvent(
            support, c);
    support.serviceAvailable(availableEvent);
       assertEquals(0, serviceRevoked);
       assertEquals(2, serviceAvailable);

}
项目:freeVM    文件:BeanContextServicesSupportTest.java   
public void testSerialization() throws IOException, ClassNotFoundException {
    BeanContextServicesSupport support = new BeanContextServicesSupport(
            null, Locale.ITALY, true, true);
    support
            .addBeanContextServicesListener(new MockBeanContextServicesListener());
    support
            .addBeanContextServicesListener(new MockBeanContextServicesListenerS(
                    "l2"));
    support
            .addBeanContextServicesListener(new MockBeanContextServicesListenerS(
                    "l3"));
    support
            .addBeanContextServicesListener(new MockBeanContextServicesListener());
    support.addService(Collection.class,
            new MockBeanContextServiceProvider());
    support.addService(List.class,
            new MockBeanContextServiceProviderS("p1"));
    support
            .addService(Set.class,
                    new MockBeanContextServiceProviderS("p2"));
    support.addService(Map.class, new MockBeanContextServiceProvider());

    assertEqualsSerially(support,
            (BeanContextServicesSupport) SerializationTester
                    .getDeserilizedObject(support));
}
项目:freeVM    文件:BeanContextEventTest.java   
public void testSerialization() throws Exception {
    final BeanContextServicesSupport ctx = new BeanContextServicesSupport(
            null, Locale.FRANCE, false, false);
    final BeanContextServicesSupport ctx2 = new BeanContextServicesSupport(
            ctx, Locale.ITALY, true, true);
    BeanContextEvent event = new MockBeanContextEvent(ctx2);
    event.setPropagatedFrom(ctx);
    SerializationTest.verifySelf(event, new SerializableAssert(){
        public void assertDeserialized(Serializable arg0, Serializable arg1) {
            BeanContextEvent e1 = (BeanContextEvent)arg0;
            BeanContextEvent e2 = (BeanContextEvent)arg1;
            assertNull((BeanContextServicesSupport)e2.getSource());
            assertNotNull((BeanContextServicesSupport)e1.getSource());
            assertEqualsSerially((BeanContextServicesSupport)e1.getPropagatedFrom(), (BeanContextServicesSupport)e2.getPropagatedFrom());
            assertEqualsSerially(ctx, (BeanContextServicesSupport)e2.getPropagatedFrom());
        }
    });
}
项目:freeVM    文件:BeanContextEventTest.java   
public void testSerializationComptibility() throws Exception {
    final BeanContextServicesSupport ctx = new BeanContextServicesSupport(
            null, Locale.ITALY, true, true);
    final BeanContextServicesSupport ctx2 = new BeanContextServicesSupport(
            null, Locale.CHINA, true, true);

    BeanContextEvent event = new MockBeanContextEvent(ctx);
    event.setPropagatedFrom(ctx2);
    SerializationTest.verifyGolden(this, event, new SerializableAssert(){
        public void assertDeserialized(Serializable arg0, Serializable arg1) {
            BeanContextEvent e1 = (BeanContextEvent)arg0;
            BeanContextEvent e2 = (BeanContextEvent)arg1;
            assertNull((BeanContextServicesSupport)e2.getSource());
            assertNotNull((BeanContextServicesSupport)e1.getSource());
            assertEqualsSerially((BeanContextServicesSupport)e1.getPropagatedFrom(), (BeanContextServicesSupport)e2.getPropagatedFrom());
            assertEqualsSerially(ctx2, (BeanContextServicesSupport)e2.getPropagatedFrom());
        }
    });
}
项目:freeVM    文件:BeanContextServicesSupportTest.java   
public void testSerialization() throws IOException, ClassNotFoundException {
    BeanContextServicesSupport support = new BeanContextServicesSupport(
            null, Locale.ITALY, true, true);
    support
            .addBeanContextServicesListener(new MockBeanContextServicesListener());
    support
            .addBeanContextServicesListener(new MockBeanContextServicesListenerS(
                    "l2"));
    support
            .addBeanContextServicesListener(new MockBeanContextServicesListenerS(
                    "l3"));
    support
            .addBeanContextServicesListener(new MockBeanContextServicesListener());
    support.addService(Collection.class,
            new MockBeanContextServiceProvider());
    support.addService(List.class,
            new MockBeanContextServiceProviderS("p1"));
    support
            .addService(Set.class,
                    new MockBeanContextServiceProviderS("p2"));
    support.addService(Map.class, new MockBeanContextServiceProvider());

    assertEqualsSerially(support,
            (BeanContextServicesSupport) SerializationTester
                    .getDeserilizedObject(support));
}
项目:freeVM    文件:BeanContextServicesSupportTest.java   
public void test_serviceRevoked_LBeanContextServiceRevokedEvent() {
    BeanContextServicesSupport support = new BeanContextServicesSupport();

    support.add(new MySupport());
    support.addBeanContextServicesListener(new MyListener());
    Class c = Object.class;

    support.addService(c, new MyProvider());

    BeanContextServiceRevokedEvent revokeEvent = new BeanContextServiceRevokedEvent(
            support, c, false);

    support.serviceRevoked(revokeEvent);
       assertEquals(0, serviceRevoked);
       assertEquals(2, serviceAvailable);

}
项目:freeVM    文件:BeanContextServicesSupportTest.java   
public void test_serviceAvailable_LBeanContextServiceRevokedEvent() {
    BeanContextServicesSupport support = new BeanContextServicesSupport();

    support.add(new MySupport());
    support.addBeanContextServicesListener(new MyListener());
    Class c = Object.class;

    support.addService(c, new MyProvider());

    BeanContextServiceAvailableEvent availableEvent = new BeanContextServiceAvailableEvent(
            support, c);
    support.serviceAvailable(availableEvent);
       assertEquals(0, serviceRevoked);
       assertEquals(2, serviceAvailable);

}
项目:freeVM    文件:TestBeanContextServicesSupport.java   
/**
 * @see java.beans.beancontext.BeanContextServicesSupport#getBeanContextServicesPeer()
 */
public Result testGetBeanContextServicesPeer() throws Exception {

    context = new BeanContextServicesSupport();

    serviceBean = new ServiceBean();

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

    // Add service to the context
    if ((context.getBeanContextServicesPeer() instanceof BeanContextServicesSupport))

        return passed();
    else
        return failed("method testGetBeanContextServicesPeer");
}
项目:freeVM    文件:TestBeanContextServicesSupport.java   
/**
 * @see java.beans.beancontext.BeanContextServicesSupport#getCurrentServiceSelectors()
 */
public Result testGetCurrentServiceSelectors() throws Exception {

    context = new BeanContextServicesSupport();

    serviceBean = new ServiceBean();

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

    // Listen for new services
    context.addBeanContextServicesListener(serviceBean);

    TestServiceProvider provider = new TestServiceProvider();

    // Add service to the context
    context.addService(TestCounter.class, provider);

    if ((context.getCurrentServiceSelectors(TestCounter.class) instanceof Iterator))
        return passed();
    else
        return failed("method testGetCurrentServiceSelectors");
}
项目:freeVM    文件:TestBeanContextServicesSupport.java   
/**
 * @see java.beans.beancontext.BeanContextServicesSupport#getService()
 */
public Result testGetService() throws Exception {

    context = new BeanContextServicesSupport();

    serviceBean = new ServiceBean();

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

    // Listen for new services
    context.addBeanContextServicesListener(serviceBean);
    TestServiceProvider provider = new TestServiceProvider();

    // Add service to the context
    context.addService(TestCounter.class, provider);

    if ((serviceBean.service instanceof TestCounter))
        return passed();
    else
        return failed("method testGetService");
}
项目:freeVM    文件:TestBeanContextServicesSupportException.java   
/**
 * @see java.beans.beancontext.BeanContextServicesSupport#addBeanContextServicesListener()
 */
public Result testAddBeanContextServicesListenerException()
        throws Exception {

    context = new BeanContextServicesSupport();

    serviceBean = null;

    try {
        // Listen for new service
        context.addBeanContextServicesListener(serviceBean);
    } catch (NullPointerException e) {

                return passed();
    }
    return failed("testAddBeanContextServicesListenerException");
}
项目:freeVM    文件:TestBeanContextServicesSupportException.java   
/**
 * @see java.beans.beancontext.BeanContextServicesSupport#getService()
 */
public Result testGetServiceException()    throws Exception {

    BeanContextChild child = null;
    Object requestor = null;
    Class serviceClass = null;
    Object serviceSelector = null;
    BeanContextServiceRevokedListener bcsrl = null;
    BeanContextServicesSupport context = new BeanContextServicesSupport();
    serviceBean = null;

    try {
        context.getService(child, requestor ,serviceClass,serviceSelector,bcsrl);
    } catch (NullPointerException e) {

        return passed();
    }
    return failed("testGetServiceException");
}
项目:freeVM    文件:TestBeanContextServicesSupportException.java   
/**
 * @see java.beans.beancontext.BeanContextServicesSupport#releaseService()
 */
public Result testReleaseServiceException()    throws Exception {

    BeanContextChild child = null;
    Object requestor = null;
    Object service = null;
    BeanContextServicesSupport context = new BeanContextServicesSupport();
    serviceBean = null;

    try {
        context.releaseService(child, requestor ,service);
    } catch (NullPointerException e) {

        return passed();
    }
    return failed("testGetServiceException");
}
项目:freeVM    文件:TestBeanContextServiceAvailableEvent.java   
/**
 * @see java.beans.beancontext.BeanContextServiceAvailableEvent#getCurrentServiceSelectors()
 * @see java.beans.beancontext.BeanContextServicesSupport#hasService()
 */
public Result testGetCurrentServiceSelectors() throws Exception {

    context = new BeanContextServicesSupport();

    serviceBean = new ServiceBean();

    // Add service to the context
    context.add(serviceBean);        

    // Listen for new services
    context.addBeanContextServicesListener(serviceBean);

    TestServiceProvider provider = new TestServiceProvider();

    // Add service to the context
    context.addService(TestCounter.class, provider);

    if ((context.hasService(TestCounter.class))
            || (serviceBean.bcsae.getCurrentServiceSelectors() instanceof java.util.Iterator))
        return passed();
    else
        return failed("method getCurrentServiceSelectors");
}
项目:jdk8u-jdk    文件:Test4328406.java   
public static void main(String[] args) {
    for (int i = 0; i < 10; i++) {
        BeanContextServices container = new BeanContextServicesSupport();
        BeanContextChild ms1 = new MyService1();
        BeanContextServices ms2 = new MyService2();
        BeanContextChild mb = new MyBean();

        container.add(ms1);
        container.add(ms2);
        ms2.add(mb);

        // exception thrown here
        container.remove(ms2);
    }
}
项目:jdk8u-jdk    文件:Test4328406.java   
protected void initializeBeanContextResources() {
    super.initializeBeanContextResources();

    BeanContextServicesSupport bcs = (BeanContextServicesSupport) getBeanContext();
    try {
        bcs.getService(this, this, MyService1.class, null, this);
    }
    catch (Exception exception) {
        exception.printStackTrace();
    }
    bcs.addService(this.getClass(), this);
}
项目:openjdk-jdk10    文件:Test4328406.java   
public static void main(String[] args) {
    for (int i = 0; i < 10; i++) {
        BeanContextServices container = new BeanContextServicesSupport();
        BeanContextChild ms1 = new MyService1();
        BeanContextServices ms2 = new MyService2();
        BeanContextChild mb = new MyBean();

        container.add(ms1);
        container.add(ms2);
        ms2.add(mb);

        // exception thrown here
        container.remove(ms2);
    }
}
项目:openjdk-jdk10    文件:Test4328406.java   
protected void initializeBeanContextResources() {
    super.initializeBeanContextResources();

    BeanContextServicesSupport bcs = (BeanContextServicesSupport) getBeanContext();
    try {
        bcs.getService(this, this, MyService1.class, null, this);
    }
    catch (Exception exception) {
        exception.printStackTrace();
    }
    bcs.addService(this.getClass(), this);
}
项目:openjdk9    文件:Test4328406.java   
public static void main(String[] args) {
    for (int i = 0; i < 10; i++) {
        BeanContextServices container = new BeanContextServicesSupport();
        BeanContextChild ms1 = new MyService1();
        BeanContextServices ms2 = new MyService2();
        BeanContextChild mb = new MyBean();

        container.add(ms1);
        container.add(ms2);
        ms2.add(mb);

        // exception thrown here
        container.remove(ms2);
    }
}
项目:openjdk9    文件:Test4328406.java   
protected void initializeBeanContextResources() {
    super.initializeBeanContextResources();

    BeanContextServicesSupport bcs = (BeanContextServicesSupport) getBeanContext();
    try {
        bcs.getService(this, this, MyService1.class, null, this);
    }
    catch (Exception exception) {
        exception.printStackTrace();
    }
    bcs.addService(this.getClass(), this);
}
项目:jdk8u_jdk    文件:Test4328406.java   
public static void main(String[] args) {
    for (int i = 0; i < 10; i++) {
        BeanContextServices container = new BeanContextServicesSupport();
        BeanContextChild ms1 = new MyService1();
        BeanContextServices ms2 = new MyService2();
        BeanContextChild mb = new MyBean();

        container.add(ms1);
        container.add(ms2);
        ms2.add(mb);

        // exception thrown here
        container.remove(ms2);
    }
}
项目:jdk8u_jdk    文件:Test4328406.java   
protected void initializeBeanContextResources() {
    super.initializeBeanContextResources();

    BeanContextServicesSupport bcs = (BeanContextServicesSupport) getBeanContext();
    try {
        bcs.getService(this, this, MyService1.class, null, this);
    }
    catch (Exception exception) {
        exception.printStackTrace();
    }
    bcs.addService(this.getClass(), this);
}
项目:lookaside_java-1.8.0-openjdk    文件:Test4328406.java   
public static void main(String[] args) {
    for (int i = 0; i < 10; i++) {
        BeanContextServices container = new BeanContextServicesSupport();
        BeanContextChild ms1 = new MyService1();
        BeanContextServices ms2 = new MyService2();
        BeanContextChild mb = new MyBean();

        container.add(ms1);
        container.add(ms2);
        ms2.add(mb);

        // exception thrown here
        container.remove(ms2);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:Test4328406.java   
protected void initializeBeanContextResources() {
    super.initializeBeanContextResources();

    BeanContextServicesSupport bcs = (BeanContextServicesSupport) getBeanContext();
    try {
        bcs.getService(this, this, MyService1.class, null, this);
    }
    catch (Exception exception) {
        exception.printStackTrace();
    }
    bcs.addService(this.getClass(), this);
}
项目:infobip-open-jdk-8    文件:Test4328406.java   
public static void main(String[] args) {
    for (int i = 0; i < 10; i++) {
        BeanContextServices container = new BeanContextServicesSupport();
        BeanContextChild ms1 = new MyService1();
        BeanContextServices ms2 = new MyService2();
        BeanContextChild mb = new MyBean();

        container.add(ms1);
        container.add(ms2);
        ms2.add(mb);

        // exception thrown here
        container.remove(ms2);
    }
}
项目:infobip-open-jdk-8    文件:Test4328406.java   
protected void initializeBeanContextResources() {
    super.initializeBeanContextResources();

    BeanContextServicesSupport bcs = (BeanContextServicesSupport) getBeanContext();
    try {
        bcs.getService(this, this, MyService1.class, null, this);
    }
    catch (Exception exception) {
        exception.printStackTrace();
    }
    bcs.addService(this.getClass(), this);
}
项目:jdk8u-dev-jdk    文件:Test4328406.java   
public static void main(String[] args) {
    for (int i = 0; i < 10; i++) {
        BeanContextServices container = new BeanContextServicesSupport();
        BeanContextChild ms1 = new MyService1();
        BeanContextServices ms2 = new MyService2();
        BeanContextChild mb = new MyBean();

        container.add(ms1);
        container.add(ms2);
        ms2.add(mb);

        // exception thrown here
        container.remove(ms2);
    }
}
项目:jdk8u-dev-jdk    文件:Test4328406.java   
protected void initializeBeanContextResources() {
    super.initializeBeanContextResources();

    BeanContextServicesSupport bcs = (BeanContextServicesSupport) getBeanContext();
    try {
        bcs.getService(this, this, MyService1.class, null, this);
    }
    catch (Exception exception) {
        exception.printStackTrace();
    }
    bcs.addService(this.getClass(), this);
}
项目:jdk7-jdk    文件:Test4328406.java   
public static void main(String[] args) {
    for (int i = 0; i < 10; i++) {
        BeanContextServices container = new BeanContextServicesSupport();
        BeanContextChild ms1 = new MyService1();
        BeanContextServices ms2 = new MyService2();
        BeanContextChild mb = new MyBean();

        container.add(ms1);
        container.add(ms2);
        ms2.add(mb);

        // exception thrown here
        container.remove(ms2);
    }
}
项目:jdk7-jdk    文件:Test4328406.java   
protected void initializeBeanContextResources() {
    super.initializeBeanContextResources();

    BeanContextServicesSupport bcs = (BeanContextServicesSupport) getBeanContext();
    try {
        bcs.getService(this, this, MyService1.class, null, this);
    }
    catch (Exception exception) {
        exception.printStackTrace();
    }
    bcs.addService(this.getClass(), this);
}
项目:openjdk-source-code-learn    文件:Test4328406.java   
public static void main(String[] args) {
    for (int i = 0; i < 10; i++) {
        BeanContextServices container = new BeanContextServicesSupport();
        BeanContextChild ms1 = new MyService1();
        BeanContextServices ms2 = new MyService2();
        BeanContextChild mb = new MyBean();

        container.add(ms1);
        container.add(ms2);
        ms2.add(mb);

        // exception thrown here
        container.remove(ms2);
    }
}
项目:openjdk-source-code-learn    文件:Test4328406.java   
protected void initializeBeanContextResources() {
    super.initializeBeanContextResources();

    BeanContextServicesSupport bcs = (BeanContextServicesSupport) getBeanContext();
    try {
        bcs.getService(this, this, MyService1.class, null, this);
    }
    catch (Exception exception) {
        exception.printStackTrace();
    }
    bcs.addService(this.getClass(), this);
}
项目:OLD-OpenJDK8    文件:Test4328406.java   
public static void main(String[] args) {
    for (int i = 0; i < 10; i++) {
        BeanContextServices container = new BeanContextServicesSupport();
        BeanContextChild ms1 = new MyService1();
        BeanContextServices ms2 = new MyService2();
        BeanContextChild mb = new MyBean();

        container.add(ms1);
        container.add(ms2);
        ms2.add(mb);

        // exception thrown here
        container.remove(ms2);
    }
}
项目:OLD-OpenJDK8    文件:Test4328406.java   
protected void initializeBeanContextResources() {
    super.initializeBeanContextResources();

    BeanContextServicesSupport bcs = (BeanContextServicesSupport) getBeanContext();
    try {
        bcs.getService(this, this, MyService1.class, null, this);
    }
    catch (Exception exception) {
        exception.printStackTrace();
    }
    bcs.addService(this.getClass(), this);
}
项目:cn1    文件:BeanContextServicesSupport2Test.java   
public void test() {
    BeanContextServiceProvider bcsp = new BCSP();
    BCSS serviceSupport = new BCSS(new BeanContextServicesSupport());
    assertTrue("Expected first addService to return true", serviceSupport
            .addService(Boolean.TYPE, bcsp, false));
    assertFalse("Expected second addService to return false", serviceSupport
            .addService(Boolean.TYPE, bcsp, false));
}
项目:cn1    文件:BeanContextServicesSupportTest.java   
public void testServiceRevoked() {
    MockChildBeanContextServicesSupport mockChildBeanContextServicesSupport = new MockChildBeanContextServicesSupport();
    BeanContextServicesSupport beanContextServicesSupport = new BeanContextServicesSupport();
    beanContextServicesSupport.add(mockChildBeanContextServicesSupport);
    BeanContextServiceRevokedEvent beanContextServiceRevokedEvent = new BeanContextServiceRevokedEvent(new BeanContextServicesSupport(), Collection.class,false);
    beanContextServicesSupport.serviceRevoked(beanContextServiceRevokedEvent);
    assertTrue(mockChildBeanContextServicesSupport.revokeCalled);        
}