Examples of CdiContainer


Examples of org.apache.deltaspike.cdise.api.CdiContainer

    }

    @Test
    public void basicInjection() // useless because of tcks but nice to have when working on this specific container
    {
        final CdiContainer container = CdiContainerLoader.getCdiContainer();
        container.boot();

        try
        {
            final BeanManager beanManager = container.getBeanManager();
            assertEquals("foo", Foo.class.cast(beanManager.getReference(beanManager.resolve(beanManager.getBeans(Foo.class)), Foo.class, null)).name());
        }
        finally
        {
            container.shutdown();
        }
    }
View Full Code Here

Examples of org.apache.deltaspike.cdise.api.CdiContainer

            return this.testControl.logHandler();
        }

        void applyBeforeClassConfig(Class testClass)
        {
            CdiContainer container = CdiContainerLoader.getCdiContainer();

            if (!isContainerStarted())
            {
                if (!CdiTestSuiteRunner.isContainerStarted())
                {
                    container.boot();
                    setContainerStarted();

                    bootExternalContainers(testClass);
                }
            }
View Full Code Here

Examples of org.apache.deltaspike.cdise.api.CdiContainer

            }
        }

        void applyAfterClassConfig()
        {
            CdiContainer container = CdiContainerLoader.getCdiContainer();

            stopStartedScopes(container);

            if (this.containerStarted)
            {
                if (CdiTestSuiteRunner.isStopContainerAllowed())
                {
                    shutdownExternalContainers();

                    container.shutdown(); //stop the container on the same level which started it
                    CdiTestSuiteRunner.setContainerStarted(false);
                }
            }
        }
View Full Code Here

Examples of org.apache.deltaspike.cdise.api.CdiContainer

public class ContainerCtrlTckTest
{
    @Test
    public void testContainerBoot()
    {
        CdiContainer cc = CdiContainerLoader.getCdiContainer();
        Assert.assertNotNull(cc);

        cc.boot();
        cc.getContextControl().startContexts();

        BeanManager bm = cc.getBeanManager();
        Assert.assertNotNull(bm);
       
        Set<Bean<?>> beans = bm.getBeans(CarRepair.class);
        Bean<?> bean = bm.resolve(beans);
       
        CarRepair carRepair = (CarRepair) bm.getReference(bean, CarRepair.class, bm.createCreationalContext(bean));
        Assert.assertNotNull(carRepair);

        Assert.assertNotNull(carRepair.getCar());
        Assert.assertNotNull(carRepair.getCar().getUser());

        cc.shutdown();
    }
View Full Code Here

Examples of org.apache.deltaspike.cdise.api.CdiContainer

    }

    @Test
    public void testSimpleContainerBoot()
    {
        CdiContainer cc = CdiContainerLoader.getCdiContainer();
        Assert.assertNotNull(cc);

        cc.boot();
        cc.getContextControl().startContexts();

        BeanManager bm = cc.getBeanManager();
        Assert.assertNotNull(bm);

        Set<Bean<?>> beans = bm.getBeans(CarRepair.class);
        Bean<?> bean = bm.resolve(beans);

        CarRepair carRepair = (CarRepair) bm.getReference(bean, CarRepair.class, bm.createCreationalContext(bean));
        Assert.assertNotNull(carRepair);

        Assert.assertNotNull(carRepair.getCar());
        Assert.assertNotNull(carRepair.getCar().getUser());

        cc.shutdown();
    }
View Full Code Here

Examples of org.apache.deltaspike.cdise.api.CdiContainer

     * If the deepest ref has the expected value, all levels in between were resetted correctly.
     */
    @Test
    public void testRestartContexts()
    {
        CdiContainer cdiContainer = CdiContainerLoader.getCdiContainer();
        Assert.assertNotNull(cdiContainer);

        cdiContainer.boot();
        cdiContainer.getContextControl().startContexts();

        BeanManager beanManager = cdiContainer.getBeanManager();
        Assert.assertNotNull(beanManager);

        Set<Bean<?>> beans = beanManager.getBeans(CarRepair.class);
        Bean<?> bean = beanManager.resolve(beans);

        CarRepair carRepair = (CarRepair)
            beanManager.getReference(bean, CarRepair.class, beanManager.createCreationalContext(bean));

        Assert.assertNotNull(carRepair);

        Car car = carRepair.getCar();

        Assert.assertNotNull(car);
        Assert.assertNotNull(car.getUser());


        carRepair.getCar().getUser().setName("tester");
        Assert.assertEquals("tester", car.getUser().getName());

        Assert.assertFalse(CarRepair.isPreDestroyCalled());
        Assert.assertFalse(Car.isPreDestroyCalled());
        Assert.assertFalse(TestUser.isPreDestroyCalled());

        cdiContainer.getContextControl().stopContexts();

        Assert.assertTrue(CarRepair.isPreDestroyCalled());
        Assert.assertTrue(Car.isPreDestroyCalled());
        Assert.assertTrue(TestUser.isPreDestroyCalled());

        try
        {
            car.getUser();

            // accessing the car should have triggered a ContextNotActiveException
            Assert.fail();
        }
        catch (ContextNotActiveException e)
        {
            //do nothing - exception expected
        }

        cdiContainer.getContextControl().startContexts();

        carRepair = (CarRepair)
            beanManager.getReference(bean, CarRepair.class, beanManager.createCreationalContext(bean));

        Assert.assertNotNull(carRepair.getCar());
        Assert.assertNotNull(carRepair.getCar().getUser());
        Assert.assertNull(carRepair.getCar().getUser().getName());

        cdiContainer.shutdown();
    }
View Full Code Here

Examples of org.apache.deltaspike.cdise.api.CdiContainer

    }

    @Test
    public void testShutdownWithInactiveContexts()
    {
        CdiContainer cdiContainer = CdiContainerLoader.getCdiContainer();
        Assert.assertNotNull(cdiContainer);

        cdiContainer.boot();
        cdiContainer.getContextControl().startContexts();

        // now do some randmo stuff
        BeanManager beanManager = cdiContainer.getBeanManager();
        Assert.assertNotNull(beanManager);

        Set<Bean<?>> beans = beanManager.getBeans(CarRepair.class);
        Bean<?> bean = beanManager.resolve(beans);

        CarRepair carRepair = (CarRepair)
                beanManager.getReference(bean, CarRepair.class, beanManager.createCreationalContext(bean));

        Assert.assertNotNull(carRepair);

        Car car = carRepair.getCar();
        Assert.assertNotNull(car);

        cdiContainer.getContextControl().startContexts();

        cdiContainer.shutdown();
    }
View Full Code Here

Examples of org.apache.deltaspike.cdise.api.CdiContainer

            return this.testControl.logHandler();
        }

        void applyBeforeClassConfig()
        {
            CdiContainer container = CdiContainerLoader.getCdiContainer();

            if (!isContainerStarted())
            {
                if (!CdiTestSuiteRunner.isContainerStarted())
                {
                    container.boot();
                    setContainerStarted();

                    bootExternalContainers();
                }
            }
View Full Code Here

Examples of org.apache.deltaspike.cdise.api.CdiContainer

            }
        }

        void applyAfterClassConfig()
        {
            CdiContainer container = CdiContainerLoader.getCdiContainer();

            stopStartedScopes(container);

            if (this.containerStarted)
            {
                if (CdiTestSuiteRunner.isStopContainerAllowed())
                {
                    shutdownExternalContainers();

                    container.shutdown(); //stop the container on the same level which started it
                    CdiTestSuiteRunner.setContainerStarted(false);
                }
            }
        }
View Full Code Here

Examples of org.apache.deltaspike.cdise.api.CdiContainer

public class ContainerCtrlTckTest
{
    @Test
    public void testContainerBoot()
    {
        CdiContainer cc = CdiContainerLoader.getCdiContainer();
        Assert.assertNotNull(cc);

        cc.boot();
        cc.getContextControl().startContexts();

        BeanManager bm = cc.getBeanManager();
        Assert.assertNotNull(bm);
       
        Set<Bean<?>> beans = bm.getBeans(CarRepair.class);
        Bean<?> bean = bm.resolve(beans);
       
        CarRepair carRepair = (CarRepair) bm.getReference(bean, CarRepair.class, bm.createCreationalContext(bean));
        Assert.assertNotNull(carRepair);

        Assert.assertNotNull(carRepair.getCar());
        Assert.assertNotNull(carRepair.getCar().getUser());

        cc.shutdown();
    }
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.