Package org.apache.webbeans.test.mock

Examples of org.apache.webbeans.test.mock.MockHttpSession


    public Manager getManager()
    {

        ContextFactory.initApplicationContext(null);
        ContextFactory.initRequestContext(null);
        ContextFactory.initSessionContext(new MockHttpSession());
        ContextFactory.initConversationContext(null);

        return ActivityManager.getInstance().getRootActivity();
    }
View Full Code Here


     *
     * @return new mock session
     */
    protected HttpSession getSession()
    {
        return new MockHttpSession();
    }
View Full Code Here

    public void testProducer4()
    {
        defineSimpleWebBean(Producer4.class);
        AbstractComponent<Producer4ConsumerComponent> component = defineSimpleWebBean(Producer4ConsumerComponent.class);

        ContextFactory.initSessionContext(new MockHttpSession());

        Producer4ConsumerComponent instance = getManager().getInstance(component);

        Assert.assertNotNull(instance);
View Full Code Here

    }

    @Test
    public void testTransactionalInterceptor()
    {
        ContextFactory.initSessionContext(new MockHttpSession());
        defineSimpleWebBeanInterceptor(TransactionalInterceptor.class);
       
        Bean<ShoppingCard> bean = defineSimpleWebBean(ShoppingCard.class);
        ShoppingCard card = getManager().getInstance(bean);
       
        card.placeOrder();
       
        Assert.assertTrue(ShoppingCard.CALLED);
       
        card.placeOrder2();
       
        Assert.assertFalse(ShoppingCard.CALLED);
               
        ContextFactory.destroySessionContext(new MockHttpSession());
    }
View Full Code Here

    }

    @Test
    public void testSecureAndTransactionalInterceptor()
    {
        ContextFactory.initSessionContext(new MockHttpSession());
        defineSimpleWebBeanInterceptor(SecureAndTransactionalInterceptor.class);
       
        Bean<SecureAndTransactionalComponent> bean = defineSimpleWebBean(SecureAndTransactionalComponent.class);
        SecureAndTransactionalComponent payment = getManager().getInstance(bean);
       
        Assert.assertFalse(SecureAndTransactionalComponent.CALL);
       
        payment.pay();
       
        Assert.assertTrue(SecureAndTransactionalComponent.CALL);
       
               
        ContextFactory.destroySessionContext(new MockHttpSession());
    }
View Full Code Here

    @Test
    public void testRealizationComponent1()
    {
        ContextFactory.initRequestContext(null);
        ContextFactory.initSessionContext(new MockHttpSession());
       
        Bean<UserComponent> userComponent = defineSimpleWebBean(UserComponent.class);
        defineSimpleWebBean(BookShop.class);
       
        UserComponent component = getManager().getInstance(userComponent);
View Full Code Here

    public void testDisposal1()
    {
        clear();

        ContextFactory.initRequestContext(null);
        ContextFactory.initSessionContext(new MockHttpSession());

        defineSimpleWebBean(Disposal1.class);

        @SuppressWarnings("unchecked")
        List<Integer> list = (List<Integer>) getManager().getInstanceByName("createBinding1");
View Full Code Here

    public BeanManager getManager()
    {

        ContextFactory.initApplicationContext(null);
        ContextFactory.initRequestContext(null);
        ContextFactory.initSessionContext(new MockHttpSession());
        ContextFactory.initConversationContext(null);

        return ActivityManager.getInstance().getRootActivity();
    }
View Full Code Here

    public void testDisposal1()
    {
        clear();

        ContextFactory.initRequestContext(null);
        ContextFactory.initSessionContext(new MockHttpSession());

        defineSimpleWebBean(Disposal1.class);

        @SuppressWarnings("unchecked")
        List<Integer> list = (List<Integer>) getManager().getInstanceByName("createBinding1");
View Full Code Here

    }

    @Test
    public void testTransactionalInterceptor()
    {
        ContextFactory.initSessionContext(new MockHttpSession());
        defineSimpleWebBeanInterceptor(TransactionalInterceptor.class);
       
        Bean<ShoppingCard> bean = defineSimpleWebBean(ShoppingCard.class);
        ShoppingCard card = getManager().getInstance(bean);
       
        card.placeOrder();
       
        Assert.assertTrue(ShoppingCard.getCALLED());
       
        card.placeOrder2();
       
        Assert.assertFalse(ShoppingCard.getCALLED());
               
        ContextFactory.destroySessionContext(new MockHttpSession());
    }
View Full Code Here

TOP

Related Classes of org.apache.webbeans.test.mock.MockHttpSession

Copyright © 2018 www.massapicom. 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.