1 Reply Latest reply on Dec 19, 2012 8:26 AM by rhauch

    Integration testing JCR based app

    mmatloka

      I am looking for idea how to test whole based on JCR application (using my API/interface etc). Modeshape is used as a JBossAS submodule, data stored in RDBMS. How I can force clean state of repository between different tests group/different executions of integration tests pack?

        • 1. Re: Integration testing JCR based app
          rhauch

          Using the database in your tests will likely be the more difficult aspect. The challenge is often setting up a clean database instance before the tests and cleaning up after the tests. There are testing frameworks that can help.

           

          ModeShape behavior should be independent of the kind of persistence, so where you can use in-memory or file-based persistence to verify functional behavior. Where you have to or want to use a database in your tests, consider using H2 with file-based persistence. File-based storage can be easily cleaned up before and after each test, and this may be simpler than doing that with a database. You'll still want a series of tests that verify the behavior of the whole system with your actual database system.

           

          In addition, I'd try to do as much testing of your server-side components outside of AS7, using embedded ModeShape. These can then be very simple and traditional JUnit/TestNG tests. This may mean you want to be able to easily configure the URL used with the RepositoryFactory, allowing different tests to use very different ModeShape configurations (embedded vs JNDI).

           

          Where you do test within AS7+ModeShape, use Arquillian as much as possible and use JUnit/TestNG tests specifically written for this environment. Arquillian can do lots of things, but at a minimum it can deploy unit tests as WAR/EAR files and run them when they are deployed within AS7.

           

          Best regards.