use of org.jboss.cdi.tck.cdi.Sections.SE_BOOTSTRAP in project cdi-tck by eclipse-ee4j.
the class BootstrapSEContainerTest method testAlternativesInSE.
@Test
@SpecAssertions({ @SpecAssertion(section = SE_CONTAINER_INITIALIZER, id = "a"), @SpecAssertion(section = SE_BOOTSTRAP, id = "db"), @SpecAssertion(section = SE_BOOTSTRAP, id = "dh"), @SpecAssertion(section = SE_BOOTSTRAP, id = "di"), @SpecAssertion(section = SE_BOOTSTRAP, id = "dm"), @SpecAssertion(section = SE_CONTAINER_INITIALIZER, id = "b") })
public void testAlternativesInSE() {
SeContainerInitializer seContainerInitializer = SeContainerInitializer.newInstance();
try (SeContainer seContainer = seContainerInitializer.disableDiscovery().addBeanClasses(Square.class, Circle.class, Foo.class, FooProducer.class).selectAlternatives(Circle.class).selectAlternativeStereotypes(AlternativeStereotype.class).initialize()) {
Shape shape = seContainer.select(Shape.class).get();
assertEquals(shape.name(), Circle.NAME);
Set<Bean<?>> foos = seContainer.getBeanManager().getBeans(Foo.class);
Optional<Bean<?>> alternativeFoo = foos.stream().filter(bean -> bean.isAlternative()).findAny();
assertTrue(alternativeFoo.isPresent());
assertEquals(alternativeFoo.get().getName(), "createFoo");
}
}
use of org.jboss.cdi.tck.cdi.Sections.SE_BOOTSTRAP in project cdi-tck by jakartaee.
the class BootstrapSEContainerTest method testAlternativesInSE.
@Test
@SpecAssertions({ @SpecAssertion(section = SE_CONTAINER_INITIALIZER, id = "a"), @SpecAssertion(section = SE_BOOTSTRAP, id = "db"), @SpecAssertion(section = SE_BOOTSTRAP, id = "dh"), @SpecAssertion(section = SE_BOOTSTRAP, id = "di"), @SpecAssertion(section = SE_BOOTSTRAP, id = "dm"), @SpecAssertion(section = SE_CONTAINER_INITIALIZER, id = "b") })
public void testAlternativesInSE() {
SeContainerInitializer seContainerInitializer = SeContainerInitializer.newInstance();
try (SeContainer seContainer = seContainerInitializer.disableDiscovery().addBeanClasses(Square.class, Circle.class, Foo.class, FooProducer.class).selectAlternatives(Circle.class).selectAlternativeStereotypes(AlternativeStereotype.class).initialize()) {
Shape shape = seContainer.select(Shape.class).get();
assertEquals(shape.name(), Circle.NAME);
Set<Bean<?>> foos = seContainer.getBeanManager().getBeans(Foo.class);
Optional<Bean<?>> alternativeFoo = foos.stream().filter(bean -> bean.isAlternative()).findAny();
assertTrue(alternativeFoo.isPresent());
assertEquals(alternativeFoo.get().getName(), "createFoo");
}
}
Aggregations