jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruno Dusausoy <bdusau...@yp5.be>
Subject All in-memory and unit/integration tests
Date Tue, 29 Mar 2011 09:02:35 GMT

I'm quite new to Jackrabbit and I have a question regarding 
unit/integration tests.

I'm testing if my data are being saved into the repository.
I'm using a TransientRepository for that purpose. But since I don't have 
a specific configuration, it saves everything in the file system, which 
is fine but slow, too slow for a unit/integration test.
So I googled a bit and found an article about how to speed up tests with 
The problem is that, if I do the changes they recommend, I lose all my 
data between the sessions, which is of course not what I want.

I got this kind of code in my tests :

     public void setUp() {
         repository = new TransientRepository(JACKRABBIT_CONFIG, 
         management = new JackrabbitModelManagement();

     public void tearDown() {

     public void testSetModelDescriptorWithoutIdNode() throws Exception {
         BaseModelVersionDescriptor descriptor =
                 new BaseModelVersionDescriptor(new 
BaseModelDescriptor(1, "first"), "1.0", 1);
         String content = "foo";
         InputStream input = IOUtils.toInputStream(content);

         // Method to test.
         management.setModelDescriptor(descriptor, input);

         Session session = repository.login(new 
SimpleCredentials(username, password.toCharArray()));
         // Retrieve content
         Node root = session.getRootNode();
         Node node = root.getNode("1/1.0/model/jcr:content");
         String actual = node.getProperty("jcr:data").getString();
         assertEquals(content, actual);

My code used to retrieve the content throws a PathNotFoundException 
because data has been lost between the two sessions (my 
management.setModelDescriptor() method opens and then closes a session.)

So is there a recommended way to use a "all-in-memory" configuration for 
use with tests ?


Pensez environnement : limitez l'impression de ce mail.
Please don't print this e-mail unless you really need to.

View raw message