Examples of RequestScopedBean


Examples of org.apache.webbeans.newtests.interceptors.beans.RequestScopedBean

        Object reference1 = getBeanManager().getReference(bean, RequestScopedBean.class, ctx);
        Assert.assertNotNull(reference1);
       
        Assert.assertTrue(reference1 instanceof RequestScopedBean);

        RequestScopedBean beanInstance1 = (RequestScopedBean)reference1;
       
        TransactionInterceptor.count = 0;
       
        beanInstance1.getMyService().getJ();

        RequestScopedBean realInstance1 = beanInstance1.getInstance();
       
        Assert.assertTrue(TransactionInterceptor.ECHO);
        Assert.assertEquals(2, TransactionInterceptor.count);

        TransactionInterceptor.ECHO = false;

        WebBeansContext webBeansContext = WebBeansContext.getInstance();
        webBeansContext.getContextFactory().destroyRequestContext(null);
        webBeansContext.getContextFactory().initRequestContext(null);

        CreationalContext<RequestScopedBean> ctx2 = getBeanManager().createCreationalContext(bean);
        Object reference2 = getBeanManager().getReference(bean, RequestScopedBean.class, ctx2);
        Assert.assertNotNull(reference2);
       
        Assert.assertTrue(reference2 instanceof RequestScopedBean);
       
        RequestScopedBean beanInstance2 = (RequestScopedBean)reference2;
        beanInstance2.getMyService().getJ();
        RequestScopedBean realInstance2 = beanInstance2.getInstance();

        Assert.assertTrue(TransactionInterceptor.ECHO);

        Assert.assertEquals(4, TransactionInterceptor.count);
       
        Assert.assertNotSame(realInstance1, realInstance2);
        Assert.assertEquals(realInstance1.getMyService().getJ(), realInstance2.getMyService().getJ());
       
        shutDownContainer();
       
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.