Search in sources :

Example 66 with WeldContainer

use of org.jboss.weld.environment.se.WeldContainer in project core by weld.

the class ProbeJmxIntegrationTest method testReceiveBeans.

@Test
public void testReceiveBeans() throws Exception {
    try (WeldContainer container = new Weld().initialize()) {
        assertNotNull(container.select(ProbeExtension.class).get());
        container.select(Omega.class).get().ping();
        Object[] params = new Object[] { 0, 50, "", "" };
        String[] signature = new String[] { int.class.getName(), int.class.getName(), String.class.getName(), String.class.getName() };
        JsonObject obj = invokeMBeanOperation("receiveBeans", params, signature);
        JsonArray beansDataArray = obj.getJsonArray(Strings.DATA);
        JsonObject omegaBeanJson = getJsonObjectByClass(beansDataArray, Omega.class);
        assertNotNull(omegaBeanJson);
        assertEquals(omegaBeanJson.getJsonString(Strings.SCOPE).getString(), "@" + Dependent.class.getSimpleName());
    }
}
Also used : JsonArray(javax.json.JsonArray) WeldContainer(org.jboss.weld.environment.se.WeldContainer) JsonObject(javax.json.JsonObject) JsonObject(javax.json.JsonObject) Weld(org.jboss.weld.environment.se.Weld) Test(org.junit.Test)

Example 67 with WeldContainer

use of org.jboss.weld.environment.se.WeldContainer in project core by weld.

the class AdditionalBeanArchiveHandlerTest method testAdditionalBeanArchiveHandlerUsed.

@Test
public void testAdditionalBeanArchiveHandlerUsed() {
    URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory() {

        @Override
        public URLStreamHandler createURLStreamHandler(String protocol) {
            return new TestURLStreamHandler();
        }
    });
    try (WeldContainer container = new Weld().setResourceLoader(new TestResourceLoader()).initialize()) {
        // Bar is available, Foo is not (TestBeanArchiveHandler2 has higher priority)
        assertTrue(container.select(Bar.class).isResolvable());
        assertFalse(container.select(Foo.class).isResolvable());
    }
}
Also used : URLStreamHandler(java.net.URLStreamHandler) WeldContainer(org.jboss.weld.environment.se.WeldContainer) URLStreamHandlerFactory(java.net.URLStreamHandlerFactory) Weld(org.jboss.weld.environment.se.Weld) Test(org.junit.Test)

Example 68 with WeldContainer

use of org.jboss.weld.environment.se.WeldContainer in project core by weld.

the class SyntheticArchiveDiscoveryModeChangeTest method testDiscoveryModeNone.

@Test(expected = IllegalArgumentException.class)
public void testDiscoveryModeNone() {
    Weld weld = new Weld();
    weld.disableDiscovery().setBeanDiscoveryMode(BeanDiscoveryMode.NONE).addPackages(Foo.class.getPackage(), Bar.class.getPackage());
    try (WeldContainer container = weld.initialize()) {
    }
}
Also used : Bar(org.jboss.weld.environment.se.test.discovery.synthetic.bdm.hiddenPackage.Bar) Foo(org.jboss.weld.environment.se.test.discovery.synthetic.bdm.discoveredPackage.Foo) WeldContainer(org.jboss.weld.environment.se.WeldContainer) Weld(org.jboss.weld.environment.se.Weld) Test(org.junit.Test)

Example 69 with WeldContainer

use of org.jboss.weld.environment.se.WeldContainer in project core by weld.

the class SyntheticArchiveDiscoveryModeChangeTest method testDiscoveryModeAll.

@Test
public void testDiscoveryModeAll() {
    Weld weld = new Weld();
    // this is same as default
    weld.disableDiscovery().setBeanDiscoveryMode(BeanDiscoveryMode.ALL).addPackages(Foo.class.getPackage(), Bar.class.getPackage());
    try (WeldContainer container = weld.initialize()) {
        Assert.assertTrue(container.isRunning());
        Assert.assertTrue(container.select(Foo.class).isResolvable());
        Assert.assertTrue(container.select(Bar.class).isResolvable());
    }
}
Also used : Bar(org.jboss.weld.environment.se.test.discovery.synthetic.bdm.hiddenPackage.Bar) Foo(org.jboss.weld.environment.se.test.discovery.synthetic.bdm.discoveredPackage.Foo) WeldContainer(org.jboss.weld.environment.se.WeldContainer) Weld(org.jboss.weld.environment.se.Weld) Test(org.junit.Test)

Example 70 with WeldContainer

use of org.jboss.weld.environment.se.WeldContainer in project core by weld.

the class SyntheticArchiveDiscoveryModeChangeTest method testDiscoveryModeAnnotated.

@Test
public void testDiscoveryModeAnnotated() {
    Weld weld = new Weld();
    weld.disableDiscovery().setBeanDiscoveryMode(BeanDiscoveryMode.ANNOTATED).addPackages(Foo.class.getPackage(), Bar.class.getPackage());
    try (WeldContainer container = weld.initialize()) {
        Assert.assertTrue(container.isRunning());
        Assert.assertTrue(container.select(Foo.class).isResolvable());
        Assert.assertFalse(container.select(Bar.class).isResolvable());
    }
}
Also used : Bar(org.jboss.weld.environment.se.test.discovery.synthetic.bdm.hiddenPackage.Bar) Foo(org.jboss.weld.environment.se.test.discovery.synthetic.bdm.discoveredPackage.Foo) WeldContainer(org.jboss.weld.environment.se.WeldContainer) Weld(org.jboss.weld.environment.se.Weld) Test(org.junit.Test)

Aggregations

WeldContainer (org.jboss.weld.environment.se.WeldContainer)115 Weld (org.jboss.weld.environment.se.Weld)100 Test (org.junit.Test)98 CountDownLatch (java.util.concurrent.CountDownLatch)8 Bean (javax.enterprise.inject.spi.Bean)8 BeanManager (javax.enterprise.inject.spi.BeanManager)8 Type (java.lang.reflect.Type)7 URLClassLoader (java.net.URLClassLoader)7 ArrayList (java.util.ArrayList)7 URL (java.net.URL)6 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)6 Fabric8Extension (io.fabric8.cdi.Fabric8Extension)4 ParameterizedType (java.lang.reflect.ParameterizedType)4 List (java.util.List)4 CreationalContext (javax.enterprise.context.spi.CreationalContext)4 BeanManagerImpl (org.jboss.weld.manager.BeanManagerImpl)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 File (java.io.File)3 PrintStream (java.io.PrintStream)3 ServiceRegistry (org.jboss.weld.bootstrap.api.ServiceRegistry)3