use of org.jboss.weld.environment.se.WeldContainer in project core by weld.
the class RequestScopedActiveInterceptorTest method requestScopedActive.
@Test
public void requestScopedActive() {
try (WeldContainer container = new Weld().initialize()) {
Foo foo = container.select(Foo.class).get();
foo.ping();
}
}
use of org.jboss.weld.environment.se.WeldContainer in project core by weld.
the class ContainerInstanceTest method testDependentInstanceDestroyedDuringShutdown.
@Test
public void testDependentInstanceDestroyedDuringShutdown() {
Foo.DESTROYED.set(false);
try (WeldContainer container = new Weld().disableDiscovery().beanClasses(Foo.class).initialize()) {
CDI.current().select(Foo.class).get();
}
// Dependent bean instances obtained by CDI should be destroyed correctly during shutdown
assertTrue(Foo.DESTROYED.get());
}
use of org.jboss.weld.environment.se.WeldContainer in project core by weld.
the class ContainerIsolationTest method testContainerIsolation.
@Test
public void testContainerIsolation() {
Weld weld1 = new Weld("1");
WeldContainer weldContainer1 = weld1.initialize();
Foo foo1 = weldContainer1.instance().select(Foo.class).get();
Weld weld2 = new Weld("2");
WeldContainer weldContainer2 = weld2.initialize();
Foo foo2 = weldContainer2.instance().select(Foo.class).get();
foo1.setValue(1);
foo2.setValue(2);
Assert.assertEquals(1, foo1.getValue());
Assert.assertEquals(2, foo2.getValue());
weld1.shutdown();
Assert.assertEquals(2, foo2.getValue());
weld2.shutdown();
}
use of org.jboss.weld.environment.se.WeldContainer in project core by weld.
the class TestExtension method beforeBeanDiscovery.
public void beforeBeanDiscovery(@Observes BeforeBeanDiscovery event) {
CDI<Object> cdi = CDI.current();
@SuppressWarnings("resource") WeldContainer container = (WeldContainer) cdi;
assertFalse(container.isRunning());
try {
cdi.select(Object.class);
fail();
} catch (IllegalStateException expected) {
}
beanManagerReference.set(cdi.getBeanManager());
}
use of org.jboss.weld.environment.se.WeldContainer in project core by weld.
the class WeldSEProviderTest method testExtension.
@Test
public void testExtension() {
TestExtension.reset();
try (WeldContainer weldContainer = new Weld().disableDiscovery().beanClasses(Foo.class).addExtension(new TestExtension()).initialize()) {
BeanManager beanManager = TestExtension.beanManagerReference.get();
assertNotNull(beanManager);
Bean<?> fooBean = TestExtension.fooBeanReference.get();
assertNotNull(fooBean);
}
}
Aggregations