jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Mueller <muel...@adobe.com>
Subject Re: All in-memory and unit/integration tests
Date Tue, 29 Mar 2011 09:23:07 GMT

I'm not sure if the in-memory persistence manager is still supported (it
has been deprecated). What does work is using an in-memory Java database
such as the H2 database, and use it as the persistence manager and file
system. To ensure the data is not deleted between two runs (within the
same process), you could use the database URL "jdbc:h2:memFS:test" - see
also http://h2database.com/html/advanced.html#file_system

Also, you should disable the Lucene index. You will still need a
repository.xml file I believe (not sure if this can be avoided).


On 3/29/11 11:02 AM, "Bruno Dusausoy" <bdusausoy@yp5.be> wrote:

>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 :
>     @Before
>     public void setUp() {
>         FileUtils.deleteQuietly(JACKRABBIT_REPOSITORY);
>         repository = new TransientRepository(JACKRABBIT_CONFIG,
>         management = new JackrabbitModelManagement();
>         management.setUsername(username);
>         management.setPassword(password);
>         management.setRepository(repository);
>     }
>     @After
>     public void tearDown() {
>         FileUtils.deleteQuietly(JACKRABBIT_REPOSITORY);
>     }
>     @Test
>     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);
>         session.logout();
>     }
>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