8 Replies Latest reply on May 24, 2014 12:57 PM by besolov

    Injecting EJB into tests

    besolov

      Hi all!

       

      I'm trying to write simple tests using arquillian and ran into a problem. Arquillian doesn't inject EJB into field annotaded by @EJB annotation. If I add "beans.xml" it works fine, but the test passes, even if I delete an annotation @Stateless from my EJB. Can anybody help me?

       

      I'm using gradle.

       

      Container: org.jboss.as:jboss-as-arquillian-container-remote:7.2.0.Final

       

      My EJB:

      @Stateless
      public class HelloEJB {
      
          public String sayHelloEJB(String name) {
      
              return "Hello " + name;
          }
      }
      
      
      

       

      My test:

      @RunWith(Arquillian.class)
      public class HelloEJBIT {
      
          @EJB
          private HelloEJB helloEJB;
      
          @Deployment
          public static JavaArchive createTestArchive() {
              return ShrinkWrap.create(JavaArchive.class)
                      .addClasses(HelloEJB.class);
          }
      
          @Test
          public void testHelloEJB() {
              assertNotNull(helloEJB);
              String result = helloEJB.sayHelloEJB("Roman");
              assertEquals("Hello Roman", result);
          }
      }