2 Replies Latest reply on Nov 21, 2015 6:20 PM by Sverker Abrahamsson

    Persistence seeding for tests before ejb's are started

    Sverker Abrahamsson Newbie

      I am writing integration tests for an ejb application. It uses several Singleton beans annotated with @Startup to set up the base plumbing of the application. That means that for my tests I need to initialize the database before those singletons are started but after the persistence context is deployed. I've looked at various desciptions, like Testing Java Persistence · Arquillian Guides and arquillian/arquillian-extension-persistence · GitHub but in both those cases the db initialization will happen after the Singletons have started.


      The best way I've found so far is to add another Singleton, which I call SetupDB when I build the deployment which set up the base plumbing of the db. This works perfectly IF I manually add a @DependsOn annotation to my Bootstrap singleton, as all other Singletons depends on that one.


      I have tried to add that annotation at runtime with javassist but that has not been successful. I am creating the deployment from the actual jar built by maven and it seems that I am not successful on replacing that class there with the one I've added annotation on.


      Does anybody have a recipe for how to solve this task?