|
| 1 | +package org.javaee8.cdi.bean.discovery.empty; |
| 2 | + |
| 3 | +import static org.junit.Assert.assertFalse; |
| 4 | + |
| 5 | +import java.util.Set; |
| 6 | + |
| 7 | +import javax.enterprise.inject.spi.Bean; |
| 8 | +import javax.enterprise.inject.spi.BeanManager; |
| 9 | +import javax.inject.Inject; |
| 10 | + |
| 11 | +import org.javaee8.cdi.bean.discovery.disabled.CdiDisabledBean; |
| 12 | +import org.javaee8.cdi.bean.discovery.enabled.CdiEnabledBean; |
| 13 | +import org.jboss.arquillian.container.test.api.Deployment; |
| 14 | +import org.jboss.arquillian.junit.Arquillian; |
| 15 | +import org.jboss.shrinkwrap.api.Archive; |
| 16 | +import org.jboss.shrinkwrap.api.ShrinkWrap; |
| 17 | +import org.jboss.shrinkwrap.api.spec.WebArchive; |
| 18 | +import org.junit.Test; |
| 19 | +import org.junit.runner.RunWith; |
| 20 | + |
| 21 | +@RunWith(Arquillian.class) |
| 22 | +public class CdiEmptyTest { |
| 23 | + |
| 24 | + @Deployment |
| 25 | + public static Archive<?> deploy() { |
| 26 | + return ShrinkWrap.create(WebArchive.class).addClasses(CdiDisabledBean.class, CdiEnabledBean.class) |
| 27 | + .addAsWebInfResource("empty-beans.xml", "beans.xml"); |
| 28 | + } |
| 29 | + |
| 30 | + @Inject |
| 31 | + BeanManager beanManager; |
| 32 | + |
| 33 | + /** |
| 34 | + * Should work the same as 'all'. |
| 35 | + */ |
| 36 | + @Test |
| 37 | + public void should_beans_be_injected() throws Exception { |
| 38 | + Set<Bean<?>> disabledBeans = beanManager.getBeans(CdiDisabledBean.class); |
| 39 | + assertFalse("Instances of disabled bean expected.", disabledBeans.isEmpty()); |
| 40 | + |
| 41 | + Set<Bean<?>> enabledBeans = beanManager.getBeans(CdiEnabledBean.class); |
| 42 | + assertFalse("Instances of enabled bean expected.", enabledBeans.isEmpty()); |
| 43 | + } |
| 44 | +} |
0 commit comments