Package org.jboss.arquillian.container.weld.ee.embedded_1_1

Examples of org.jboss.arquillian.container.weld.ee.embedded_1_1.WeldEEMockContainer


        throw new RuntimeException();
    }

    @Test
    public void ensureNoThreadLocalLeakOnContexts() throws Exception {
        TestContainer container = new TestContainer(Foo.class, ThreadLocalTestCase.class);
        container.startContainer();
        BeanManager manager = getBeanManager(container);

        Bean<? extends Object> testBean = manager.resolve(manager.getBeans(ThreadLocalTestCase.class));

        try {
            manager.getReference(
                    testBean,
                    ThreadLocalTestCase.class,
                    manager.createCreationalContext(testBean));
        } catch (RuntimeException e) {
            // Ignore, expected
        }

        container.stopContainer();
        verifyThreadLocals();
    }
View Full Code Here


        verifyThreadLocals();
    }

    @Test
    public void ensureNoThreadLocalLeakOnInjectionPoints() throws Exception {
        TestContainer container = new TestContainer(Bar.class, Baz.class);
        container.startContainer();
        BeanManager manager = getBeanManager(container);

        Bean<?> testBean = manager.resolve(manager.getBeans(Baz.class));

        Baz baz = cast(manager.getReference(
                testBean,
                Baz.class,
                manager.createCreationalContext(testBean)));
        baz.getBar().ping();

        container.stopContainer();
        verifyThreadLocals();
    }
View Full Code Here

                    return bda1;
                }
            }

        };
        TestContainer container = new TestContainer(deployment);
        // Cause the container to deploy the beans etc.
        container.startContainer();

        // Get the bean manager for bda1 and bda2
        BeanManager beanManager1 = container.getBeanManager(bda1);
        BeanManager beanManager2 = container.getBeanManager(bda2);

        Observer1 observer1 = Utils.getReference(beanManager1, Observer1.class);
        Assert.assertTrue(observer1.isBeforeBeanDiscoveryCalled());
        Assert.assertEquals(beanManager1, observer1.getBeforeBeanDiscoveryBeanManager());
        Assert.assertTrue(observer1.isAfterBeanDiscoveryCalled());
View Full Code Here

                }
            }

        };

        TestContainer container = new TestContainer(deployment);

        // Cause the container to deploy the beans etc.
        container.startContainer();

        // Get the bean manager for bda1 and bda2
        BeanManager beanManager1 = container.getBeanManager(bda1);

        CountingObserver1 observer1 = Utils.getReference(beanManager1, CountingObserver1.class);
        CountingObserver2 observer2 = Utils.getReference(beanManager1, CountingObserver2.class);
        Assert.assertEquals(1, observer1.getBeforeBeanDiscovery());
        Assert.assertEquals(1, observer1.getProcessFooManagedBean());
View Full Code Here

        war.getBeanDeploymentArchives().add(jar1);
        war.getBeanDeploymentArchives().add(jar2);

        Deployment deployment = new FlatDeployment(war);

        TestContainer container = null;
        try {
            container = new TestContainer(deployment).startContainer().ensureRequestActive();
            BeanManagerImpl warBeanManager = (BeanManagerImpl) container.getBeanManager(war);
            BeanManagerImpl jar1BeanManager = (BeanManagerImpl) container.getBeanManager(jar1);
            BeanManagerImpl jar2BeanManager = (BeanManagerImpl) container.getBeanManager(jar2);
            Assert.assertTrue(warBeanManager.getEnabled().getAlternativeClasses().isEmpty());
            Assert.assertFalse(jar1BeanManager.getEnabled().getAlternativeClasses().isEmpty());
            Assert.assertTrue(jar2BeanManager.getEnabled().getAlternativeClasses().isEmpty());
        } finally {
            if (container != null) {
                container.stopContainer();
            }
        }
    }
View Full Code Here

        war.getBeanDeploymentArchives().add(jar1);
        war.getBeanDeploymentArchives().add(jar2);

        Deployment deployment = new FlatDeployment(war);

        TestContainer container = null;
        try {
            container = new TestContainer(deployment).startContainer().ensureRequestActive();
            BeanManagerImpl warBeanManager = (BeanManagerImpl) container.getBeanManager(war);
            BeanManagerImpl jar1BeanManager = (BeanManagerImpl) container.getBeanManager(jar1);
            BeanManagerImpl jar2BeanManager = (BeanManagerImpl) container.getBeanManager(jar2);
            Assert.assertTrue(warBeanManager.getEnabled().getAlternativeClasses().isEmpty());
            Assert.assertFalse(jar1BeanManager.getEnabled().getAlternativeClasses().isEmpty());
            Assert.assertFalse(jar2BeanManager.getEnabled().getAlternativeClasses().isEmpty());
        } finally {
            if (container != null) {
                container.stopContainer();
            }
        }
    }
View Full Code Here

                return ejbJar;
            }

        };

        TestContainer container = new TestContainer(deployment);
        container.startContainer();
        container.ensureRequestActive();

        // Get the bean manager for war and ejb jar
        BeanManager warBeanManager = container.getBeanManager(war);
        BeanManager ejbJarBeanManager = container.getBeanManager(ejbJar);

        Assert.assertEquals(1, warBeanManager.getBeans(Bar.class).size());
        Assert.assertEquals(1, warBeanManager.getBeans(Foo.class).size());
        Assert.assertEquals(1, ejbJarBeanManager.getBeans(Foo.class).size());
        Assert.assertEquals(0, ejbJarBeanManager.getBeans(Bar.class).size());
View Full Code Here

                return ejbJar;
            }

        };

        TestContainer container = new TestContainer(deployment);
        container.startContainer();
        container.ensureRequestActive();

        // Get the bean manager for war and ejb jar
        BeanManager warBeanManager = container.getBeanManager(war);
        BeanManager ejbJarBeanManager = container.getBeanManager(ejbJar);


        BasicInterceptor.reset();
        Simple simple = getReference(ejbJarBeanManager, Simple.class);
        simple.ping("14");
View Full Code Here

                return ejbJar;
            }

        };

        TestContainer container = new TestContainer(deployment);
        container.startContainer();
        container.ensureRequestActive();

        // Get the bean manager for war and ejb jar
        BeanManager warBeanManager = container.getBeanManager(war);
        BeanManager ejbJarBeanManager = container.getBeanManager(ejbJar);


        BasicInterceptor.reset();
        Blah blah = getReference(ejbJarBeanManager, Blah.class);
        blah.ping(10);
View Full Code Here

    public void test() {

        // Bootstrap container 1
        SwitchableSingletonProvider.use(1);

        TestContainer container1 = new TestContainer(Foo.class);
        container1.startContainer();
        container1.ensureRequestActive();

        BeanManagerImpl beanManager1 = getBeanManager(container1);
        Bean<?> fooBean1 = beanManager1.resolve(beanManager1.getBeans(Foo.class));
        Foo foo1 = (Foo) beanManager1.getReference(fooBean1, Foo.class, beanManager1.createCreationalContext(fooBean1));
        foo1.setName("container 1");

        // Bootstrap container 2
        SwitchableSingletonProvider.use(2);

        TestContainer container2 = new TestContainer(Foo.class);
        container2.startContainer();
        container2.ensureRequestActive();

        BeanManagerImpl beanManager2 = getBeanManager(container2);
        Bean<?> fooBean2 = beanManager2.resolve(beanManager2.getBeans(Foo.class));
        Foo foo2 = (Foo) beanManager2.getReference(fooBean2, Foo.class, beanManager2.createCreationalContext(fooBean2));
        foo2.setName("container 2");

        // Switch to container 1 and check value
        SwitchableSingletonProvider.use(1);
        foo1 = (Foo) beanManager1.getReference(fooBean1, Foo.class, beanManager1.createCreationalContext(fooBean1));
        assert foo1.getName().equals("container 1");

        // Switch to container 2 and check value
        SwitchableSingletonProvider.use(2);
        foo2 = (Foo) beanManager2.getReference(fooBean2, Foo.class, beanManager2.createCreationalContext(fooBean2));
        assert foo2.getName().equals("container 2");
        SwitchableSingletonProvider.use(1);
        container1.stopContainer();
        SwitchableSingletonProvider.use(2);
        container2.stopContainer();
        SingletonProvider.reset();
    }
View Full Code Here

TOP

Related Classes of org.jboss.arquillian.container.weld.ee.embedded_1_1.WeldEEMockContainer

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.