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());
}
}
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());
}
}
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()) {
}
}
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());
}
}
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());
}
}
Aggregations