java类java.beans.beancontext.BeanContextServiceRevokedEvent的实例源码

BeanContextServiceRevokedEventTest.java 文件源码 项目:cn1 阅读 28 收藏 0 点赞 0 评论 0
private void assertEqualsSerially(BeanContextServiceRevokedEvent orig,
        BeanContextServiceRevokedEvent ser) {
    assertNull(ser.getSource());

    // check propagatedFrom
    if (orig.getPropagatedFrom() instanceof Serializable) {
        BeanContext origFrom = orig.getPropagatedFrom();
        BeanContext serFrom = ser.getPropagatedFrom();
        assertEquals(origFrom.getClass(), serFrom.getClass());
        if (origFrom instanceof MockBeanContextDelegateS) {
            assertEquals(((MockBeanContextDelegateS) origFrom).id,
                    ((MockBeanContextDelegateS) serFrom).id);
        }
    }

    // check serviceClass
    assertEquals(orig.getServiceClass(), ser.getServiceClass());

    // check invalidateRefs
    assertEquals(orig.isCurrentServiceInvalidNow(), ser
            .isCurrentServiceInvalidNow());
}
BeanContextServicesSupportTest.java 文件源码 项目:cn1 阅读 26 收藏 0 点赞 0 评论 0
public void testFireServiceRevokedBeanContextServiceRevokedEvent() {
    MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
    MockBeanContextServicesSupport childSupport = new MockBeanContextServicesSupport();
    support.add(childSupport);
    MockBeanContextServicesListener l1 = new MockBeanContextServicesListener();
    MockBeanContextServicesListener l2 = new MockBeanContextServicesListener();
    support.addBeanContextServicesListener(l1);
    childSupport.addBeanContextServicesListener(l2);
    support.records.assertRecord("initialize", null);
    childSupport.records.assertRecord("initialize", null);

    BeanContextServiceRevokedEvent evt = new BeanContextServiceRevokedEvent(
            support, Collection.class, false);
    support.publicFireServiceRevoked(evt);

    support.records.assertEndOfRecords();
    childSupport.records.assertEndOfRecords();
    assertSame(evt, l1.lastRevokedEvent);
    assertNull(l2.lastRevokedEvent);
}
BeanContextServicesSupportTest.java 文件源码 项目:cn1 阅读 31 收藏 0 点赞 0 评论 0
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);

}
BeanContextServiceRevokedEventTest.java 文件源码 项目:freeVM 阅读 19 收藏 0 点赞 0 评论 0
private void assertEqualsSerially(BeanContextServiceRevokedEvent orig,
        BeanContextServiceRevokedEvent ser) {
    assertNull(ser.getSource());

    // check propagatedFrom
    if (orig.getPropagatedFrom() instanceof Serializable) {
        BeanContext origFrom = orig.getPropagatedFrom();
        BeanContext serFrom = ser.getPropagatedFrom();
        assertEquals(origFrom.getClass(), serFrom.getClass());
        if (origFrom instanceof MockBeanContextDelegateS) {
            assertEquals(((MockBeanContextDelegateS) origFrom).id,
                    ((MockBeanContextDelegateS) serFrom).id);
        }
    }

    // check serviceClass
    assertEquals(orig.getServiceClass(), ser.getServiceClass());

    // check invalidateRefs
    assertEquals(orig.isCurrentServiceInvalidNow(), ser
            .isCurrentServiceInvalidNow());
}
BeanContextServicesSupportTest.java 文件源码 项目:freeVM 阅读 26 收藏 0 点赞 0 评论 0
public void testFireServiceRevokedBeanContextServiceRevokedEvent() {
    MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
    MockBeanContextServicesSupport childSupport = new MockBeanContextServicesSupport();
    support.add(childSupport);
    MockBeanContextServicesListener l1 = new MockBeanContextServicesListener();
    MockBeanContextServicesListener l2 = new MockBeanContextServicesListener();
    support.addBeanContextServicesListener(l1);
    childSupport.addBeanContextServicesListener(l2);
    support.records.assertRecord("initialize", null);
    childSupport.records.assertRecord("initialize", null);

    BeanContextServiceRevokedEvent evt = new BeanContextServiceRevokedEvent(
            support, Collection.class, false);
    support.publicFireServiceRevoked(evt);

    support.records.assertEndOfRecords();
    childSupport.records.assertEndOfRecords();
    assertSame(evt, l1.lastRevokedEvent);
    assertNull(l2.lastRevokedEvent);
}
BeanContextServiceRevokedEventTest.java 文件源码 项目:freeVM 阅读 25 收藏 0 点赞 0 评论 0
private void assertEqualsSerially(BeanContextServiceRevokedEvent orig,
        BeanContextServiceRevokedEvent ser) {
    assertNull(ser.getSource());

    // check propagatedFrom
    if (orig.getPropagatedFrom() instanceof Serializable) {
        BeanContext origFrom = orig.getPropagatedFrom();
        BeanContext serFrom = ser.getPropagatedFrom();
        assertEquals(origFrom.getClass(), serFrom.getClass());
        if (origFrom instanceof MockBeanContextDelegateS) {
            assertEquals(((MockBeanContextDelegateS) origFrom).id,
                    ((MockBeanContextDelegateS) serFrom).id);
        }
    }

    // check serviceClass
    assertEquals(orig.getServiceClass(), ser.getServiceClass());

    // check invalidateRefs
    assertEquals(orig.isCurrentServiceInvalidNow(), ser
            .isCurrentServiceInvalidNow());
}
BeanContextServicesSupportTest.java 文件源码 项目:freeVM 阅读 25 收藏 0 点赞 0 评论 0
public void testFireServiceRevokedBeanContextServiceRevokedEvent() {
    MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
    MockBeanContextServicesSupport childSupport = new MockBeanContextServicesSupport();
    support.add(childSupport);
    MockBeanContextServicesListener l1 = new MockBeanContextServicesListener();
    MockBeanContextServicesListener l2 = new MockBeanContextServicesListener();
    support.addBeanContextServicesListener(l1);
    childSupport.addBeanContextServicesListener(l2);
    support.records.assertRecord("initialize", null);
    childSupport.records.assertRecord("initialize", null);

    BeanContextServiceRevokedEvent evt = new BeanContextServiceRevokedEvent(
            support, Collection.class, false);
    support.publicFireServiceRevoked(evt);

    support.records.assertEndOfRecords();
    childSupport.records.assertEndOfRecords();
    assertSame(evt, l1.lastRevokedEvent);
    assertNull(l2.lastRevokedEvent);
}
BeanContextServicesSupportTest.java 文件源码 项目:freeVM 阅读 21 收藏 0 点赞 0 评论 0
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);

}
BeanContextServiceRevokedEventTest.java 文件源码 项目:cn1 阅读 21 收藏 0 点赞 0 评论 0
public void testBeanContextServiceRevokedEvent() {
    BeanContextServices services = new MockBeanContextServices();
    BeanContextServiceRevokedEvent event = new MockBeanContextServiceRevokedEvent(
            services, BeanContext.class, true);
    assertSame(BeanContext.class, event.getServiceClass());
    assertSame(services, event.getSource());
    assertSame(services, event.getSourceAsBeanContextServices());
    assertTrue(event.isCurrentServiceInvalidNow());
}
BeanContextServiceRevokedEventTest.java 文件源码 项目:cn1 阅读 18 收藏 0 点赞 0 评论 0
public void testIsServiceClass() {
    BeanContextServices services = new MockBeanContextServices();
    BeanContextServiceRevokedEvent event = new MockBeanContextServiceRevokedEvent(
            services, BeanContext.class, true);
    assertTrue(event.isServiceClass(BeanContext.class));
    assertFalse(event.isServiceClass(Integer.class));

    // Regression for HARMONY-1516
    assertFalse(event.isServiceClass(null));
}
BeanContextServiceRevokedEventTest.java 文件源码 项目:cn1 阅读 22 收藏 0 点赞 0 评论 0
public void testIsCurrentServiceInvalidNow() {
    BeanContextServices services = new MockBeanContextServices();
    BeanContextServiceRevokedEvent event = new MockBeanContextServiceRevokedEvent(
            services, BeanContext.class, true);
    assertTrue(event.isCurrentServiceInvalidNow());
    event = new MockBeanContextServiceRevokedEvent(services,
            BeanContext.class, false);
    assertFalse(event.isCurrentServiceInvalidNow());
}
BeanContextServiceRevokedEventTest.java 文件源码 项目:cn1 阅读 24 收藏 0 点赞 0 评论 0
public void testSerialization() throws IOException, ClassNotFoundException {
    BeanContextServiceRevokedEvent event = new BeanContextServiceRevokedEvent(
            new MockBeanContextServices(), ArrayList.class, true);
    event.setPropagatedFrom(new MockBeanContextDelegateS("from ID"));

    assertEqualsSerially(event,
            (BeanContextServiceRevokedEvent) SerializationTester
                    .getDeserilizedObject(event));

}
BeanContextServiceRevokedEventTest.java 文件源码 项目:cn1 阅读 126 收藏 0 点赞 0 评论 0
public void testSerialization_Compatibility() throws Exception {
    BeanContextServiceRevokedEvent event = new BeanContextServiceRevokedEvent(
            new MockBeanContextServices(), ArrayList.class, true);
    event.setPropagatedFrom(new MockBeanContextDelegateS("from ID"));
    SerializationTest.verifyGolden(this, event, new SerializableAssert() {
        public void assertDeserialized(Serializable orig, Serializable ser) {
            assertEqualsSerially((BeanContextServiceRevokedEvent) orig,
                    (BeanContextServiceRevokedEvent) ser);
        }
    });
}
BeanContextServiceRevokedEventTest.java 文件源码 项目:cn1 阅读 25 收藏 0 点赞 0 评论 0
public void testConstructor() throws Exception {
    BeanContextServices bcs = new MockBeanContextServices();
    BeanContextServiceRevokedEvent event = new BeanContextServiceRevokedEvent(
            bcs, ArrayList.class, true);
    assertEquals(null, event.getPropagatedFrom());
    assertEquals(ArrayList.class, event.getServiceClass());
    assertSame(bcs, event.getSource());
    assertSame(bcs, event.getBeanContext());
    assertSame(bcs, event.getSourceAsBeanContextServices());
    assertFalse(event.isPropagated());
}
BeanContextServicesSupportTest.java 文件源码 项目:cn1 阅读 27 收藏 0 点赞 0 评论 0
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);        
}
BeanContextServiceRevokedEventTest.java 文件源码 项目:freeVM 阅读 21 收藏 0 点赞 0 评论 0
public void testBeanContextServiceRevokedEvent() {
    BeanContextServices services = new MockBeanContextServices();
    BeanContextServiceRevokedEvent event = new MockBeanContextServiceRevokedEvent(
            services, BeanContext.class, true);
    assertSame(BeanContext.class, event.getServiceClass());
    assertSame(services, event.getSource());
    assertSame(services, event.getSourceAsBeanContextServices());
    assertTrue(event.isCurrentServiceInvalidNow());
}
BeanContextServiceRevokedEventTest.java 文件源码 项目:freeVM 阅读 21 收藏 0 点赞 0 评论 0
public void testIsServiceClass() {
    BeanContextServices services = new MockBeanContextServices();
    BeanContextServiceRevokedEvent event = new MockBeanContextServiceRevokedEvent(
            services, BeanContext.class, true);
    assertTrue(event.isServiceClass(BeanContext.class));
    assertFalse(event.isServiceClass(Integer.class));

    // Regression for HARMONY-1516
    assertFalse(event.isServiceClass(null));
}
BeanContextServiceRevokedEventTest.java 文件源码 项目:freeVM 阅读 25 收藏 0 点赞 0 评论 0
public void testIsCurrentServiceInvalidNow() {
    BeanContextServices services = new MockBeanContextServices();
    BeanContextServiceRevokedEvent event = new MockBeanContextServiceRevokedEvent(
            services, BeanContext.class, true);
    assertTrue(event.isCurrentServiceInvalidNow());
    event = new MockBeanContextServiceRevokedEvent(services,
            BeanContext.class, false);
    assertFalse(event.isCurrentServiceInvalidNow());
}
BeanContextServiceRevokedEventTest.java 文件源码 项目:freeVM 阅读 25 收藏 0 点赞 0 评论 0
public void testSerialization() throws IOException, ClassNotFoundException {
    BeanContextServiceRevokedEvent event = new BeanContextServiceRevokedEvent(
            new MockBeanContextServices(), ArrayList.class, true);
    event.setPropagatedFrom(new MockBeanContextDelegateS("from ID"));

    assertEqualsSerially(event,
            (BeanContextServiceRevokedEvent) SerializationTester
                    .getDeserilizedObject(event));
}
BeanContextServiceRevokedEventTest.java 文件源码 项目:freeVM 阅读 20 收藏 0 点赞 0 评论 0
public void testSerialization_Compatibility() throws Exception {
    BeanContextServiceRevokedEvent event = new BeanContextServiceRevokedEvent(
            new MockBeanContextServices(), ArrayList.class, true);
    event.setPropagatedFrom(new MockBeanContextDelegateS("from ID"));

    assertEqualsSerially(
            event,
            (BeanContextServiceRevokedEvent) SerializationTester
                    .readObject(event,
                            "serialization/java/beans/beancontext/BeanContextServiceRevokedEvent.ser"));
}
BeanContextServiceRevokedEventTest.java 文件源码 项目:freeVM 阅读 21 收藏 0 点赞 0 评论 0
public void testBeanContextServiceRevokedEvent() {
    BeanContextServices services = new MockBeanContextServices();
    BeanContextServiceRevokedEvent event = new MockBeanContextServiceRevokedEvent(
            services, BeanContext.class, true);
    assertSame(BeanContext.class, event.getServiceClass());
    assertSame(services, event.getSource());
    assertSame(services, event.getSourceAsBeanContextServices());
    assertTrue(event.isCurrentServiceInvalidNow());
}
BeanContextServiceRevokedEventTest.java 文件源码 项目:freeVM 阅读 22 收藏 0 点赞 0 评论 0
public void testIsServiceClass() {
    BeanContextServices services = new MockBeanContextServices();
    BeanContextServiceRevokedEvent event = new MockBeanContextServiceRevokedEvent(
            services, BeanContext.class, true);
    assertTrue(event.isServiceClass(BeanContext.class));
    assertFalse(event.isServiceClass(Integer.class));

    // Regression for HARMONY-1516
    assertFalse(event.isServiceClass(null));
}
BeanContextServiceRevokedEventTest.java 文件源码 项目:freeVM 阅读 24 收藏 0 点赞 0 评论 0
public void testIsCurrentServiceInvalidNow() {
    BeanContextServices services = new MockBeanContextServices();
    BeanContextServiceRevokedEvent event = new MockBeanContextServiceRevokedEvent(
            services, BeanContext.class, true);
    assertTrue(event.isCurrentServiceInvalidNow());
    event = new MockBeanContextServiceRevokedEvent(services,
            BeanContext.class, false);
    assertFalse(event.isCurrentServiceInvalidNow());
}
BeanContextServiceRevokedEventTest.java 文件源码 项目:freeVM 阅读 22 收藏 0 点赞 0 评论 0
public void testSerialization() throws IOException, ClassNotFoundException {
    BeanContextServiceRevokedEvent event = new BeanContextServiceRevokedEvent(
            new MockBeanContextServices(), ArrayList.class, true);
    event.setPropagatedFrom(new MockBeanContextDelegateS("from ID"));

    assertEqualsSerially(event,
            (BeanContextServiceRevokedEvent) SerializationTester
                    .getDeserilizedObject(event));

}
BeanContextServiceRevokedEventTest.java 文件源码 项目:freeVM 阅读 20 收藏 0 点赞 0 评论 0
public void testSerialization_Compatibility() throws Exception {
    BeanContextServiceRevokedEvent event = new BeanContextServiceRevokedEvent(
            new MockBeanContextServices(), ArrayList.class, true);
    event.setPropagatedFrom(new MockBeanContextDelegateS("from ID"));
    SerializationTest.verifyGolden(this, event, new SerializableAssert() {
        public void assertDeserialized(Serializable orig, Serializable ser) {
            assertEqualsSerially((BeanContextServiceRevokedEvent) orig,
                    (BeanContextServiceRevokedEvent) ser);
        }
    });
}
BeanContextServiceRevokedEventTest.java 文件源码 项目:freeVM 阅读 22 收藏 0 点赞 0 评论 0
public void testConstructor() throws Exception {
    BeanContextServices bcs = new MockBeanContextServices();
    BeanContextServiceRevokedEvent event = new BeanContextServiceRevokedEvent(
            bcs, ArrayList.class, true);
    assertEquals(null, event.getPropagatedFrom());
    assertEquals(ArrayList.class, event.getServiceClass());
    assertSame(bcs, event.getSource());
    assertSame(bcs, event.getBeanContext());
    assertSame(bcs, event.getSourceAsBeanContextServices());
    assertFalse(event.isPropagated());
}
BeanContextServicesSupportTest.java 文件源码 项目:freeVM 阅读 21 收藏 0 点赞 0 评论 0
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);        
}
ServiceBean.java 文件源码 项目:freeVM 阅读 33 收藏 0 点赞 0 评论 0
/**
 * @param bcsre the BeanContextServiceRevokedEvent
 */
public void serviceRevoked(BeanContextServiceRevokedEvent bcsre) {

    System.out.println("Sservice is revoked");
    counterRevokedEvent++;
    this.bcsre = bcsre;
}
BeanContextServiceRevokedEventTest.java 文件源码 项目:cn1 阅读 27 收藏 0 点赞 0 评论 0
public void serviceRevoked(BeanContextServiceRevokedEvent p0) {
    return;
}
BeanContextServiceRevokedEventTest.java 文件源码 项目:cn1 阅读 21 收藏 0 点赞 0 评论 0
public void testGetServiceClass() {
    BeanContextServices services = new MockBeanContextServices();
    BeanContextServiceRevokedEvent event = new MockBeanContextServiceRevokedEvent(
            services, BeanContext.class, true);
    assertSame(BeanContext.class, event.getServiceClass());
}


问题


面经


文章

微信
公众号

扫码关注公众号