3 Replies Latest reply on Jul 15, 2014 2:15 AM by otinanism

    Prepopulate memory database when running client tests

    otinanism

      Hello all,

       

      I have the following requirement:

       

      I want to test my UI (using graphene and drone) but I need to login to the application before all tests. I have a Database authentication Realm in jboss which for testing uses an H2 in-memory database. So what I need is to add a user (username, password) before all tests in the users table so I can login successfully in my application.

       

      I first tried to inject my users EJB in the test class so I can create a user before all tests in the database. This is impossible because the UI tests run on the client (testable=false). It was obvious that at the time I did not know exactly how arquillian works...

       

      I then tried to use arquillian persistence extension and @UsingDataSet annotation but this also fails for the same reason (although I am not sure why, since I don't know exactly how this annotation works).

       

      Finally, I tried to create a Singleton EJB with @Startup annotation and on its @PostConstruct method create the user I need. When debugging, I can see in the H2 console that the user is created. But when I run my tests the login still fails.

       

      Can someone explain why this last case fails because I do not understand. But most importently if someone knows how to make this work I would greately appreciate it!

       

      Thank you in advance!

       

      Alexandros