I have a code accessing to content repositories through JCR API. My code is being developed in OSGI environment. What I want is to have a JCR content repository which should be available while running the unit tests regardless from the environment. I mean it should be available for any user who builds the project. I don’t want to depend on some external content repository running in a different virtual machine.
Is it possible to do such a thing? Thanks in advance.
You may also look at the transient repository provided by the Jackrabbit implementation.
(assuming you are using Jackrabbit implementation)
A Transient Repository is
Please look at the examples here – it is really easy to create an instance of it. Since it is a local repository, you will never need to go over the network.
I normally create a transient repository and a session once per JUnit test class in setUpClass/BeforeClass hook and reuse it across all the test cases, cleaning up the session ( e.g, removing the nodes I added during a test case, etc.) after each test case.
One drawback, however, using transient repository, is that it will create several repository specific files/directory in your base directory. If you are using maven, then you can use maven-clean-plugin to clean up the unwanted files as a solution.