Search in sources :

Example 11 with WeldContainer

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

the class DefaultIndyConfigFactoryTest method weldInjection_writeDefaults.

@Test
public void weldInjection_writeDefaults() throws IOException, ConfigurationException {
    Weld weld = new Weld();
    WeldContainer container = weld.initialize();
    DefaultIndyConfigFactory factory = container.instance().select(DefaultIndyConfigFactory.class).get();
    File dir = temp.newFolder("indy-config");
    dir.mkdirs();
    factory.writeDefaultConfigs(dir);
    assertThat(new File(dir, "main.conf").exists(), equalTo(true));
}
Also used : WeldContainer(org.jboss.weld.environment.se.WeldContainer) File(java.io.File) Weld(org.jboss.weld.environment.se.Weld) Test(org.junit.Test)

Example 12 with WeldContainer

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

the class CDIExample method main.

public static void main(String[] args) {
    Weld w = new Weld();
    WeldContainer wc = w.initialize();
    CDIExample bean = wc.instance().select(CDIExample.class).get();
    bean.go(System.out);
    w.shutdown();
}
Also used : WeldContainer(org.jboss.weld.environment.se.WeldContainer) Weld(org.jboss.weld.environment.se.Weld)

Example 13 with WeldContainer

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

the class CDIExampleWithInclusionTest method testGo.

@Test
public void testGo() {
    Weld w = new Weld();
    WeldContainer wc = w.initialize();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(baos);
    CDIExampleWithInclusion bean = wc.instance().select(CDIExampleWithInclusion.class).get();
    bean.go(ps);
    ps.close();
    String actual = new String(baos.toByteArray());
    String expected = "" + "Dave: Hello, HAL. Do you read me, HAL?" + NL + "HAL: Dave. I read you." + NL + "Dave: Open the pod bay doors, HAL." + NL + "HAL: I'm sorry, Dave. I'm afraid I can't do that." + NL;
    assertEquals(expected, actual);
    w.shutdown();
}
Also used : PrintStream(java.io.PrintStream) WeldContainer(org.jboss.weld.environment.se.WeldContainer) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Weld(org.jboss.weld.environment.se.Weld) Test(org.junit.Test)

Example 14 with WeldContainer

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

the class CDIExampleTest method testGo.

@Test
public void testGo() {
    Weld w = new Weld();
    WeldContainer wc = w.initialize();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(baos);
    CDIExample bean = wc.instance().select(CDIExample.class).get();
    bean.go(ps);
    ps.close();
    String actual = new String(baos.toByteArray());
    String expected = "" + "Dave: Hello, HAL. Do you read me, HAL?" + NL + "HAL: Dave. I read you." + NL;
    assertEquals(expected, actual);
    w.shutdown();
}
Also used : PrintStream(java.io.PrintStream) WeldContainer(org.jboss.weld.environment.se.WeldContainer) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Weld(org.jboss.weld.environment.se.Weld) Test(org.junit.Test)

Example 15 with WeldContainer

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

the class CDIInstanceExampleTest method testGo.

@Test
public void testGo() {
    Weld w = new Weld();
    WeldContainer wc = w.initialize();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(baos);
    CDIInstanceExample bean = wc.instance().select(CDIInstanceExample.class).get();
    bean.go(ps);
    ps.close();
    String actual = new String(baos.toByteArray());
    String expected = "" + "Dave: Hello, HAL. Do you read me, HAL?" + NL + "HAL: Dave. I read you." + NL;
    assertEquals(expected, actual);
    w.shutdown();
}
Also used : PrintStream(java.io.PrintStream) WeldContainer(org.jboss.weld.environment.se.WeldContainer) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Weld(org.jboss.weld.environment.se.Weld) Test(org.junit.Test)

Aggregations

WeldContainer (org.jboss.weld.environment.se.WeldContainer)16 Weld (org.jboss.weld.environment.se.Weld)12 Test (org.junit.Test)9 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 PrintStream (java.io.PrintStream)3 BeanManager (javax.enterprise.inject.spi.BeanManager)3 File (java.io.File)1 URL (java.net.URL)1 URLClassLoader (java.net.URLClassLoader)1 ArrayList (java.util.ArrayList)1 Bean (javax.enterprise.inject.spi.Bean)1 NamingException (javax.naming.NamingException)1 KieServicesImpl (org.drools.compiler.kie.builder.impl.KieServicesImpl)1 Statement (org.junit.runners.model.Statement)1