jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1412909 - in /jackrabbit/oak/trunk/oak-jcr: pom.xml src/main/java/org/apache/jackrabbit/oak/jcr/OakRepositoryStubBase.java src/test/java/org/apache/jackrabbit/oak/jcr/OakRepositoryStub.java
Date Fri, 23 Nov 2012 15:13:42 GMT
Author: alexparvulescu
Date: Fri Nov 23 15:13:40 2012
New Revision: 1412909

URL: http://svn.apache.org/viewvc?rev=1412909&view=rev
Log:
OAK-456 RepositoryInitializer for the lucene global index used in tests
 - moved OakRepositoryStub to main so that it can be used from other projects as well

Added:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/OakRepositoryStubBase.java
  (contents, props changed)
      - copied, changed from r1411613, jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakRepositoryStub.java
Modified:
    jackrabbit/oak/trunk/oak-jcr/pom.xml
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakRepositoryStub.java

Modified: jackrabbit/oak/trunk/oak-jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/pom.xml?rev=1412909&r1=1412908&r2=1412909&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-jcr/pom.xml Fri Nov 23 15:13:40 2012
@@ -382,7 +382,7 @@
       <groupId>org.apache.jackrabbit</groupId>
       <artifactId>jackrabbit-jcr-tests</artifactId>
       <version>${jackrabbit.version}</version>
-      <scope>test</scope>
+      <optional>true</optional>
     </dependency>
   </dependencies>
 </project>

Copied: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/OakRepositoryStubBase.java
(from r1411613, jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakRepositoryStub.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/OakRepositoryStubBase.java?p2=jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/OakRepositoryStubBase.java&p1=jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakRepositoryStub.java&r1=1411613&r2=1412909&rev=1412909&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakRepositoryStub.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/OakRepositoryStubBase.java
Fri Nov 23 15:13:40 2012
@@ -32,7 +32,7 @@ import org.apache.jackrabbit.oak.securit
 import org.apache.jackrabbit.test.NotExecutableException;
 import org.apache.jackrabbit.test.RepositoryStub;
 
-public class OakRepositoryStub extends RepositoryStub {
+public class OakRepositoryStubBase extends RepositoryStub {
 
     private final Repository repository;
 
@@ -42,26 +42,20 @@ public class OakRepositoryStub extends R
      * @param settings repository settings
      * @throws javax.jcr.RepositoryException If an error occurs.
      */
-    public OakRepositoryStub(Properties settings) throws RepositoryException {
+    public OakRepositoryStubBase(Properties settings) throws RepositoryException {
         super(settings);
 
         // TODO: OAK-17. workaround for missing test configuration
         Configuration.setConfiguration(new OakConfiguration());
 
         String dir = "target/mk-tck-" + System.currentTimeMillis();
-        repository = new Jcr(new MicroKernelImpl(dir))
-            .with(Executors.newScheduledThreadPool(1))
-            .createRepository();
-
-        Session session = repository.login(superuser);
-        try {
-            TestContentLoader loader = new TestContentLoader();
-            loader.loadTestContent(session);
-        } catch (Exception e) {
-            e.printStackTrace(System.err);
-        } finally {
-            session.logout();
-        }
+        Jcr jcr = new Jcr(new MicroKernelImpl(dir));
+        jcr.with(Executors.newScheduledThreadPool(1));
+        preCreateRepository(jcr);
+        repository = jcr.createRepository();
+    }
+
+    protected void preCreateRepository(Jcr jcr) {
     }
 
     /**

Propchange: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/OakRepositoryStubBase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakRepositoryStub.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakRepositoryStub.java?rev=1412909&r1=1412908&r2=1412909&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakRepositoryStub.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakRepositoryStub.java
Fri Nov 23 15:13:40 2012
@@ -16,25 +16,11 @@
  */
 package org.apache.jackrabbit.oak.jcr;
 
-import java.security.Principal;
 import java.util.Properties;
-import java.util.concurrent.Executors;
-import javax.jcr.Credentials;
-import javax.jcr.GuestCredentials;
-import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
-import javax.jcr.UnsupportedRepositoryOperationException;
-import javax.security.auth.login.Configuration;
 
-import org.apache.jackrabbit.mk.core.MicroKernelImpl;
-import org.apache.jackrabbit.oak.security.OakConfiguration;
-import org.apache.jackrabbit.test.NotExecutableException;
-import org.apache.jackrabbit.test.RepositoryStub;
-
-public class OakRepositoryStub extends RepositoryStub {
-
-    private final Repository repository;
+public class OakRepositoryStub extends OakRepositoryStubBase {
 
     /**
      * Constructor as required by the JCR TCK.
@@ -45,15 +31,7 @@ public class OakRepositoryStub extends R
     public OakRepositoryStub(Properties settings) throws RepositoryException {
         super(settings);
 
-        // TODO: OAK-17. workaround for missing test configuration
-        Configuration.setConfiguration(new OakConfiguration());
-
-        String dir = "target/mk-tck-" + System.currentTimeMillis();
-        repository = new Jcr(new MicroKernelImpl(dir))
-            .with(Executors.newScheduledThreadPool(1))
-            .createRepository();
-
-        Session session = repository.login(superuser);
+        Session session = getRepository().login(superuser);
         try {
             TestContentLoader loader = new TestContentLoader();
             loader.loadTestContent(session);
@@ -63,37 +41,4 @@ public class OakRepositoryStub extends R
             session.logout();
         }
     }
-
-    /**
-     * Returns the configured repository instance.
-     * 
-     * @return the configured repository instance.
-     */
-    @Override
-    public synchronized Repository getRepository() {
-        return repository;
-    }
-
-    @Override
-    public Credentials getReadOnlyCredentials() {
-        return new GuestCredentials();
-    }
-
-    @Override
-    public Principal getKnownPrincipal(Session session) throws RepositoryException {
-        throw new UnsupportedRepositoryOperationException();
-    }
-
-    private static final Principal UNKNOWN_PRINCIPAL = new Principal() {
-        @Override
-        public String getName() {
-            return "an_unknown_user";
-        }
-    };
-
-    @Override
-    public Principal getUnknownPrincipal(Session session) throws RepositoryException, NotExecutableException
{
-        return UNKNOWN_PRINCIPAL;
-    }
-
 }



Mime
View raw message