Search in sources :

Example 1 with SE_BOOTSTRAP

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");
    }
}
Also used : Any(jakarta.enterprise.inject.Any) SE_CONTAINER(org.jboss.cdi.tck.cdi.Sections.SE_CONTAINER) EmptyAsset(org.jboss.shrinkwrap.api.asset.EmptyAsset) InjectLiteral(jakarta.enterprise.inject.literal.InjectLiteral) SeContainer(jakarta.enterprise.inject.se.SeContainer) Assert.assertEquals(org.testng.Assert.assertEquals) Pear(org.jboss.cdi.tck.tests.se.container.testPackage.nestedPackage.Pear) Test(org.testng.annotations.Test) Worm(org.jboss.cdi.tck.tests.se.container.testPackage.Worm) Instance(jakarta.enterprise.inject.Instance) Bean(jakarta.enterprise.inject.spi.Bean) SE_CONTAINER_INITIALIZER(org.jboss.cdi.tck.cdi.Sections.SE_CONTAINER_INITIALIZER) SpecVersion(org.jboss.test.audit.annotations.SpecVersion) SpecAssertion(org.jboss.test.audit.annotations.SpecAssertion) Assert.assertFalse(org.testng.Assert.assertFalse) BeanManager(jakarta.enterprise.inject.spi.BeanManager) Assert.assertNotEquals(org.testng.Assert.assertNotEquals) ShrinkWrap(org.jboss.shrinkwrap.api.ShrinkWrap) Arquillian(org.jboss.arquillian.testng.Arquillian) SpecAssertions(org.jboss.test.audit.annotations.SpecAssertions) Set(java.util.Set) Assert.assertNotNull(org.testng.Assert.assertNotNull) Archive(org.jboss.shrinkwrap.api.Archive) ClassPath(org.jboss.arquillian.container.se.api.ClassPath) SeContainerInitializer(jakarta.enterprise.inject.se.SeContainerInitializer) Deployment(org.jboss.arquillian.container.test.api.Deployment) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) SE(org.jboss.cdi.tck.TestGroups.SE) SE_BOOTSTRAP(org.jboss.cdi.tck.cdi.Sections.SE_BOOTSTRAP) Assert.assertTrue(org.testng.Assert.assertTrue) Optional(java.util.Optional) Apple(org.jboss.cdi.tck.tests.se.container.testPackage.Apple) SeContainer(jakarta.enterprise.inject.se.SeContainer) SeContainerInitializer(jakarta.enterprise.inject.se.SeContainerInitializer) Bean(jakarta.enterprise.inject.spi.Bean) SpecAssertions(org.jboss.test.audit.annotations.SpecAssertions) Test(org.testng.annotations.Test)

Example 2 with SE_BOOTSTRAP

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");
    }
}
Also used : Any(jakarta.enterprise.inject.Any) SE_CONTAINER(org.jboss.cdi.tck.cdi.Sections.SE_CONTAINER) EmptyAsset(org.jboss.shrinkwrap.api.asset.EmptyAsset) InjectLiteral(jakarta.enterprise.inject.literal.InjectLiteral) SeContainer(jakarta.enterprise.inject.se.SeContainer) Assert.assertEquals(org.testng.Assert.assertEquals) Pear(org.jboss.cdi.tck.tests.se.container.testPackage.nestedPackage.Pear) Test(org.testng.annotations.Test) Worm(org.jboss.cdi.tck.tests.se.container.testPackage.Worm) Instance(jakarta.enterprise.inject.Instance) Bean(jakarta.enterprise.inject.spi.Bean) SE_CONTAINER_INITIALIZER(org.jboss.cdi.tck.cdi.Sections.SE_CONTAINER_INITIALIZER) SpecVersion(org.jboss.test.audit.annotations.SpecVersion) SpecAssertion(org.jboss.test.audit.annotations.SpecAssertion) Assert.assertFalse(org.testng.Assert.assertFalse) BeanManager(jakarta.enterprise.inject.spi.BeanManager) Assert.assertNotEquals(org.testng.Assert.assertNotEquals) ShrinkWrap(org.jboss.shrinkwrap.api.ShrinkWrap) Arquillian(org.jboss.arquillian.testng.Arquillian) SpecAssertions(org.jboss.test.audit.annotations.SpecAssertions) Set(java.util.Set) Assert.assertNotNull(org.testng.Assert.assertNotNull) Archive(org.jboss.shrinkwrap.api.Archive) ClassPath(org.jboss.arquillian.container.se.api.ClassPath) SeContainerInitializer(jakarta.enterprise.inject.se.SeContainerInitializer) Deployment(org.jboss.arquillian.container.test.api.Deployment) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) SE(org.jboss.cdi.tck.TestGroups.SE) SE_BOOTSTRAP(org.jboss.cdi.tck.cdi.Sections.SE_BOOTSTRAP) Assert.assertTrue(org.testng.Assert.assertTrue) Optional(java.util.Optional) Apple(org.jboss.cdi.tck.tests.se.container.testPackage.Apple) SeContainer(jakarta.enterprise.inject.se.SeContainer) SeContainerInitializer(jakarta.enterprise.inject.se.SeContainerInitializer) Bean(jakarta.enterprise.inject.spi.Bean) SpecAssertions(org.jboss.test.audit.annotations.SpecAssertions) Test(org.testng.annotations.Test)

Aggregations

Any (jakarta.enterprise.inject.Any)2 Instance (jakarta.enterprise.inject.Instance)2 InjectLiteral (jakarta.enterprise.inject.literal.InjectLiteral)2 SeContainer (jakarta.enterprise.inject.se.SeContainer)2 SeContainerInitializer (jakarta.enterprise.inject.se.SeContainerInitializer)2 Bean (jakarta.enterprise.inject.spi.Bean)2 BeanManager (jakarta.enterprise.inject.spi.BeanManager)2 Optional (java.util.Optional)2 Set (java.util.Set)2 ClassPath (org.jboss.arquillian.container.se.api.ClassPath)2 Deployment (org.jboss.arquillian.container.test.api.Deployment)2 Arquillian (org.jboss.arquillian.testng.Arquillian)2 SE (org.jboss.cdi.tck.TestGroups.SE)2 SE_BOOTSTRAP (org.jboss.cdi.tck.cdi.Sections.SE_BOOTSTRAP)2 SE_CONTAINER (org.jboss.cdi.tck.cdi.Sections.SE_CONTAINER)2 SE_CONTAINER_INITIALIZER (org.jboss.cdi.tck.cdi.Sections.SE_CONTAINER_INITIALIZER)2 Apple (org.jboss.cdi.tck.tests.se.container.testPackage.Apple)2 Worm (org.jboss.cdi.tck.tests.se.container.testPackage.Worm)2 Pear (org.jboss.cdi.tck.tests.se.container.testPackage.nestedPackage.Pear)2 Archive (org.jboss.shrinkwrap.api.Archive)2