jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1374309 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/core/ main/java/org/apache/jackrabbit/oak/kernel/ main/java/org/apache/jackrabbit/oak/plugins/memory/ main/java/org/apache/jackrabbit/oak/security/authori...
Date Fri, 17 Aug 2012 15:10:38 GMT
Author: angela
Date: Fri Aug 17 15:10:37 2012
New Revision: 1374309

URL: http://svn.apache.org/viewvc?rev=1374309&view=rev
Log:
OAK-251 : CommitEditor is global to ContentRepository instance  (WIP)
- add initial draft that allows to extend the commit-editor passed in to the repository constructor

OAK-51 : Implement JCR Access Control Management 
- enforce dummy permission validation upon commit

OAK-50 : UserManagement
- enforce user-validation upon commit

OAK-64 : Privilege Management 
- enforce privilege validation upon commit (currently disabled due to core-tests that don't
setup mandatory
   repository content and therefore fail).
   
OAK-125 	: Improved namespace registry 
- fixing test that expected that anonymous was allowed to register namespaces (fails with
dummy permission
   check enabled)
   
 Query tests:
 - replace usage of GuestCredentials where modifications are made to the repository

Added:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/AbstractOakTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/AbstractCoreTest.java
  (contents, props changed)
      - copied, changed from r1374165, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/AbstractOakTest.java
Removed:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/AbstractOakTest.java
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/PermissionValidatorProvider.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStoreBranch.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/DefaultConflictHandlerTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/TreeImplTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/LargeKernelNodeStateTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/AbstractLuceneQueryTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneEditorTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/name/NamespaceRegistryImplTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java?rev=1374309&r1=1374308&r2=1374309&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
Fri Aug 17 15:10:37 2012
@@ -26,10 +26,18 @@ import javax.annotation.Nonnull;
 import org.apache.jackrabbit.oak.api.ChangeExtractor;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.ConflictHandler;
+import org.apache.jackrabbit.oak.api.CoreValueFactory;
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.security.authorization.PermissionValidatorProvider;
+import org.apache.jackrabbit.oak.security.user.UserValidatorProvider;
+import org.apache.jackrabbit.oak.spi.commit.CommitEditor;
+import org.apache.jackrabbit.oak.spi.commit.CompositeValidatorProvider;
+import org.apache.jackrabbit.oak.spi.commit.ValidatingEditor;
+import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
 import org.apache.jackrabbit.oak.spi.security.authorization.AccessControlContext;
 import org.apache.jackrabbit.oak.spi.security.authorization.CompiledPermissions;
+import org.apache.jackrabbit.oak.spi.security.user.UserManagerConfig;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeStateDiff;
@@ -52,15 +60,17 @@ public class RootImpl implements Root {
     /** The underlying store to which this root belongs */
     private final NodeStore store;
 
+    private final AccessControlContext accessControlContext;
+    private CompiledPermissions permissions;
+
+    private final CommitEditor commitEditor;
+
     /** Current branch this root operates on */
     private NodeStoreBranch branch;
 
     /** Current root {@code Tree} */
     private TreeImpl rootTree;
 
-    private final AccessControlContext accessControlContext;
-    private CompiledPermissions permissions;
-
     /**
      * Number of {@link #purge()} occurred so since the lase
      * purge.
@@ -92,13 +102,12 @@ public class RootImpl implements Root {
      * @param store  node store
      * @param workspaceName  name of the workspace
      * @param accessControlContext
-     * TODO: add support for multiple workspaces. See OAK-118
      */
     @SuppressWarnings("UnusedParameters")
     public RootImpl(NodeStore store, String workspaceName, AccessControlContext accessControlContext)
{
         this.store = store;
         this.accessControlContext = accessControlContext;
-
+        this.commitEditor = createCommitEditor();
         refresh();
     }
 
@@ -148,7 +157,7 @@ public class RootImpl implements Root {
 
     @Override
     public final void refresh() {
-        branch = store.branch();
+        branch = store.branch(commitEditor);
         rootTree = TreeImpl.createRoot(this);
         permissions = this.accessControlContext.getPermissions();
     }
@@ -237,4 +246,19 @@ public class RootImpl implements Root {
             purgeListener.purged();
         }
     }
+
+    private CommitEditor createCommitEditor() {
+        CoreValueFactory valueFactory = store.getValueFactory();
+        List<ValidatorProvider> providers = new ArrayList<ValidatorProvider>();
+
+        // TODO: refactor once permissions are read from content (make sure we read from
an up to date store)
+        providers.add(new PermissionValidatorProvider(valueFactory, accessControlContext));
+        // TODO the following v-providers could be initialized at ContentRepo level
+        // FIXME: use proper configuration
+        providers.add(new UserValidatorProvider(valueFactory, new UserManagerConfig("admin")));
+        // FIXME: oak-core tests setup incomplete repository -> privilege validator fails.
+        // providers.add(new PrivilegeValidatorProvider(valueFactory));
+
+        return new ValidatingEditor(new CompositeValidatorProvider(providers));
+    }
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java?rev=1374309&r1=1374308&r2=1374309&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStore.java
Fri Aug 17 15:10:37 2012
@@ -97,8 +97,8 @@ public class KernelNodeStore implements 
     }
 
     @Override
-    public NodeStoreBranch branch() {
-        return new KernelNodeStoreBranch(this);
+    public NodeStoreBranch branch(CommitEditor commitEditor) {
+        return new KernelNodeStoreBranch(this, commitEditor);
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java?rev=1374309&r1=1374308&r2=1374309&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
Fri Aug 17 15:10:37 2012
@@ -16,11 +16,11 @@
  */
 package org.apache.jackrabbit.oak.kernel;
 
-
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.api.MicroKernelException;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.spi.commit.CommitEditor;
+import org.apache.jackrabbit.oak.spi.commit.CompositeEditor;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStoreBranch;
 
@@ -38,6 +38,9 @@ class KernelNodeStoreBranch implements N
     /** The underlying store to which this branch belongs */
     private final KernelNodeStore store;
 
+    /** The commit editor */
+    private final CommitEditor editor;
+
     /** Base state of this branch */
     private final NodeState base;
 
@@ -50,8 +53,13 @@ class KernelNodeStoreBranch implements N
     /** Last state which was committed to this branch */
     private NodeState committed;
 
-    KernelNodeStoreBranch(KernelNodeStore store) {
+    KernelNodeStoreBranch(KernelNodeStore store, CommitEditor editor) {
         this.store = store;
+        if (editor == null) {
+            this.editor = store.getEditor();
+        } else {
+            this.editor = new CompositeEditor(store.getEditor(), editor);
+        }
 
         MicroKernel kernel = store.getKernel();
         this.branchRevision = kernel.branch(null);
@@ -61,13 +69,13 @@ class KernelNodeStoreBranch implements N
     }
 
     @Override
-    public NodeState getRoot() {
-        return currentRoot;
+    public NodeState getBase() {
+        return base;
     }
 
     @Override
-    public NodeState getBase() {
-        return base;
+    public NodeState getRoot() {
+        return currentRoot;
     }
 
     @Override
@@ -122,14 +130,12 @@ class KernelNodeStoreBranch implements N
 
     @Override
     public KernelNodeState merge() throws CommitFailedException {
-        MicroKernel kernel = store.getKernel();
-        CommitEditor editor = store.getEditor();
-
         NodeState oldRoot = base;
         NodeState toCommit = editor.editCommit(store, oldRoot, currentRoot);
         setRoot(toCommit);
 
         try {
+            MicroKernel kernel = store.getKernel();
             String mergedRevision = kernel.merge(branchRevision, null);
             branchRevision = null;
             currentRoot = null;
@@ -163,5 +169,4 @@ class KernelNodeStoreBranch implements N
         currentRoot = new KernelNodeState(kernel, "/", branchRevision);
         committed = currentRoot;
     }
-
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java?rev=1374309&r1=1374308&r2=1374309&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java
Fri Aug 17 15:10:37 2012
@@ -20,6 +20,8 @@ import java.util.concurrent.atomic.Atomi
 
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.CoreValueFactory;
+import org.apache.jackrabbit.oak.spi.commit.CommitEditor;
+import org.apache.jackrabbit.oak.spi.commit.EmptyEditor;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
@@ -45,7 +47,7 @@ public class MemoryNodeStore implements 
     }
 
     @Override
-    public NodeStoreBranch branch() {
+    public NodeStoreBranch branch(CommitEditor editor) {
         return new MemoryNodeStoreBranch(root.get());
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/PermissionValidatorProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/PermissionValidatorProvider.java?rev=1374309&r1=1374308&r2=1374309&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/PermissionValidatorProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/PermissionValidatorProvider.java
Fri Aug 17 15:10:37 2012
@@ -18,8 +18,9 @@ package org.apache.jackrabbit.oak.securi
 
 import javax.annotation.Nonnull;
 
-import org.apache.jackrabbit.oak.api.ContentSession;
+import org.apache.jackrabbit.oak.api.CoreValueFactory;
 import org.apache.jackrabbit.oak.core.ReadOnlyTree;
+import org.apache.jackrabbit.oak.namepath.NamePathMapper;
 import org.apache.jackrabbit.oak.spi.commit.Validator;
 import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
 import org.apache.jackrabbit.oak.spi.security.authorization.AccessControlContext;
@@ -31,11 +32,11 @@ import org.apache.jackrabbit.oak.util.No
  */
 public class PermissionValidatorProvider implements ValidatorProvider {
 
-    private final ContentSession contentSession;
+    private final CoreValueFactory coreValueFactory;
     private final AccessControlContext accessControlContext;
 
-    public PermissionValidatorProvider(ContentSession contentSession, AccessControlContext
accessControlContext) {
-        this.contentSession = contentSession;
+    public PermissionValidatorProvider(CoreValueFactory coreValueFactory, AccessControlContext
accessControlContext) {
+        this.coreValueFactory = coreValueFactory;
         this.accessControlContext = accessControlContext;
     }
 
@@ -43,8 +44,8 @@ public class PermissionValidatorProvider
     @Nonnull
     @Override
     public Validator getRootValidator(NodeState before, NodeState after) {
-        NodeUtil rootBefore = new NodeUtil(new ReadOnlyTree(before), contentSession);
-        NodeUtil rootAfter = new NodeUtil(new ReadOnlyTree(after), contentSession);
+        NodeUtil rootBefore = new NodeUtil(new ReadOnlyTree(before), coreValueFactory, NamePathMapper.DEFAULT);
+        NodeUtil rootAfter = new NodeUtil(new ReadOnlyTree(after), coreValueFactory, NamePathMapper.DEFAULT);
         return new PermissionValidator(accessControlContext.getPermissions(), rootBefore,
rootAfter);
     }
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStore.java?rev=1374309&r1=1374308&r2=1374309&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStore.java
Fri Aug 17 15:10:37 2012
@@ -16,10 +16,11 @@
  */
 package org.apache.jackrabbit.oak.spi.state;
 
-import org.apache.jackrabbit.oak.api.CoreValueFactory;
-
 import javax.annotation.Nonnull;
 
+import org.apache.jackrabbit.oak.api.CoreValueFactory;
+import org.apache.jackrabbit.oak.spi.commit.CommitEditor;
+
 /**
  * Storage abstraction for trees. At any given point in time the stored
  * tree is rooted at a single immutable node state.
@@ -44,7 +45,7 @@ public interface NodeStore {
      * @return branch
      */
     @Nonnull
-    NodeStoreBranch branch();
+    NodeStoreBranch branch(CommitEditor commitEditor);
 
     /**
      * Returns a builder for constructing a new or modified node state.

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStoreBranch.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStoreBranch.java?rev=1374309&r1=1374308&r2=1374309&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStoreBranch.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStoreBranch.java
Fri Aug 17 15:10:37 2012
@@ -16,27 +16,27 @@
  */
 package org.apache.jackrabbit.oak.spi.state;
 
-import org.apache.jackrabbit.oak.api.CommitFailedException;
-
 import javax.annotation.Nonnull;
 
+import org.apache.jackrabbit.oak.api.CommitFailedException;
+
 public interface NodeStoreBranch {
 
     /**
-     * Returns the latest state of the branch.
+     * Returns the base state of this branch.
      *
-     * @return root node state
+     * @return base node state
      */
     @Nonnull
-    NodeState getRoot();
+    NodeState getBase();
 
     /**
-     * Returns the base state of this branch.
+     * Returns the latest state of the branch.
      *
-     * @return base node state
+     * @return root node state
      */
     @Nonnull
-    NodeState getBase();
+    NodeState getRoot();
 
     /**
      * Updates the state of the content tree.

Added: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/AbstractOakTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/AbstractOakTest.java?rev=1374309&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/AbstractOakTest.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/AbstractOakTest.java
Fri Aug 17 15:10:37 2012
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak;
+
+import javax.jcr.Credentials;
+import javax.jcr.GuestCredentials;
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.SimpleCredentials;
+import javax.security.auth.login.LoginException;
+
+import org.apache.jackrabbit.oak.api.ContentRepository;
+import org.apache.jackrabbit.oak.api.ContentSession;
+import org.apache.jackrabbit.oak.core.ContentRepositoryImpl;
+import org.junit.Before;
+
+/**
+ * AbstractOakTest is the base class for oak test execution.
+ */
+public abstract class AbstractOakTest {
+
+    private ContentRepository contentRepository;
+
+    @Before
+    public void before() throws Exception {
+        contentRepository = createRepository();
+    }
+
+    protected abstract ContentRepository createRepository();
+
+    protected static ContentRepository createEmptyRepository() {
+        return new ContentRepositoryImpl();
+    }
+
+    protected ContentRepository getContentRepository() {
+        return contentRepository;
+    }
+
+    protected ContentSession createAdminSession() throws LoginException, NoSuchWorkspaceException
{
+        return getContentRepository().login(getAdminCredentials(), null);
+    }
+
+    protected ContentSession createGuestSession() throws LoginException, NoSuchWorkspaceException
{
+        return getContentRepository().login(new GuestCredentials(), null);
+    }
+
+    private Credentials getAdminCredentials() {
+        // TODO retrieve from config
+        return new SimpleCredentials("admin", "admin".toCharArray());
+    }
+
+}
\ No newline at end of file

Copied: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/AbstractCoreTest.java
(from r1374165, jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/AbstractOakTest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/AbstractCoreTest.java?p2=jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/AbstractCoreTest.java&p1=jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/AbstractOakTest.java&r1=1374165&r2=1374309&rev=1374309&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/AbstractOakTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/AbstractCoreTest.java
Fri Aug 17 15:10:37 2012
@@ -29,12 +29,12 @@ import org.slf4j.LoggerFactory;
 /**
  * AbstractOakTest...
  */
-public abstract class AbstractOakTest {
+public abstract class AbstractCoreTest {
 
     /**
      * logger instance
      */
-    private static final Logger log = LoggerFactory.getLogger(AbstractOakTest.class);
+    private static final Logger log = LoggerFactory.getLogger(AbstractCoreTest.class);
 
     // TODO: use regular oak-repo setup
     protected KernelNodeStore store;

Propchange: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/AbstractCoreTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/DefaultConflictHandlerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/DefaultConflictHandlerTest.java?rev=1374309&r1=1374308&r2=1374309&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/DefaultConflictHandlerTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/DefaultConflictHandlerTest.java
Fri Aug 17 15:10:37 2012
@@ -31,7 +31,7 @@ import static org.junit.Assert.assertEqu
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 
-public class DefaultConflictHandlerTest extends AbstractOakTest {
+public class DefaultConflictHandlerTest extends AbstractCoreTest {
     private Root ourRoot;
     private Root theirRoot;
     private CoreValue ourValue;

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplTest.java?rev=1374309&r1=1374308&r2=1374309&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplTest.java
Fri Aug 17 15:10:37 2012
@@ -35,7 +35,7 @@ import static org.junit.Assert.assertNot
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
-public class RootImplTest extends AbstractOakTest {
+public class RootImplTest extends AbstractCoreTest {
 
     @Override
     protected NodeState createInitialState(MicroKernel microKernel) {

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/TreeImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/TreeImplTest.java?rev=1374309&r1=1374308&r2=1374309&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/TreeImplTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/TreeImplTest.java
Fri Aug 17 15:10:37 2012
@@ -40,7 +40,7 @@ import static org.junit.Assert.assertTru
 /**
  * TreeImplTest...
  */
-public class TreeImplTest extends AbstractOakTest {
+public class TreeImplTest extends AbstractCoreTest {
 
     @Override
     protected NodeState createInitialState(MicroKernel microKernel) {

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateTest.java?rev=1374309&r1=1374308&r2=1374309&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStateTest.java
Fri Aug 17 15:10:37 2012
@@ -18,23 +18,23 @@
  */
 package org.apache.jackrabbit.oak.kernel;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.oak.api.PropertyState;
-import org.apache.jackrabbit.oak.core.AbstractOakTest;
+import org.apache.jackrabbit.oak.core.AbstractCoreTest;
 import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.junit.Test;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
 import static junit.framework.Assert.assertEquals;
 import static junit.framework.Assert.assertNotNull;
 import static junit.framework.Assert.assertNull;
 
-public class KernelNodeStateTest extends AbstractOakTest {
+public class KernelNodeStateTest extends AbstractCoreTest {
 
     @Override
     protected NodeState createInitialState(MicroKernel microKernel) {

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreTest.java?rev=1374309&r1=1374308&r2=1374309&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreTest.java
Fri Aug 17 15:10:37 2012
@@ -24,6 +24,7 @@ import org.apache.jackrabbit.oak.api.Com
 import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState;
 import org.apache.jackrabbit.oak.spi.commit.CommitEditor;
+import org.apache.jackrabbit.oak.spi.commit.EmptyEditor;
 import org.apache.jackrabbit.oak.spi.commit.Observer;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
@@ -69,7 +70,7 @@ public class KernelNodeStoreTest {
 
     @Test
     public void branch() throws CommitFailedException {
-        NodeStoreBranch branch = store.branch();
+        NodeStoreBranch branch = store.branch(EmptyEditor.INSTANCE);
 
         NodeBuilder rootBuilder = store.getBuilder(branch.getRoot());
         NodeBuilder testBuilder = rootBuilder.getChildBuilder("test");
@@ -137,7 +138,7 @@ public class KernelNodeStoreTest {
 
         NodeState newRoot = rootBuilder.getNodeState();
 
-        NodeStoreBranch branch = store.branch();
+        NodeStoreBranch branch = store.branch(EmptyEditor.INSTANCE);
         branch.setRoot(newRoot);
         branch.merge();
         store.getRoot(); // triggers the observer
@@ -180,7 +181,7 @@ public class KernelNodeStoreTest {
 
         NodeState newRoot = rootBuilder.getNodeState();
 
-        NodeStoreBranch branch = store.branch();
+        NodeStoreBranch branch = store.branch(EmptyEditor.INSTANCE);
         branch.setRoot(newRoot);
         branch.merge();
 

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/LargeKernelNodeStateTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/LargeKernelNodeStateTest.java?rev=1374309&r1=1374308&r2=1374309&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/LargeKernelNodeStateTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/LargeKernelNodeStateTest.java
Fri Aug 17 15:10:37 2012
@@ -19,7 +19,7 @@
 package org.apache.jackrabbit.oak.kernel;
 
 import org.apache.jackrabbit.mk.api.MicroKernel;
-import org.apache.jackrabbit.oak.core.AbstractOakTest;
+import org.apache.jackrabbit.oak.core.AbstractCoreTest;
 import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.junit.Test;
@@ -28,7 +28,7 @@ import static junit.framework.Assert.ass
 import static junit.framework.Assert.assertNotNull;
 import static junit.framework.Assert.assertNull;
 
-public class LargeKernelNodeStateTest extends AbstractOakTest {
+public class LargeKernelNodeStateTest extends AbstractCoreTest {
     private static final int N = KernelNodeState.MAX_CHILD_NODE_NAMES;
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/AbstractLuceneQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/AbstractLuceneQueryTest.java?rev=1374309&r1=1374308&r2=1374309&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/AbstractLuceneQueryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/AbstractLuceneQueryTest.java
Fri Aug 17 15:10:37 2012
@@ -16,23 +16,18 @@
  */
 package org.apache.jackrabbit.oak.plugins.lucene;
 
-import static org.apache.jackrabbit.oak.plugins.lucene.LuceneIndexUtils.DEFAULT_INDEX_HOME;
-import static org.apache.jackrabbit.oak.plugins.lucene.LuceneIndexUtils.DEFAULT_INDEX_NAME;
-import static org.apache.jackrabbit.oak.plugins.lucene.LuceneIndexUtils.createIndexNode;
-
 import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.List;
 
-import javax.jcr.GuestCredentials;
-
 import org.apache.jackrabbit.mk.core.MicroKernelImpl;
+import org.apache.jackrabbit.oak.AbstractOakTest;
 import org.apache.jackrabbit.oak.api.ContentRepository;
 import org.apache.jackrabbit.oak.api.ContentSession;
 import org.apache.jackrabbit.oak.api.CoreValueFactory;
-import org.apache.jackrabbit.oak.api.SessionQueryEngine;
 import org.apache.jackrabbit.oak.api.Result;
 import org.apache.jackrabbit.oak.api.Root;
+import org.apache.jackrabbit.oak.api.SessionQueryEngine;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.core.ContentRepositoryImpl;
 import org.apache.jackrabbit.oak.core.DefaultConflictHandler;
@@ -48,16 +43,19 @@ import org.apache.jackrabbit.oak.spi.com
 import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
 import org.junit.Before;
 
+import static org.apache.jackrabbit.oak.plugins.lucene.LuceneIndexUtils.DEFAULT_INDEX_HOME;
+import static org.apache.jackrabbit.oak.plugins.lucene.LuceneIndexUtils.DEFAULT_INDEX_NAME;
+import static org.apache.jackrabbit.oak.plugins.lucene.LuceneIndexUtils.createIndexNode;
+
 /**
  * base class for lucene search tests
  */
-public abstract class AbstractLuceneQueryTest {
+public abstract class AbstractLuceneQueryTest extends AbstractOakTest {
 
     protected static final String SQL2 = "JCR-SQL2";
 
     private static final String TEST_INDEX_NAME = DEFAULT_INDEX_NAME;
 
-    protected ContentRepository repository;
     protected ContentSession session;
     protected CoreValueFactory vf;
     protected SessionQueryEngine qe;
@@ -65,17 +63,22 @@ public abstract class AbstractLuceneQuer
 
     @Before
     public void before() throws Exception {
-        repository = new ContentRepositoryImpl(new MicroKernelImpl(),
-                new LuceneIndexProvider(DEFAULT_INDEX_HOME),
-                buildDefaultCommitEditor());
-        session = repository.login(new GuestCredentials(), null);
-        cleanupIndexNode();
+        super.before();
 
+        session = createAdminSession();
+        cleanupIndexNode();
         vf = session.getCoreValueFactory();
         qe = session.getQueryEngine();
 
     }
 
+    @Override
+    protected ContentRepository createRepository() {
+        return new ContentRepositoryImpl(new MicroKernelImpl(),
+                new LuceneIndexProvider(DEFAULT_INDEX_HOME),
+                buildDefaultCommitEditor());
+    }
+
     private static CommitEditor buildDefaultCommitEditor() {
         List<CommitEditor> editors = new ArrayList<CommitEditor>();
         editors.add(new DefaultTypeEditor());

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneEditorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneEditorTest.java?rev=1374309&r1=1374308&r2=1374309&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneEditorTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneEditorTest.java
Fri Aug 17 15:10:37 2012
@@ -16,12 +16,6 @@
  */
 package org.apache.jackrabbit.oak.plugins.lucene;
 
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertFalse;
-import static junit.framework.Assert.assertTrue;
-import static org.apache.jackrabbit.oak.plugins.lucene.LuceneIndexUtils.DEFAULT_INDEX_NAME;
-import static org.apache.jackrabbit.oak.plugins.lucene.LuceneIndexUtils.DEFAULT_INDEX_PATH;
-
 import org.apache.jackrabbit.mk.core.MicroKernelImpl;
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.Tree;
@@ -37,6 +31,12 @@ import org.apache.jackrabbit.oak.spi.Fil
 import org.apache.jackrabbit.oak.spi.QueryIndex;
 import org.junit.Test;
 
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertFalse;
+import static junit.framework.Assert.assertTrue;
+import static org.apache.jackrabbit.oak.plugins.lucene.LuceneIndexUtils.DEFAULT_INDEX_NAME;
+import static org.apache.jackrabbit.oak.plugins.lucene.LuceneIndexUtils.DEFAULT_INDEX_PATH;
+
 public class LuceneEditorTest {
 
     @Test

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/name/NamespaceRegistryImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/name/NamespaceRegistryImplTest.java?rev=1374309&r1=1374308&r2=1374309&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/name/NamespaceRegistryImplTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/name/NamespaceRegistryImplTest.java
Fri Aug 17 15:10:37 2012
@@ -16,22 +16,25 @@
 */
 package org.apache.jackrabbit.oak.plugins.name;
 
-import static org.junit.Assert.assertEquals;
-
-import javax.jcr.GuestCredentials;
 import javax.jcr.NamespaceRegistry;
 
+import org.apache.jackrabbit.oak.AbstractOakTest;
 import org.apache.jackrabbit.oak.api.ContentRepository;
 import org.apache.jackrabbit.oak.api.ContentSession;
-import org.apache.jackrabbit.oak.core.ContentRepositoryImpl;
 import org.junit.Test;
 
-public class NamespaceRegistryImplTest {
+import static org.junit.Assert.assertEquals;
+
+public class NamespaceRegistryImplTest extends AbstractOakTest {
+
+    @Override
+    protected ContentRepository createRepository() {
+        return createEmptyRepository();
+    }
 
     @Test
     public void testMappings() throws Exception {
-        ContentRepository repository = new ContentRepositoryImpl();
-        ContentSession session = repository.login(new GuestCredentials(), null);
+        ContentSession session = createAdminSession();
         NamespaceRegistry r = new NamespaceRegistryImpl(session);
 
         assertEquals("", r.getURI(""));
@@ -55,5 +58,4 @@ public class NamespaceRegistryImplTest {
         assertEquals(r.getPrefix("n2"), "p2");
 
     }
-
 }



Mime
View raw message