1 package org
.argeo
.server
.jackrabbit
.unit
;
5 import javax
.jcr
.Repository
;
6 import javax
.jcr
.Session
;
7 import javax
.jcr
.SimpleCredentials
;
9 import junit
.framework
.TestCase
;
11 import org
.apache
.commons
.io
.FileUtils
;
12 import org
.apache
.jackrabbit
.core
.TransientRepository
;
13 import org
.argeo
.ArgeoException
;
15 public abstract class AbstractJcrTestCase
extends TestCase
{
16 private TransientRepository repository
;
17 private Session session
= null;
19 protected abstract File
getRepositoryFile() throws Exception
;
22 protected void setUp() throws Exception
{
23 File homeDir
= new File(System
.getProperty("java.io.tmpdir"),
24 AbstractJcrTestCase
.class.getSimpleName());
25 FileUtils
.deleteDirectory(homeDir
);
26 repository
= new TransientRepository(getRepositoryFile(), homeDir
);
30 protected void tearDown() throws Exception
{
35 protected Session
session() {
36 if (session
== null) {
38 session
= getRepository().login(
39 new SimpleCredentials("demo", "demo".toCharArray()));
40 } catch (Exception e
) {
41 throw new ArgeoException("Cannot login to repository", e
);
47 protected Repository
getRepository() {