use of org.jboss.weld.environment.se.test.weldManager.contextActive.TheLoneBean in project core by weld.
the class GetContextUtilMethodsTest method getActiveContextsTest.
@Test
public void getActiveContextsTest() {
try (WeldContainer container = new Weld().initialize()) {
// TheLoneBean is just to have some bean in the archive
container.select(TheLoneBean.class).get().ping();
WeldManager manager = container.select(WeldManager.class).get();
// there are 7 scopes by default in SE, only 3 have active contexts by default
// it is dependent, singleton and application
Collection<Context> activeContexts = manager.getActiveContexts();
Assert.assertEquals(3, activeContexts.size());
Set<Class<? extends Annotation>> scopes = activeContexts.stream().map(t -> t.getScope()).collect(Collectors.toSet());
Assert.assertTrue(scopes.contains(Dependent.class));
Assert.assertTrue(scopes.contains(Singleton.class));
Assert.assertTrue(scopes.contains(ApplicationScoped.class));
}
}
Aggregations