1 Reply Latest reply on Aug 19, 2015 8:59 AM by Wolfgang Mayer

    How to run JUnit Tests on EJB with embedded container

    Jorge Perea Newbie

      Hi guys,

       

       

      I'm making my first EAP project and I need some help. I want to test my business layer using JUnit but I haven't been able to. While looking on the internet, I found that since EJB 3.1 it's possible to use an embedded container to test my EJB, I'm using Wildfly for AS but I can't get the test running, I think it is because I lack some configuration.

      I saw this sample code on a website, could you tell me what should I put if I'm using Wildfly?

      @Before

      public void setup() {

          Properties properties = new Properties();

          properties.setProperty(EJBContainer.MODULES, "myModule");

          properties.put(EJBContainer.PROVIDER, "tomee-embedded");

          Context context = EJBContainer.createEJBContainer().getContext();

      }

       

      @After

      public void tearDown() throws NamingException {

          ejbContainer.close();

       

       

      Any help is kindly appreciated.