4 Replies Latest reply on Feb 13, 2015 9:51 PM by Tung Tran

    Why CDI works with the managed container?

    Tung Tran Newbie

      After watched this video https://www.youtube.com/watch?v=YKZU9XNRRNY I thought we couldn't consume the resources such as EJB, CDI while using a managed container. Whereas I saw a test with a managed container can inject the CDI bean  arquillian-examples/GreeterTest.java at master · arquillian/arquillian-examples · GitHub.


      package org.arquillian.example;
      import javax.inject.Inject;
      import org.jboss.arquillian.container.test.api.Deployment;
      import org.jboss.arquillian.junit.Arquillian;
      import org.jboss.shrinkwrap.api.ShrinkWrap;
      import org.jboss.shrinkwrap.api.asset.EmptyAsset;
      import org.jboss.shrinkwrap.api.spec.JavaArchive;
      import org.junit.Test;
      import org.junit.Assert;
      import org.junit.runner.RunWith;
       * @author <a href="http://community.jboss.org/people/dan.j.allen">Dan Allen</a>
      public class GreeterTest {
          public static JavaArchive createDeployment() {
              JavaArchive jar = ShrinkWrap.create(JavaArchive.class)
                  .addClasses(Greeter.class, PhraseBuilder.class)
                  .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
              // System.out.println(jar.toString(true));
              return jar;
          Greeter greeter;
          public void should_create_greeting() {
              Assert.assertEquals("Hello, Earthling!",
              greeter.greet(System.out, "Earthling");


      Somebody help me understand this, please!