use of org.jboss.weld.environment.se.WeldContainer in project core by weld.
the class WeldSEProviderTest method testDependentInstanceDestroyedDuringShutdown.
@Test
public void testDependentInstanceDestroyedDuringShutdown() {
Baz.DISPOSED.set(false);
try (WeldContainer weldContainer = new Weld().disableDiscovery().beanClasses(Baz.class).initialize()) {
assertTrue(CDI.current().select(Baz.class).get().ping());
assertFalse(Baz.DISPOSED.get());
}
assertTrue(Baz.DISPOSED.get());
}
use of org.jboss.weld.environment.se.WeldContainer in project core by weld.
the class WeldSEProviderTest method testMultipleContainers.
@Test
public void testMultipleContainers() {
Weld weld = new Weld().disableDiscovery();
try {
WeldContainer weldContainer1 = weld.containerId("foo").beanClasses(Foo.class).initialize();
WeldContainer weldContainer2 = weld.containerId("bar").beanClasses(Bar.class).initialize();
// The caller cannot be used to determine the right container - the first one is returned
assertCdi(CDI.current(), weldContainer1.getId());
// Foo is caller
assertCdi(weldContainer1.select(Foo.class).get().getCurrent(), weldContainer1.getId());
// Bar is caller
assertCdi(weldContainer2.select(Bar.class).get().getCurrent(), weldContainer2.getId());
} finally {
weld.shutdown();
}
}
use of org.jboss.weld.environment.se.WeldContainer in project core by weld.
the class PostConstructInheritanceTest method testPostConstructInherited.
@Test
public void testPostConstructInherited() {
Weld weld = new Weld();
try {
Plant.postConstructCalled = false;
WeldContainer weldContainer = weld.initialize();
weldContainer.instance().select(Tree.class).get();
assertTrue(Plant.postConstructCalled);
} finally {
weld.shutdown();
}
}
use of org.jboss.weld.environment.se.WeldContainer in project core by weld.
the class InterceptorEnabledForAppAndArchiveTest method testInitialization.
@Test
public void testInitialization() {
try (WeldContainer container = new Weld().disableDiscovery().beanClasses(TransasctionalService.class, TransactionalInterceptor.class).addInterceptor(TransactionalInterceptor.class).initialize()) {
ActionSequence.reset();
container.select(TransasctionalService.class).get().ping();
ActionSequence.assertSequenceDataEquals(TransactionalInterceptor.class.getName());
}
}
use of org.jboss.weld.environment.se.WeldContainer in project core by weld.
the class InjectionPointTest method testInjectionPoint.
@Test
public void testInjectionPoint() throws Exception {
try (WeldContainer weld = new Weld().disableDiscovery().beanClasses(Foo.class).initialize()) {
final InjectionPoint ip = weld.select(Foo.class).get().getIp();
assertEquals(Foo.class, ip.getType());
}
}
Aggregations