1 package org
.argeo
.jackrabbit
.unit
;
5 import javax
.jcr
.Repository
;
7 import org
.apache
.commons
.io
.FileUtils
;
8 import org
.apache
.jackrabbit
.core
.RepositoryImpl
;
9 import org
.apache
.jackrabbit
.core
.config
.RepositoryConfig
;
10 import org
.argeo
.jcr
.unit
.AbstractJcrTestCase
;
12 /** Factorizes configuration of an in memory transient repository */
13 public abstract class AbstractJackrabbitTestCase
extends AbstractJcrTestCase
{
14 protected RepositoryImpl repositoryImpl
;
16 // protected File getRepositoryFile() throws Exception {
17 // Resource res = new ClassPathResource(
18 // "org/argeo/jackrabbit/unit/repository-memory.xml");
19 // return res.getFile();
22 public AbstractJackrabbitTestCase() {
23 URL url
= AbstractJackrabbitTestCase
.class.getResource("jaas.config");
25 System
.setProperty("java.security.auth.login.config", url
.toString());
28 protected Repository
createRepository() throws Exception
{
29 // Repository repository = new TransientRepository(getRepositoryFile(),
31 RepositoryConfig repositoryConfig
= RepositoryConfig
.create(
32 AbstractJackrabbitTestCase
.class
33 .getResourceAsStream(getRepositoryConfigResource()),
34 getHomeDir().getAbsolutePath());
35 RepositoryImpl repositoryImpl
= RepositoryImpl
.create(repositoryConfig
);
36 return repositoryImpl
;
39 protected String
getRepositoryConfigResource() {
40 return "repository-memory.xml";
44 protected void clearRepository(Repository repository
) throws Exception
{
45 RepositoryImpl repositoryImpl
= (RepositoryImpl
) repository
;
46 if (repositoryImpl
!= null)
47 repositoryImpl
.shutdown();
48 FileUtils
.deleteDirectory(getHomeDir());