jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r776036 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java
Date Mon, 18 May 2009 18:21:23 GMT
Author: jukka
Date: Mon May 18 18:21:23 2009
New Revision: 776036

URL: http://svn.apache.org/viewvc?rev=776036&view=rev
Log:
JCR-2055: RepositoryStub implementation in jackrabbit-core

Allow a subclass of JackrabbityRepositoryStub to customize the type of the repository being
created for the test cases.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java?rev=776036&r1=776035&r2=776036&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java
Mon May 18 18:21:23 2009
@@ -26,9 +26,8 @@
 import java.security.acl.Group;
 import java.util.Arrays;
 import java.util.Calendar;
-import java.util.HashSet;
+import java.util.Collection;
 import java.util.Properties;
-import java.util.Set;
 
 import javax.jcr.Node;
 import javax.jcr.PathNotFoundException;
@@ -137,30 +136,12 @@
                     dir = new File("target", "repository").getPath();
                 }
 
-                new File(dir).mkdirs();
-
                 String xml = settings.getProperty(PROP_REPOSITORY_CONFIG);
                 if (xml == null) {
                     xml = new File(dir, "repository.xml").getPath();
                 }
 
-                if (!new File(xml).exists()) {
-                    InputStream input = getResource("repository.xml");
-                    try {
-                        OutputStream output = new FileOutputStream(xml);
-                        try {
-                            IOUtils.copy(input, output);
-                        } finally {
-                            output.close();
-                        }
-                    } finally {
-                        input.close();
-                    }
-                }
-
-                RepositoryConfig config = RepositoryConfig.create(xml, dir);
-                repository = RepositoryImpl.create(config);
-
+                repository = createRepository(dir, xml);
                 Session session = repository.login(superuser);
                 try {
                     prepareTestContent(session);
@@ -177,12 +158,34 @@
         return repository;
     }
 
+    protected Repository createRepository(String dir, String xml)
+            throws Exception {
+        new File(dir).mkdirs();
+
+        if (!new File(xml).exists()) {
+            InputStream input = getResource("repository.xml");
+            try {
+                OutputStream output = new FileOutputStream(xml);
+                try {
+                    IOUtils.copy(input, output);
+                } finally {
+                    output.close();
+                }
+            } finally {
+                input.close();
+            }
+        }
+
+        RepositoryConfig config = RepositoryConfig.create(xml, dir);
+        return RepositoryImpl.create(config);
+    }
+
     private void prepareTestContent(Session session)
             throws RepositoryException, IOException {
         JackrabbitWorkspace workspace =
             (JackrabbitWorkspace) session.getWorkspace();
-        Set workspaces = new HashSet(
-                Arrays.asList(workspace.getAccessibleWorkspaceNames()));
+        Collection<String> workspaces =
+            Arrays.asList(workspace.getAccessibleWorkspaceNames());
         if (!workspaces.contains("test")) {
             workspace.createWorkspace("test");
         }



Mime
View raw message