0 Replies Latest reply on Mar 12, 2018 9:03 AM by Bart Krul

    Wildfly + Arquillian EntityManager

    Bart Krul Newbie


      I setup Arquillain testing.
      Some tests worked, and I use hibernate to recreate my database tables when the unittests start.

      So in the @BeforeClass I want to add some data to my database using the entityManager.
      However, I get a nullpointer exception when trying to persist something with the entitymanager.
      Here is my TestClass:



      public class ProfileServiceTest {

         public static JavaArchive createDeployment() {

         return ShrinkWrap.create(JavaArchive.class)

        .addPackages(true, "dao", "dto", "entities", "filters", "rest", "security", "services")

        .addAsResource("test-persistence.xml", "META-INF/persistence.xml")

        .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");


         @PersistenceContext(name = "kwetterTestPu")

         private static EntityManager entityManager;

        private static Profile p1;
        private static Profile p2;
        private static String name1;
        private static String name2;
        private static String email1;
        private static String email2;
        private static String password;

         public static void setup(){

         name1 = "Bart";
         name2 = "Jules";
         email1 = "Bart@email.com";
         email2 = "Jules@email.com";
         password = "password";

         p1 = new Profile(email1,password, name1);
         p2 = new Profile(email2, password, name2);



      I found this topic on StackOverflow:


      But there is no answer posted.


      What am I doing wrong?