Search in sources :

Example 1 with Environment

use of org.jboss.weld.bootstrap.api.Environment in project core by weld.

the class SubclassedComponentDescriptorTest method prepareContainer.

@BeforeClass
public void prepareContainer() {
    final EjbDescriptor<Foo> fooDescriptor = new EjbDescriptorImpl<Foo>(Foo.class, Foo.class, EnhancedFoo.class, SessionBeanType.STATEFUL);
    final EjbDescriptor<Bar> barDescriptor = new EjbDescriptorImpl<Bar>(Bar.class, BarLocal.class, EnhancedBar.class, SessionBeanType.STATEFUL);
    final EjbDescriptor<Baz> bazDescriptor = new EjbDescriptorImpl<Baz>(Baz.class, Baz.class, EnhancedBaz.class, null);
    final BeanDeploymentArchive bda = new BeanDeploymentArchiveImpl("1", Foo.class, Bar.class, BarLocal.class, BarDecorator.class, BarInterceptor.class, BarInterceptorBinding.class, Baz.class) {

        @Override
        public Collection<EjbDescriptor<?>> getEjbs() {
            return ImmutableSet.<EjbDescriptor<?>>of(fooDescriptor, barDescriptor, bazDescriptor);
        }
    };
    final Deployment deployment = new FlatDeployment(bda) {

        @Override
        public BeanDeploymentArchive loadBeanDeploymentArchive(Class<?> beanClass) {
            return bda;
        }

        @Override
        protected void configureServices(Environment environment) {
            super.configureServices(environment);
            getServices().add(EjbServices.class, new MockEjbServices());
        }
    };
    container = new TestContainer(deployment).startContainer();
    manager = (BeanManagerImpl) container.getBeanManager(bda);
}
Also used : TestContainer(org.jboss.arquillian.container.weld.embedded.mock.TestContainer) BeanDeploymentArchiveImpl(org.jboss.arquillian.container.weld.embedded.mock.BeanDeploymentArchiveImpl) Deployment(org.jboss.weld.bootstrap.spi.Deployment) FlatDeployment(org.jboss.arquillian.container.weld.embedded.mock.FlatDeployment) EjbDescriptor(org.jboss.weld.ejb.spi.EjbDescriptor) MockEjbServices(org.jboss.weld.mock.MockEjbServices) FlatDeployment(org.jboss.arquillian.container.weld.embedded.mock.FlatDeployment) BeanDeploymentArchive(org.jboss.weld.bootstrap.spi.BeanDeploymentArchive) Environment(org.jboss.weld.bootstrap.api.Environment) AfterClass(org.testng.annotations.AfterClass) BeforeClass(org.testng.annotations.BeforeClass) BeforeClass(org.testng.annotations.BeforeClass)

Example 2 with Environment

use of org.jboss.weld.bootstrap.api.Environment in project core by weld.

the class StaticResourceTest method testStaticResourceInjectionWithInjectionServices.

@Test
public void testStaticResourceInjectionWithInjectionServices() {
    // Create the BDA in which we will deploy FooExtension. This BDA does not have access to bda2
    final BeanDeploymentArchive bda = new BeanDeploymentArchiveImpl("1", InjectedClass.class) {

        @Override
        protected void configureServices(Environment environment) {
            getServices().add(InjectionServices.class, new TestInjectionServices());
        }
    };
    // Create a deployment, that we can use to mirror the structure of one Extension inside a BDA, and one outside
    Deployment deployment = new FlatDeployment(new BeanDeploymentArchive[] { bda }) {

        @Override
        protected void configureServices(Environment environment) {
            super.configureServices(environment);
            getServices().add(TransactionServices.class, new TestTransactionServices());
        }

        @Override
        public BeanDeploymentArchive loadBeanDeploymentArchive(Class<?> beanClass) {
            return bda;
        }
    };
    final WeldBootstrap bootstrap = new WeldBootstrap();
    bootstrap.startContainer(Environments.EE, deployment).startInitialization().deployBeans().validateBeans().endInitialization();
    try {
        final BeanManagerImpl manager = bootstrap.getManager(bda);
        final SpecialResource resource = manager.instance().select(SpecialResource.class).get();
        Assert.assertNotNull(resource);
        Assert.assertEquals(resource.getName(), TestInjectionServices.RESOURCE_NAME);
    } finally {
        bootstrap.shutdown();
    }
}
Also used : BeanDeploymentArchiveImpl(org.jboss.arquillian.container.weld.embedded.mock.BeanDeploymentArchiveImpl) BeanManagerImpl(org.jboss.weld.manager.BeanManagerImpl) FlatDeployment(org.jboss.arquillian.container.weld.embedded.mock.FlatDeployment) WeldBootstrap(org.jboss.weld.bootstrap.WeldBootstrap) BeanDeploymentArchive(org.jboss.weld.bootstrap.spi.BeanDeploymentArchive) Environment(org.jboss.weld.bootstrap.api.Environment) Deployment(org.jboss.weld.bootstrap.spi.Deployment) FlatDeployment(org.jboss.arquillian.container.weld.embedded.mock.FlatDeployment) Test(org.testng.annotations.Test)

Aggregations

BeanDeploymentArchiveImpl (org.jboss.arquillian.container.weld.embedded.mock.BeanDeploymentArchiveImpl)2 FlatDeployment (org.jboss.arquillian.container.weld.embedded.mock.FlatDeployment)2 Environment (org.jboss.weld.bootstrap.api.Environment)2 BeanDeploymentArchive (org.jboss.weld.bootstrap.spi.BeanDeploymentArchive)2 Deployment (org.jboss.weld.bootstrap.spi.Deployment)2 TestContainer (org.jboss.arquillian.container.weld.embedded.mock.TestContainer)1 WeldBootstrap (org.jboss.weld.bootstrap.WeldBootstrap)1 EjbDescriptor (org.jboss.weld.ejb.spi.EjbDescriptor)1 BeanManagerImpl (org.jboss.weld.manager.BeanManagerImpl)1 MockEjbServices (org.jboss.weld.mock.MockEjbServices)1 AfterClass (org.testng.annotations.AfterClass)1 BeforeClass (org.testng.annotations.BeforeClass)1 Test (org.testng.annotations.Test)1