jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r790118 [1/2] - in /jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test: ./ api/ api/lock/ api/observation/ api/query/ api/query/qom/ api/retention/ api/version/ api/version/simple/
Date Wed, 01 Jul 2009 11:07:14 GMT
Author: mreutegg
Date: Wed Jul  1 11:07:13 2009
New Revision: 790118

URL: http://svn.apache.org/viewvc?rev=790118&view=rev
Log:
JCR-2178: Test must not fail if mixin cannot be added

Modified:
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/AbstractWorkspaceReferenceableTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/AbstractWorkspaceVersionableTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/GetWeakReferencesTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeAddMixinTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeCanAddMixinTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeRemoveMixinTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeSetPrimaryTypeTest.java   (contents, props changed)
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ReferencesTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SerializationTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SessionRemoveItemTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SessionTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyAssumeTypeTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyConstraintViolationExceptionTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueConstraintViolationExceptionTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueReferenceTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueValueFormatExceptionTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueVersionExceptionTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ShareableNodeTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/TreeComparator.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneReferenceableTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneVersionableTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesReferenceableTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesVersionableTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyReferenceableTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceMoveReferenceableTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceMoveTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/AbstractLockTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/DeepLockTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/LockManagerTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/LockTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/SessionScopedLockTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/SetValueLockExceptionTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/AddEventListenerTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/EventJournalTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/GetUserDataTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/LockingTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLJoinTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SaveTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/BindVariableValueTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/ChildNodeJoinConditionTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/DescendantNodeJoinConditionTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/EquiJoinConditionTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/LengthTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/NodeLocalNameTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/NodeNameTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/SameNodeJoinConditionTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/retention/HoldTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/retention/RetentionPolicyTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/AbstractVersionTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/FrozenNodeTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/GetReferencesNodeTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/MergeNodeTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/RestoreTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/AbstractVersionTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/FrozenNodeTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/RestoreTest.java

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java Wed Jul  1 11:07:13 2009
@@ -736,7 +736,28 @@
             throw new NotExecutableException("Repository does not support node type " + nodetype);
         }
     }
-    
+
+    /**
+     * Ensures that the given <code>node</code> is of the given mixin type.
+     *
+     * @param node  a node.
+     * @param mixin the name of a mixin type.
+     * @throws NotExecutableException if the node is not of type mixin and the
+     *                                mixin cannot be added.
+     * @throws RepositoryException    if an error occurs.
+     */
+    protected void ensureMixinType(Node node, String mixin)
+            throws NotExecutableException, RepositoryException {
+        if (!node.isNodeType(mixin)) {
+            if (node.canAddMixin(mixin)) {
+                node.addMixin(mixin);
+            } else {
+                throw new NotExecutableException(node.getPath() +
+                        " does not support adding " + mixin);
+            }
+        }
+    }
+
     /**
      * Checks whether the node already has the specified mixin node type
      */

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/AbstractWorkspaceReferenceableTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/AbstractWorkspaceReferenceableTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/AbstractWorkspaceReferenceableTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/AbstractWorkspaceReferenceableTest.java Wed Jul  1 11:07:13 2009
@@ -53,11 +53,10 @@
      * @param node
      * @return referenceable node.
      */
-    protected Node addMixinReferenceableToNode(Node node) throws RepositoryException {
-        if (!node.isNodeType(mixReferenceable)) {
-            node.addMixin(mixReferenceable);
-            node.save();
-        }
+    protected Node addMixinReferenceableToNode(Node node) throws RepositoryException,
+            NotExecutableException {
+        ensureMixinType(node, mixReferenceable);
+        node.save();
         return node;
     }
 }
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/AbstractWorkspaceVersionableTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/AbstractWorkspaceVersionableTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/AbstractWorkspaceVersionableTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/AbstractWorkspaceVersionableTest.java Wed Jul  1 11:07:13 2009
@@ -52,11 +52,9 @@
     /**
      * add the mix:versionable mixin type to a node.
      */
-    protected Node addMixinVersionableToNode(Node parent, Node node) throws RepositoryException {
-        NodeType nodetype = node.getPrimaryNodeType();
-        if (!nodetype.isNodeType(mixVersionable)) {
-            node.addMixin(mixVersionable);
-        }
+    protected Node addMixinVersionableToNode(Node parent, Node node) throws RepositoryException,
+            NotExecutableException {
+        ensureMixinType(node, mixVersionable);
         parent.save();
 
         return node;

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/GetWeakReferencesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/GetWeakReferencesTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/GetWeakReferencesTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/GetWeakReferencesTest.java Wed Jul  1 11:07:13 2009
@@ -38,12 +38,7 @@
     protected void setUp() throws Exception {
         super.setUp();
         target = testRootNode.addNode(nodeName1, testNodeType);
-        if (!target.isNodeType(mixReferenceable)) {
-            if (!target.canAddMixin(mixReferenceable)) {
-                throw new NotExecutableException("cannot add mix:referenceable to node");
-            }
-            target.addMixin(mixReferenceable);
-        }
+        ensureMixinType(target, mixReferenceable);
         referring = testRootNode.addNode(nodeName2, testNodeType);
         superuser.save();
     }

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeAddMixinTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeAddMixinTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeAddMixinTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeAddMixinTest.java Wed Jul  1 11:07:13 2009
@@ -179,14 +179,7 @@
         // create a node that is lockable
         Node node = testRootNode.addNode(nodeName1, testNodeType);
         // or try to make it lockable if it is not
-        if (!node.isNodeType(mixLockable)) {
-            if (node.canAddMixin(mixLockable)) {
-                node.addMixin(mixLockable);
-            } else {
-                throw new NotExecutableException("Node " + nodeName1 + " is not lockable and does not " +
-                        "allow to add mix:lockable");
-            }
-        }
+        ensureMixinType(node, mixLockable);
         testRootNode.save();
 
         String mixinName = NodeMixinUtil.getAddableMixinName(session, node);
@@ -241,14 +234,7 @@
         // create a node that is versionable
         Node node = testRootNode.addNode(nodeName1, testNodeType);
         // or try to make it versionable if it is not
-        if (!node.isNodeType(mixVersionable)) {
-            if (node.canAddMixin(mixVersionable)) {
-                node.addMixin(mixVersionable);
-            } else {
-                throw new NotExecutableException("Node " + nodeName1 + " is not versionable and does not " +
-                        "allow to add mix:versionable");
-            }
-        }
+        ensureMixinType(node, mixVersionable);
         testRootNode.save();
 
         String mixinName = NodeMixinUtil.getAddableMixinName(session, node);
@@ -279,9 +265,7 @@
 
         // get session an create default node
         Node node = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(node, mixReferenceable)) {
-            node.addMixin(mixReferenceable);
-        }
+        ensureMixinType(node, mixReferenceable);
         // implementation specific: mixin may take effect only upon save
         testRootNode.save();
 

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeCanAddMixinTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeCanAddMixinTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeCanAddMixinTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeCanAddMixinTest.java Wed Jul  1 11:07:13 2009
@@ -54,14 +54,7 @@
         // create a node that is lockable
         Node node = testRootNode.addNode(nodeName1, testNodeType);
         // or try to make it lockable if it is not
-        if (!node.isNodeType(mixLockable)) {
-            if (node.canAddMixin(mixLockable)) {
-                node.addMixin(mixLockable);
-            } else {
-                throw new NotExecutableException("Node " + nodeName1 + " is not lockable and does not " +
-                        "allow to add mix:lockable");
-            }
-        }
+        ensureMixinType(node, mixLockable);
         testRootNode.save();
 
         String mixinName = NodeMixinUtil.getAddableMixinName(session, node);
@@ -105,14 +98,7 @@
         // create a node that is versionable
         Node node = testRootNode.addNode(nodeName1, testNodeType);
         // or try to make it versionable if it is not
-        if (!node.isNodeType(mixVersionable)) {
-            if (node.canAddMixin(mixVersionable)) {
-                node.addMixin(mixVersionable);
-            } else {
-                throw new NotExecutableException("Node " + nodeName1 + " is not versionable and does not " +
-                        "allow to add mix:versionable");
-            }
-        }
+        ensureMixinType(node, mixVersionable);
         testRootNode.save();
 
         String mixinName = NodeMixinUtil.getAddableMixinName(session, node);

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeRemoveMixinTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeRemoveMixinTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeRemoveMixinTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeRemoveMixinTest.java Wed Jul  1 11:07:13 2009
@@ -149,14 +149,7 @@
         // create a node that is lockable
         Node node = testRootNode.addNode(nodeName1, testNodeType);
         // or try to make it lockable if it is not
-        if (!node.isNodeType(mixLockable)) {
-            if (node.canAddMixin(mixLockable)) {
-                node.addMixin(mixLockable);
-            } else {
-                throw new NotExecutableException("Node " + nodeName1 + " is not lockable and does not " +
-                        "allow to add mix:lockable");
-            }
-        }
+        ensureMixinType(node, mixLockable);
         testRootNode.save();
 
         String mixinName = NodeMixinUtil.getAddableMixinName(session, node);
@@ -214,14 +207,7 @@
         // create a node that is versionable
         Node node = testRootNode.addNode(nodeName1, testNodeType);
         // or try to make it versionable if it is not
-        if (!node.isNodeType(mixVersionable)) {
-            if (node.canAddMixin(mixVersionable)) {
-                node.addMixin(mixVersionable);
-            } else {
-                throw new NotExecutableException("Node " + nodeName1 + " is not versionable and does not " +
-                        "allow to add mix:versionable");
-            }
-        }
+        ensureMixinType(node, mixVersionable);
         testRootNode.save();
 
         String mixinName = NodeMixinUtil.getAddableMixinName(session, node);

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeSetPrimaryTypeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeSetPrimaryTypeTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeSetPrimaryTypeTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeSetPrimaryTypeTest.java Wed Jul  1 11:07:13 2009
@@ -211,13 +211,7 @@
         // create a node that is lockable
         Node node = testRootNode.addNode(nodeName1, testNodeType);
         // or try to make it lockable if it is not
-        if (!node.isNodeType(mixLockable)) {
-            if (node.canAddMixin(mixLockable)) {
-                node.addMixin(mixLockable);
-            } else {
-                throw new NotExecutableException("Node " + nodeName1 + " is not lockable and does not allow to add mix:lockable");
-            }
-        }
+        ensureMixinType(node, mixLockable);
         testRootNode.save();
 
         String primaryTypeName = getPrimaryTypeName(session, node);
@@ -266,14 +260,7 @@
         // create a node that is versionable
         Node node = testRootNode.addNode(nodeName1, testNodeType);
         // or try to make it versionable if it is not
-        if (!node.isNodeType(mixVersionable)) {
-            if (node.canAddMixin(mixVersionable)) {
-                node.addMixin(mixVersionable);
-            } else {
-                throw new NotExecutableException("Node " + nodeName1 + " is not versionable and does not " +
-                        "allow to add mix:versionable");
-            }
-        }
+        ensureMixinType(node, mixVersionable);
         superuser.save();
 
         String primaryTypeName = getPrimaryTypeName(session, node);

Propchange: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeSetPrimaryTypeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeTest.java Wed Jul  1 11:07:13 2009
@@ -657,14 +657,7 @@
         // create a node that is lockable
         Node node = testRootNode.addNode(nodeName1, testNodeType);
         // or try to make it lockable if it is not
-        if (!node.isNodeType(mixLockable)) {
-            if (node.canAddMixin(mixLockable)) {
-                node.addMixin(mixLockable);
-            } else {
-                throw new NotExecutableException("Node " + nodeName1 + " is not lockable and does not " +
-                        "allow to add mix:lockable");
-            }
-        }
+        ensureMixinType(node, mixLockable);
         testRootNode.save();
 
         // remove first slash of path to get rel path to root
@@ -705,14 +698,7 @@
         // create a node that is lockable
         Node node = testRootNode.addNode(nodeName1, testNodeType);
         // or try to make it lockable if it is not
-        if (!node.isNodeType(mixLockable)) {
-            if (node.canAddMixin(mixLockable)) {
-                node.addMixin(mixLockable);
-            } else {
-                throw new NotExecutableException("Node " + nodeName1 + " is not lockable and does not " +
-                        "allow to add mix:lockable");
-            }
-        }
+        ensureMixinType(node, mixLockable);
         // create a child node
         Node subNode = node.addNode(nodeName2, testNodeType);
         testRootNode.save();

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ReferencesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ReferencesTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ReferencesTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ReferencesTest.java Wed Jul  1 11:07:13 2009
@@ -40,9 +40,7 @@
      */
     public void testReferences() throws RepositoryException, NotExecutableException {
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1, mixReferenceable)) {
-            n1.addMixin(mixReferenceable);
-        }
+        ensureMixinType(n1, mixReferenceable);
 
         // with some impls. the mixin type has only affect upon save
         testRootNode.save();
@@ -117,9 +115,7 @@
      */
     public void testReferenceTarget() throws RepositoryException, NotExecutableException {
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1, mixReferenceable)) {
-            n1.addMixin(mixReferenceable);
-        }
+        ensureMixinType(n1, mixReferenceable);
 
         // with some impls. the mixin type has only affect upon save
         testRootNode.save();
@@ -146,13 +142,9 @@
      */
     public void testAlterReference() throws RepositoryException, NotExecutableException {
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1, mixReferenceable)) {
-            n1.addMixin(mixReferenceable);
-        }
+        ensureMixinType(n1, mixReferenceable);
         Node n2 = testRootNode.addNode(nodeName2, testNodeType);
-        if (needsMixin(n2, mixReferenceable)) {
-            n2.addMixin(mixReferenceable);
-        }
+        ensureMixinType(n2, mixReferenceable);
 
         // with some impls. the mixin type has only affect upon save
         testRootNode.save();

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SerializationTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SerializationTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SerializationTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SerializationTest.java Wed Jul  1 11:07:13 2009
@@ -123,13 +123,7 @@
      */
     protected Node initVersioningException(boolean returnParent) throws RepositoryException, NotExecutableException, IOException {
         Node vNode = testRootNode.addNode(nodeName1, testNodeType);
-        if (!vNode.isNodeType(mixVersionable)) {
-            if (vNode.canAddMixin(mixVersionable)) {
-                vNode.addMixin(mixVersionable);
-            } else {
-                throw new NotExecutableException("NodeType: " + testNodeType + " is not versionable");
-            }
-        }
+        ensureMixinType(vNode, mixVersionable);
         Node vChild = vNode.addNode(nodeName2, testNodeType);
         session.save();
         vNode.checkin();
@@ -215,7 +209,7 @@
         if (isSupported(Repository.OPTION_LOCKING_SUPPORTED)) {
             //A LockException is thrown if a lock prevents the addition of the subtree.
             Node lNode = testRootNode.addNode(nodeName1);
-            lNode.addMixin(mixLockable);
+            ensureMixinType(lNode, mixLockable);
             testRootNode.save();
             Lock lock = lNode.lock(true, true);
             session.removeLockToken(lock.getLockToken());   //remove the token, so the lock is for me, too

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SessionRemoveItemTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SessionRemoveItemTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SessionRemoveItemTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SessionRemoveItemTest.java Wed Jul  1 11:07:13 2009
@@ -91,14 +91,8 @@
     }
 
     public void testRemoveLockedNode() throws RepositoryException, NotExecutableException {
-        if (!removeNode.isNodeType(mixLockable)) {
-            if (removeNode.canAddMixin(mixLockable)) {
-                removeNode.addMixin(mixLockable);
-                removeNode.save();
-            } else {
-                throw new NotExecutableException("Cannot make test node lockable.");
-            }
-        }
+        ensureMixinType(removeNode, mixLockable);
+        removeNode.save();
 
         // make sure the test node is locked.
         removeNode.lock(true, true);
@@ -123,14 +117,8 @@
         Property childP = removeNode.setProperty(propertyName2, v);
         removeNode.save();
 
-        if (!removeNode.isNodeType(mixLockable)) {
-            if (removeNode.canAddMixin(mixLockable)) {
-                removeNode.addMixin(mixLockable);
-                removeNode.save();
-            } else {
-                throw new NotExecutableException("Cannot make test node lockable.");
-            }
-        }
+        ensureMixinType(removeNode, mixLockable);
+        removeNode.save();
 
         // make sure the test node is locked.
         removeNode.lock(true, true);
@@ -167,14 +155,8 @@
         Property childP = removeNode.setProperty(propertyName2, v);
         removeNode.save();
 
-        if (!removeNode.isNodeType(mixVersionable)) {
-            if (removeNode.canAddMixin(mixVersionable)) {
-                removeNode.addMixin(mixVersionable);
-                removeNode.save();
-            } else {
-                throw new NotExecutableException("Cannot make test node versionable.");
-            }
-        }
+        ensureMixinType(removeNode, mixVersionable);
+        removeNode.save();
 
         removeNode.checkin();
         try {

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SessionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SessionTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SessionTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SessionTest.java Wed Jul  1 11:07:13 2009
@@ -259,14 +259,7 @@
         // create a node that is lockable
         Node lockableNode = testRootNode.addNode(nodeName1, testNodeType);
         // or try to make it lockable if it is not
-        if (!lockableNode.isNodeType(mixLockable)) {
-            if (lockableNode.canAddMixin(mixLockable)) {
-                lockableNode.addMixin(mixLockable);
-            } else {
-                throw new NotExecutableException("Node " + nodeName1 + " is not lockable and does not " +
-                        "allow to add mix:lockable");
-            }
-        }
+        ensureMixinType(lockableNode, mixLockable);
 
         // add a sub node (the one that is tried to move later on)
         Node srcNode = lockableNode.addNode(nodeName1, testNodeType);

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyAssumeTypeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyAssumeTypeTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyAssumeTypeTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyAssumeTypeTest.java Wed Jul  1 11:07:13 2009
@@ -374,7 +374,8 @@
         setUpNodeWithUndefinedProperty(false);
 
         Node referenceableNode = testRootNode.addNode(nodeName2);
-        referenceableNode.addMixin(mixReferenceable);
+        ensureMixinType(referenceableNode, mixReferenceable);
+
         // some implementations may require a save after addMixin()
         testRootNode.save();
 

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyConstraintViolationExceptionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyConstraintViolationExceptionTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyConstraintViolationExceptionTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyConstraintViolationExceptionTest.java Wed Jul  1 11:07:13 2009
@@ -397,7 +397,7 @@
 
             // create a referenceable node not satisfying the constraint
             nodeNotSatisfied = testRootNode.addNode(nodeName4, nodeTypeNotSatisfied);
-            nodeNotSatisfied.addMixin(mixReferenceable);
+            ensureMixinType(nodeNotSatisfied, mixReferenceable);
 
             testRootNode.save();
         } catch (ConstraintViolationException e) {

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueConstraintViolationExceptionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueConstraintViolationExceptionTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueConstraintViolationExceptionTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueConstraintViolationExceptionTest.java Wed Jul  1 11:07:13 2009
@@ -442,11 +442,11 @@
 
             // create a referenceable node satisfying the constraint
             nodeSatisfied = testRootNode.addNode(nodeName3, nodeTypeSatisfied);
-            nodeSatisfied.addMixin(mixReferenceable);
+            ensureMixinType(nodeSatisfied, mixReferenceable);
 
             // create a referenceable node not satisfying the constraint
             nodeNotSatisfied = testRootNode.addNode(nodeName4, nodeTypeNotSatisfied);
-            nodeNotSatisfied.addMixin(mixReferenceable);
+            ensureMixinType(nodeNotSatisfied, mixReferenceable);
 
             // some implementations may require a save after addMixin()
             testRootNode.save();
@@ -814,11 +814,11 @@
 
             // create a referenceable node satisfying the constraint
             nodeSatisfied = testRootNode.addNode(nodeName3, nodeTypeSatisfied);
-            nodeSatisfied.addMixin(mixReferenceable);
+            ensureMixinType(nodeSatisfied, mixReferenceable);
 
             // create a referenceable node not satisfying the constraint
             nodeNotSatisfied = testRootNode.addNode(nodeName4, nodeTypeNotSatisfied);
-            nodeNotSatisfied.addMixin(mixReferenceable);
+            ensureMixinType(nodeNotSatisfied, mixReferenceable);
 
             // some implementations may require a save after addMixin()
             testRootNode.save();

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueReferenceTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueReferenceTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueReferenceTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueReferenceTest.java Wed Jul  1 11:07:13 2009
@@ -152,15 +152,7 @@
      *                                referenceable nodes.
      */
     private void ensureReferenceable(Node n) throws RepositoryException, NotExecutableException {
-        if (n.isNodeType(mixReferenceable)) {
-            return;
-        }
-        if (n.canAddMixin(mixReferenceable)) {
-            n.addMixin(mixReferenceable);
-            // some implementations may require a save after addMixin()
-            n.getSession().save();
-        } else {
-            throw new NotExecutableException("Node is not referenceable: " + n.getPath());
-        }
+        ensureMixinType(n, mixReferenceable);
+        n.getSession().save();
     }
 }

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueValueFormatExceptionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueValueFormatExceptionTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueValueFormatExceptionTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueValueFormatExceptionTest.java Wed Jul  1 11:07:13 2009
@@ -213,7 +213,7 @@
         try {
             Node referenceableNode = testRootNode.addNode(nodeName3, testNodeType);
             if (needsMixin(referenceableNode, mixReferenceable)) {
-                referenceableNode.addMixin(mixReferenceable);
+                ensureMixinType(referenceableNode, mixReferenceable);
             }
 
             // some implementations may require a save after addMixin()

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueVersionExceptionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueVersionExceptionTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueVersionExceptionTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetValueVersionExceptionTest.java Wed Jul  1 11:07:13 2009
@@ -70,13 +70,7 @@
         // create a node that is versionable
         node = testRootNode.addNode(nodeName1, testNodeType);
         // or try to make it versionable if it is not
-        if (!node.isNodeType(mixVersionable)) {
-            if (node.canAddMixin(mixVersionable)) {
-                node.addMixin(mixVersionable);
-            } else {
-                throw new NotExecutableException("Failed to set up required test items");
-            }
-        }
+        ensureMixinType(node, mixVersionable);
 
         property = node.setProperty(propertyName1, value);
         multiProperty = node.setProperty(propertyName2, values);
@@ -280,13 +274,7 @@
             : testRootNode.addNode(nodeName3, nodeType3);
 
         // try to make it referenceable if it is not
-        if (!referenceableNode.isNodeType(mixReferenceable)) {
-            if (referenceableNode.canAddMixin(mixReferenceable)) {
-              referenceableNode.addMixin(mixReferenceable);
-            } else {
-                throw new NotExecutableException("Failed to set up required test items.");
-            }
-        }
+        ensureMixinType(referenceableNode, mixReferenceable);
 
         // implementation specific if mixin takes effect immediately or upon save
         testRootNode.save();
@@ -297,13 +285,7 @@
         Node node = testRootNode.addNode(nodeName4, nodeType);
 
         // try to make it versionable if it is not
-        if (!node.isNodeType(mixVersionable)) {
-            if (node.canAddMixin(mixVersionable)) {
-                node.addMixin(mixVersionable);
-            } else {
-                throw new NotExecutableException("Failed to set up required test items.");
-            }
-        }
+        ensureMixinType(node, mixVersionable);
 
         // fail early when reference properties are not suppoerted
         ensureCanSetProperty(node, refPropName, node.getSession().getValueFactory().createValue(referenceableNode));

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ShareableNodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ShareableNodeTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ShareableNodeTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ShareableNodeTest.java Wed Jul  1 11:07:13 2009
@@ -43,11 +43,14 @@
  * Tests features available with shareable nodes.
  */
 public class ShareableNodeTest extends AbstractJCRTest {
-    
+
+    private String mixShareable;
+
     protected void setUp() throws Exception {
         super.setUp();
         checkSupportedOption(Repository.OPTION_SHAREABLE_NODES_SUPPORTED);
-        ensureKnowsNodeType(superuser, "mix:shareable");
+        ensureKnowsNodeType(superuser, mixShareable);
+        mixShareable = superuser.getNamespacePrefix(NS_MIX_URI) + ":shareable";
     }
 
     protected void tearDown() throws Exception {
@@ -70,7 +73,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -100,7 +103,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -130,7 +133,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -160,7 +163,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -189,7 +192,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -220,7 +223,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -250,7 +253,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -272,7 +275,7 @@
         Node b = a.addNode("b");
         testRootNode.save();
 
-        b.addMixin("mix:shareable");
+        ensureMixinType(b, mixShareable);
         b.save();
     }
 
@@ -287,7 +290,7 @@
         testRootNode.save();
 
         // make b1 shareable
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -296,7 +299,7 @@
                 a2.getPath() + "/b2", false);
 
         // make a2 versionable
-        a2.addMixin("mix:versionable");
+        ensureMixinType(a2, mixVersionable);
         a2.save();
 
         // check in version and check out again
@@ -331,7 +334,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -365,7 +368,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -395,7 +398,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -427,7 +430,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -457,7 +460,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -493,7 +496,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -532,7 +535,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         Workspace workspace = b1.getSession().getWorkspace();
@@ -558,7 +561,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -594,7 +597,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -638,7 +641,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -692,7 +695,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -749,7 +752,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -806,7 +809,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -864,7 +867,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -913,14 +916,14 @@
     public void testLock() throws Exception {
         // setup parent nodes and first child
         Node a1 = testRootNode.addNode("a1");
-        a1.addMixin("mix:lockable");
+        ensureMixinType(a1, mixLockable);
         Node a2 = testRootNode.addNode("a2");
         Node b1 = a1.addNode("b1");
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
-        b1.addMixin("mix:lockable");
+        ensureMixinType(b1, mixShareable);
+        ensureMixinType(b1, mixLockable);
         b1.save();
 
         // add child c
@@ -968,7 +971,7 @@
         testRootNode.save();
 
         // make b1 shareable
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -981,7 +984,7 @@
         b1.save();
 
         // make a2 versionable
-        a2.addMixin("mix:versionable");
+        ensureMixinType(a2, mixVersionable);
         a2.save();
 
         // check in version and check out again
@@ -1031,7 +1034,7 @@
         }
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone (2nd attempt, with mix:shareable)
@@ -1051,7 +1054,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -1080,12 +1083,12 @@
         testRootNode.save();
 
         // add mixin
-        b.addMixin("mix:shareable");
+        ensureMixinType(b, mixShareable);
         b.save();
 
         try {
             // remove mixin
-            b.removeMixin("mix:shareable");
+            b.removeMixin(mixShareable);
             b.save();
             fail("Removing mix:shareable should fail.");
         } catch (UnsupportedRepositoryOperationException e) {
@@ -1105,7 +1108,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -1115,7 +1118,7 @@
 
         // add new referenceable child
         Node c = b1.addNode("c");
-        c.addMixin(mixReferenceable);
+        ensureMixinType(c, mixReferenceable);
         b1.save();
 
         String sql = "SELECT * FROM nt:unstructured WHERE jcr:uuid = '"+c.getUUID()+"'";
@@ -1144,7 +1147,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         Workspace workspace = b1.getSession().getWorkspace();
@@ -1170,7 +1173,7 @@
         testRootNode.save();
 
         // add mixin
-        b.addMixin("mix:shareable");
+        ensureMixinType(b, mixShareable);
         b.save();
 
         // move
@@ -1197,7 +1200,7 @@
         testRootNode.save();
 
         // add mixin
-        b.addMixin("mix:shareable");
+        ensureMixinType(b, mixShareable);
         b.save();
 
         // move
@@ -1227,7 +1230,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -1262,7 +1265,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -1300,7 +1303,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -1334,7 +1337,7 @@
         testRootNode.save();
 
         // add mixin
-        b1.addMixin("mix:shareable");
+        ensureMixinType(b1, mixShareable);
         b1.save();
 
         // clone
@@ -1377,7 +1380,7 @@
         testRootNode.save();
 
         // add mixin
-        b.addMixin("mix:shareable");
+        ensureMixinType(b, mixShareable);
         b.save();
 
         Workspace workspace = b.getSession().getWorkspace();
@@ -1402,7 +1405,7 @@
        Node a1 = testRootNode.addNode("a1");
        Node a2 = a1.addNode("a2");
        Node b1 = a1.addNode("b1");
-       b1.addMixin("mix:shareable");
+       ensureMixinType(b1, mixShareable);
        testRootNode.save();
 
        //now we have a shareable node N with path a1/b1

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/TreeComparator.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/TreeComparator.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/TreeComparator.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/TreeComparator.java Wed Jul  1 11:07:13 2009
@@ -240,11 +240,9 @@
             pt.setProperty(sc.pathTestProperty, superuser.getValueFactory().createValue("paths/dont/have/to/point/anywhere", PropertyType.PATH));
             // Reference: Note that I only check if the node exists. We do not specify what happens with
             // the UUID during serialization.
-            if (!referenceable.isNodeType(mixReferenceable)) {
-                referenceable.addMixin(mixReferenceable);
-                // some implementations may require a save after addMixin()
-                session.save();
-            }
+            ensureMixinType(referenceable, mixReferenceable);
+            // some implementations may require a save after addMixin()
+            session.save();
 
             pt.setProperty(sc.referenceTestProperty, referenceable);
 

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneReferenceableTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneReferenceableTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneReferenceableTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneReferenceableTest.java Wed Jul  1 11:07:13 2009
@@ -20,6 +20,8 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.ItemExistsException;
 
+import org.apache.jackrabbit.test.NotExecutableException;
+
 /**
  * <code>WorkspaceCloneReferenceableTest</code> contains tests for cloning
  * referenceable nodes between workspaces.
@@ -36,7 +38,8 @@
      * that the new node in the destination workspcace has the same UUID as the
      * node in the source workspace.
      */
-    public void testCloneNodesReferenceableNodesOriginalUUID() throws RepositoryException {
+    public void testCloneNodesReferenceableNodesOriginalUUID() throws RepositoryException,
+            NotExecutableException {
         // add mixin referenceable to node1
         addMixinReferenceableToNode(node1);
 
@@ -60,7 +63,8 @@
      * will reflect the clones state in srcWorkspace, in other words the
      * existing node will be moved and changed.
      */
-    public void testCloneNodesRemoveExistingTrue() throws RepositoryException {
+    public void testCloneNodesRemoveExistingTrue() throws RepositoryException,
+            NotExecutableException {
         // add mixin referenceable to node1
         addMixinReferenceableToNode(node1);
 
@@ -83,7 +87,8 @@
      * If removeExisting is false then a UUID collision causes this method to
      * throw a ItemExistsException and no changes are made.
      */
-    public void testCloneNodesRemoveExistingFalse() throws RepositoryException {
+    public void testCloneNodesRemoveExistingFalse() throws RepositoryException,
+            NotExecutableException {
         // add mixin referenceable to node1
         addMixinReferenceableToNode(node1);
 
@@ -102,7 +107,8 @@
     /**
      * The clone method clones both referenceable and nonreferenceable nodes.
      */
-    public void testCloneNodesReferenceableAndNonreferenceable() throws RepositoryException {
+    public void testCloneNodesReferenceableAndNonreferenceable() throws RepositoryException,
+            NotExecutableException {
         // clone referenceable node
 
         // add mixin referenceable to node1

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneTest.java Wed Jul  1 11:07:13 2009
@@ -25,6 +25,8 @@
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.lock.LockException;
 
+import org.apache.jackrabbit.test.NotExecutableException;
+
 /**
  * <code>WorkspaceCloneTest</code> contains tests for cloning nodes between
  * workspace.
@@ -53,12 +55,13 @@
      * If successful, the changes are persisted immediately, there is no need to
      * call save.
      */
-    public void testCloneNodesTwice() throws RepositoryException {
+    public void testCloneNodesTwice() throws RepositoryException,
+            NotExecutableException {
         // clone referenceable node below non-referenceable node
         String dstAbsPath = node2W2.getPath() + "/" + node1.getName();
 
         Node folder = node1.addNode(nodeName3);
-        folder.addMixin(mixReferenceable);
+        ensureMixinType(folder, mixReferenceable);
         node1.save();
         workspaceW2.clone(workspace.getName(), node1.getPath(), dstAbsPath, true);
         workspaceW2.clone(workspace.getName(), node1.getPath(), dstAbsPath, true);
@@ -169,7 +172,8 @@
     /**
      * A LockException is thrown if a lock prevents the copy.
      */
-    public void testCloneNodesLocked() throws RepositoryException {
+    public void testCloneNodesLocked()
+            throws RepositoryException, NotExecutableException {
         // we assume repository supports locking
         String dstAbsPath = node2W2.getPath() + "/" + node1.getName();
 
@@ -177,10 +181,8 @@
         Node lockTarget = (Node) rwSessionW2.getItem(node2W2.getPath());
 
         // add mixin "lockable" to be able to lock the node
-        if (!lockTarget.getPrimaryNodeType().isNodeType(mixLockable)) {
-            lockTarget.addMixin(mixLockable);
-            lockTarget.getParent().save();
-        }
+        ensureMixinType(lockTarget, mixLockable);
+        lockTarget.getParent().save();
 
         // lock dst parent node using other session
         lockTarget.lock(true, true);

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneVersionableTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneVersionableTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneVersionableTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCloneVersionableTest.java Wed Jul  1 11:07:13 2009
@@ -19,6 +19,8 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.version.VersionException;
 
+import org.apache.jackrabbit.test.NotExecutableException;
+
 
 /**
  * <code>WorkspaceCloneVersionableTest</code> contains tests for cloning
@@ -36,7 +38,8 @@
      * versionable and checked-in, or is non-versionable but its nearest
      * versionable ancestor is checked-in.
      */
-    public void testCloneNodesVersionableAndCheckedIn() throws RepositoryException {
+    public void testCloneNodesVersionableAndCheckedIn() throws RepositoryException,
+            NotExecutableException {
         // prepare the test data
         // create a non-versionable node below a versionable node
         // required for having a nearest versionable ancestor to a nonversionable sub node

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesReferenceableTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesReferenceableTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesReferenceableTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesReferenceableTest.java Wed Jul  1 11:07:13 2009
@@ -19,6 +19,8 @@
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 
+import org.apache.jackrabbit.test.NotExecutableException;
+
 /**
  * <code>WorkspaceCopyBetweenWorkspacesReferenceableTest</code> contains tests
  * for copying referenceable nodes between workspace.
@@ -34,7 +36,8 @@
      * Copies of referenceable nodes (nodes with UUIDs) are automatically given
      * new UUIDs.
      */
-    public void testCopyNodesReferenceableNodesNewUUID() throws RepositoryException {
+    public void testCopyNodesReferenceableNodesNewUUID() throws RepositoryException,
+            NotExecutableException {
         // add mixin referenceable to node1
         addMixinReferenceableToNode(node1);
 

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesTest.java Wed Jul  1 11:07:13 2009
@@ -165,10 +165,8 @@
         Node lockTarget = (Node) rwSessionW2.getItem(node2W2.getPath());
 
         // add mixin "lockable" to be able to lock the node
-        if (!lockTarget.getPrimaryNodeType().isNodeType(mixLockable)) {
-            lockTarget.addMixin(mixLockable);
-            lockTarget.getParent().save();
-        }
+        ensureMixinType(lockTarget, mixLockable);
+        lockTarget.getParent().save();
 
         // lock dst parent node using other session
         lockTarget.lock(true, true);

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesVersionableTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesVersionableTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesVersionableTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesVersionableTest.java Wed Jul  1 11:07:13 2009
@@ -19,6 +19,8 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.version.VersionException;
 
+import org.apache.jackrabbit.test.NotExecutableException;
+
 /**
  * <code>WorkspaceCopyBetweenWorkspacesVersionableTest</code> contains tests for
  * copying versionable nodes between workspace.
@@ -35,7 +37,8 @@
      * versionable and checked-in, or is non-versionable but its nearest
      * versionable ancestor is checked-in.
      */
-    public void testCopyNodesVersionableAndCheckedIn() throws RepositoryException {
+    public void testCopyNodesVersionableAndCheckedIn() throws RepositoryException,
+            NotExecutableException {
         // prepare the test data
         // create a non-versionable node below a versionable node
         // required for having a nearest versionable ancestor to a nonversionable sub node

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyReferenceableTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyReferenceableTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyReferenceableTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyReferenceableTest.java Wed Jul  1 11:07:13 2009
@@ -44,7 +44,8 @@
      * Copies of referenceable nodes (nodes with UUIDs) are automatically given
      * new UUIDs.
      */
-    public void testCopyNodesNewUUID() throws RepositoryException {
+    public void testCopyNodesNewUUID() throws RepositoryException,
+            NotExecutableException {
         // add mixin referenceable to node1
         addMixinReferenceableToNode(node1);
 

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceCopyTest.java Wed Jul  1 11:07:13 2009
@@ -24,6 +24,8 @@
 import javax.jcr.lock.LockException;
 import javax.jcr.nodetype.ConstraintViolationException;
 
+import org.apache.jackrabbit.test.NotExecutableException;
+
 /**
  * <code>WorkspaceCopyTest</code> contains tests for copying nodes in one
  * workspace.
@@ -136,7 +138,8 @@
     /**
      * A LockException is thrown if a lock prevents the copy.
      */
-    public void testCopyNodesLocked() throws RepositoryException {
+    public void testCopyNodesLocked() throws RepositoryException,
+            NotExecutableException {
         // we assume repository supports locking
         String dstAbsPath = node2.getPath() + "/" + node1.getName();
 
@@ -148,10 +151,8 @@
             Node lockTarget = (Node) otherSession.getItem(node2.getPath());
 
             // add mixin "lockable" to be able to lock the node
-            if (!lockTarget.getPrimaryNodeType().isNodeType(mixLockable)) {
-                lockTarget.addMixin(mixLockable);
-                lockTarget.getParent().save();
-            }
+            ensureMixinType(lockTarget, mixLockable);
+            lockTarget.getParent().save();
 
             // lock dst parent node using other session
             lockTarget.lock(true, true);

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceMoveReferenceableTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceMoveReferenceableTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceMoveReferenceableTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceMoveReferenceableTest.java Wed Jul  1 11:07:13 2009
@@ -44,7 +44,8 @@
      * Copies of referenceable nodes (nodes with UUIDs) remains their original
      * UUIDs.
      */
-    public void testMoveNodesReferenceableNodesNewUUID() throws RepositoryException {
+    public void testMoveNodesReferenceableNodesNewUUID() throws RepositoryException,
+            NotExecutableException {
         // add mixin referenceable to node1
         addMixinReferenceableToNode(node1);
 

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceMoveTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceMoveTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceMoveTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/WorkspaceMoveTest.java Wed Jul  1 11:07:13 2009
@@ -24,6 +24,8 @@
 import javax.jcr.lock.LockException;
 import javax.jcr.nodetype.ConstraintViolationException;
 
+import org.apache.jackrabbit.test.NotExecutableException;
+
 /**
  * <code>WorkspaceMoveTest</code> contains tests for copying nodes in one
  * workspace.
@@ -137,7 +139,8 @@
     /**
      * A LockException is thrown if a lock prevents the copy.
      */
-    public void testMoveNodesLocked() throws RepositoryException {
+    public void testMoveNodesLocked() throws RepositoryException,
+            NotExecutableException {
         // we assume repository supports locking
         String dstAbsPath = node2.getPath() + "/" + node1.getName();
 
@@ -149,10 +152,8 @@
             Node lockTarget = (Node) otherSession.getItem(node2.getPath());
 
             // add mixin "lockable" to be able to lock the node
-            if (!lockTarget.getPrimaryNodeType().isNodeType(mixLockable)) {
-                lockTarget.addMixin(mixLockable);
-                lockTarget.getParent().save();
-            }
+            ensureMixinType(lockTarget, mixLockable);
+            lockTarget.getParent().save();
 
             // lock dst parent node using other session
             lockTarget.lock(true, true);

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/AbstractLockTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/AbstractLockTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/AbstractLockTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/AbstractLockTest.java Wed Jul  1 11:07:13 2009
@@ -52,7 +52,7 @@
         super.setUp();
         
         lockedNode = testRootNode.addNode(nodeName1, testNodeType);
-        lockedNode.addMixin(mixLockable);
+        ensureMixinType(lockedNode, mixLockable);
         childNode = lockedNode.addNode(nodeName2, testNodeType);
         testRootNode.save();
 
@@ -75,11 +75,10 @@
     protected abstract boolean isSessionScoped();
     protected abstract boolean isDeep();
 
-    protected void assertLockable(Node n) throws RepositoryException {
-        if (!n.isNodeType(mixLockable)) {
-            n.addMixin(mixLockable);
-            n.getSession().save();
-        }
+    protected void assertLockable(Node n)
+            throws RepositoryException, NotExecutableException {
+        ensureMixinType(n, mixLockable);
+        n.getSession().save();
     }
 
     protected long getTimeoutHint() throws RepositoryException {
@@ -412,7 +411,8 @@
         }
     }
 
-    public void testRemoveMixLockableFromLockedNode() throws RepositoryException {
+    public void testRemoveMixLockableFromLockedNode() throws RepositoryException,
+            NotExecutableException {
         try {
             lockedNode.removeMixin(mixLockable);
             lockedNode.save();
@@ -439,8 +439,8 @@
             assertTrue(msg, lockedNode.hasProperty(jcrlockIsDeep));
         } finally {
             // ev. re-add the mixin in order to be able to unlock the node
-            if (lockedNode.isLocked() && !lockedNode.isNodeType(mixLockable)) {
-                lockedNode.addMixin(mixLockable);
+            if (lockedNode.isLocked()) {
+                ensureMixinType(lockedNode, mixLockable);
                 lockedNode.save();
             }
         }

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/DeepLockTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/DeepLockTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/DeepLockTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/DeepLockTest.java Wed Jul  1 11:07:13 2009
@@ -49,8 +49,9 @@
         assertTrue("Lock.getNode() must return the lock holding node even if lock is obtained from child node.", lock.getNode().isSame(lockedNode));
     }
 
-    public void testParentChildDeepLock() throws RepositoryException {
-        childNode.addMixin(mixLockable);
+    public void testParentChildDeepLock()
+            throws RepositoryException, NotExecutableException {
+        ensureMixinType(childNode, mixLockable);
         testRootNode.save();
 
         // try to lock child node
@@ -73,7 +74,7 @@
         Node parent = lockedNode.getParent();
         if (!parent.isNodeType(mixLockable)) {
             try {
-                parent.addMixin(mixLockable);
+                ensureMixinType(parent, mixLockable);
                 parent.save();
             } catch (RepositoryException e) {
                 throw new NotExecutableException();
@@ -96,14 +97,8 @@
 
     public void testShallowLockAboveLockedChild() throws RepositoryException, NotExecutableException {
         Node parent = lockedNode.getParent();
-        if (!parent.isNodeType(mixLockable)) {
-            try {
-                parent.addMixin(mixLockable);
-                parent.save();
-            } catch (RepositoryException e) {
-                throw new NotExecutableException();
-            }
-        }
+        ensureMixinType(parent, mixLockable);
+        parent.save();
 
         try {
             // creating a shallow lock on the parent must succeed.

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/LockManagerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/LockManagerTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/LockManagerTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/LockManagerTest.java Wed Jul  1 11:07:13 2009
@@ -64,11 +64,10 @@
         super.tearDown();
     }
 
-    private void assertLockable(Node n) throws RepositoryException {
-        if (!n.isNodeType(mixLockable)) {
-            n.addMixin(mixLockable);
-            n.getSession().save();
-        }
+    private void assertLockable(Node n) throws RepositoryException,
+            NotExecutableException {
+        ensureMixinType(n, mixLockable);
+        n.getSession().save();
     }
 
    private static LockManager getLockManager(Session session) throws RepositoryException {
@@ -100,7 +99,8 @@
         }
     }
 
-    public void testLockWithPendingChanges() throws RepositoryException {
+    public void testLockWithPendingChanges() throws RepositoryException,
+            NotExecutableException {
         assertLockable(testNode);
 
         // transient modification
@@ -113,14 +113,16 @@
         }
     }
 
-    public void testNullOwnerHint() throws RepositoryException {
+    public void testNullOwnerHint() throws RepositoryException,
+            NotExecutableException {
         assertLockable(testNode);
 
         Lock l = lockMgr.lock(testPath, true, true, Long.MAX_VALUE, null);
         assertNotNull(l.getLockOwner());
     }
 
-    public void testGetLockTokens() throws RepositoryException {
+    public void testGetLockTokens() throws RepositoryException,
+            NotExecutableException {
         assertLockable(testNode);
 
         boolean sessionScoped = false;
@@ -132,7 +134,8 @@
                 containsLockToken(superuser.getLockTokens(), ltoken));
     }
 
-    public void testGetLockTokensAfterUnlock() throws RepositoryException {
+    public void testGetLockTokensAfterUnlock() throws RepositoryException,
+            NotExecutableException {
         assertLockable(testNode);
 
         boolean sessionScoped = false;
@@ -146,7 +149,8 @@
                 containsLockToken(superuser.getLockTokens(), ltoken));
     }
 
-    public void testGetLockTokensSessionScoped() throws RepositoryException {
+    public void testGetLockTokensSessionScoped() throws RepositoryException,
+            NotExecutableException {
         assertLockable(testNode);
 
         List tokensBefore = Arrays.asList(lockMgr.getLockTokens());
@@ -160,7 +164,8 @@
                 tokensBefore, Arrays.asList(superuser.getLockTokens()));
     }
 
-    public void testAddLockToken() throws RepositoryException {
+    public void testAddLockToken() throws RepositoryException,
+            NotExecutableException {
         assertLockable(testNode);
 
         boolean sessionScoped = false;
@@ -180,7 +185,8 @@
         }
     }
 
-    public void testAddLockTokenToAnotherSession() throws RepositoryException {
+    public void testAddLockTokenToAnotherSession() throws RepositoryException,
+            NotExecutableException {
         // TODO: for 283 add config option for simultaneous tokens....
         
         assertLockable(testNode);

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/LockTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/LockTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/LockTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/LockTest.java Wed Jul  1 11:07:13 2009
@@ -49,9 +49,7 @@
     public void testAddRemoveLockToken() throws Exception {
         // create new node
         Node n = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n, mixLockable)) {
-            n.addMixin(mixLockable);
-        }
+        ensureMixinType(n, mixLockable);
         testRootNode.save();
 
         // lock node and get lock token
@@ -107,9 +105,7 @@
     public void testNodeLocked() throws Exception {
         // create new node and lock it
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1, mixLockable)) {
-            n1.addMixin(mixLockable);
-        }
+        ensureMixinType(n1, mixLockable);
         testRootNode.save();
 
         // lock node
@@ -147,13 +143,9 @@
     public void testGetNode() throws Exception {
         // create new node with a sub node and lock it
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1, mixLockable)) {
-            n1.addMixin(mixLockable);
-        }
+        ensureMixinType(n1, mixLockable);
         Node n1Sub = n1.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1Sub, mixLockable)) {
-            n1Sub.addMixin(mixLockable);
-        }
+        ensureMixinType(n1Sub, mixLockable);
         testRootNode.save();
 
         // lock node
@@ -177,9 +169,7 @@
     public void testGetLockOwnerProperty() throws Exception {
         // create new node and lock it
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1, mixLockable)) {
-            n1.addMixin(mixLockable);
-        }
+        ensureMixinType(n1, mixLockable);
         testRootNode.save();
 
         // lock node
@@ -205,9 +195,7 @@
     public void testGetLockOwner() throws Exception {
         // create new node and lock it
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1, mixLockable)) {
-            n1.addMixin(mixLockable);
-        }
+        ensureMixinType(n1, mixLockable);
         testRootNode.save();
 
         // lock node
@@ -227,9 +215,7 @@
     public void testShallowLock() throws Exception {
         // create new nodes
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1, mixLockable)) {
-            n1.addMixin(mixLockable);
-        }
+        ensureMixinType(n1, mixLockable);
         Node n2 = n1.addNode(nodeName2, testNodeType);
         testRootNode.save();
 
@@ -252,19 +238,9 @@
 
         // create a node that is lockable and versionable
         Node node = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(node, mixLockable)) {
-            node.addMixin(mixLockable);
-        }
+        ensureMixinType(node, mixLockable);
         // try to make it versionable if it is not
-        if (!node.isNodeType(mixVersionable)) {
-            if (node.canAddMixin(mixVersionable)) {
-                node.addMixin(mixVersionable);
-            } else {
-                throw new NotExecutableException("Node " + nodeName1 + " is " +
-                        "not versionable and does not allow to add " +
-                        "mix:versionable");
-            }
-        }
+        ensureMixinType(node, mixVersionable);
         testRootNode.save();
 
         node.checkin();
@@ -292,13 +268,9 @@
     public void testParentChildLock() throws Exception {
         // create new nodes
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1, mixLockable)) {
-            n1.addMixin(mixLockable);
-        }
+        ensureMixinType(n1, mixLockable);
         Node n2 = n1.addNode(nodeName2, testNodeType);
-        if (needsMixin(n2, mixLockable)) {
-            n2.addMixin(mixLockable);
-        }
+        ensureMixinType(n2, mixLockable);
         testRootNode.save();
 
         // lock parent node
@@ -320,13 +292,9 @@
     public void testParentChildDeepLock() throws Exception {
         // create new nodes
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1, mixLockable)) {
-            n1.addMixin(mixLockable);
-        }
+        ensureMixinType(n1, mixLockable);
         Node n2 = n1.addNode(nodeName2, testNodeType);
-        if (needsMixin(n2, mixLockable)) {
-            n2.addMixin(mixLockable);
-        }
+        ensureMixinType(n2, mixLockable);
         testRootNode.save();
 
         // lock child node
@@ -344,16 +312,12 @@
     /**
      * Test Lock.isDeep()
      */
-    public void testIsDeep() throws RepositoryException {
+    public void testIsDeep() throws RepositoryException, NotExecutableException {
         // create two lockable nodes
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1, mixLockable)) {
-            n1.addMixin(mixLockable);
-        }
+        ensureMixinType(n1, mixLockable);
         Node n2 = testRootNode.addNode(nodeName2, testNodeType);
-        if (needsMixin(n2, mixLockable)) {
-            n2.addMixin(mixLockable);
-        }
+        ensureMixinType(n2, mixLockable);
         testRootNode.save();
 
         // lock node 1 "undeeply"
@@ -372,16 +336,13 @@
     /**
      * Test Lock.isSessionScoped()
      */
-    public void testIsSessionScoped() throws RepositoryException {
+    public void testIsSessionScoped() throws RepositoryException,
+            NotExecutableException {
         // create two lockable nodes
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1, mixLockable)) {
-            n1.addMixin(mixLockable);
-        }
+        ensureMixinType(n1, mixLockable);
         Node n2 = testRootNode.addNode(nodeName2, testNodeType);
-        if (needsMixin(n2, mixLockable)) {
-            n2.addMixin(mixLockable);
-        }
+        ensureMixinType(n2, mixLockable);
         testRootNode.save();
 
         // lock node 1 session-scoped
@@ -405,9 +366,7 @@
     public void testLogout() throws Exception {
         // add node
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1, mixLockable)) {
-            n1.addMixin(mixLockable);
-        }
+        ensureMixinType(n1, mixLockable);
         testRootNode.save();
 
         // create new session
@@ -447,9 +406,7 @@
     public void testLockTransfer() throws Exception {
         // add node
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1, mixLockable)) {
-            n1.addMixin(mixLockable);
-        }
+        ensureMixinType(n1, mixLockable);
         testRootNode.save();
 
         // create new session
@@ -490,9 +447,7 @@
     public void testOpenScopedLocks() throws Exception {
         // add node
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1, mixLockable)) {
-            n1.addMixin(mixLockable);
-        }
+        ensureMixinType(n1, mixLockable);
         testRootNode.save();
 
         // create new session
@@ -524,9 +479,7 @@
     public void testRefresh() throws Exception {
         // create new node
         Node n = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n, mixLockable)) {
-            n.addMixin(mixLockable);
-        }
+        ensureMixinType(n, mixLockable);
         testRootNode.save();
 
         // lock node and get lock token
@@ -551,9 +504,7 @@
     public void testRefreshNotLive() throws Exception {
         // create new node
         Node n = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n, mixLockable)) {
-            n.addMixin(mixLockable);
-        }
+        ensureMixinType(n, mixLockable);
         testRootNode.save();
 
         // lock node and get lock token
@@ -583,13 +534,9 @@
     public void testGetLock() throws Exception {
         // create new nodes
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1, mixLockable)) {
-            n1.addMixin(mixLockable);
-        }
+        ensureMixinType(n1, mixLockable);
         Node n2 = n1.addNode(nodeName2, testNodeType);
-        if (needsMixin(n2, mixLockable)) {
-            n2.addMixin(mixLockable);
-        }
+        ensureMixinType(n2, mixLockable);
         testRootNode.save();
 
         // deep lock parent node
@@ -612,10 +559,8 @@
 
         // set up versionable and lockable node
         Node testNode = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(testNode, mixLockable)) {
-            testNode.addMixin(mixLockable);
-        }
-        testNode.addMixin(mixVersionable);
+        ensureMixinType(testNode, mixLockable);
+        ensureMixinType(testNode, mixVersionable);
         testRootNode.save();
 
         // lock and check-in
@@ -691,13 +636,9 @@
 
         // create two nodes, parent and child
         Node testNode1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(testNode1, mixLockable)) {
-            testNode1.addMixin(mixLockable);
-        }
+        ensureMixinType(testNode1, mixLockable);
         Node testNode2 = testNode1.addNode(nodeName2, testNodeType);
-        if (needsMixin(testNode2, mixLockable)) {
-            testNode2.addMixin(mixLockable);
-        }
+        ensureMixinType(testNode2, mixLockable);
         testRootNode.save();
 
         // lock child node
@@ -737,8 +678,8 @@
             throw new NotExecutableException("Node does not seem to allow same name siblings");
         }
 
-        n1.addMixin("mix:lockable");
-        n2.addMixin("mix:lockable");
+        ensureMixinType(n1, mixLockable);
+        ensureMixinType(n2, mixLockable);
         session.save();
 
         // lock both nodes
@@ -778,17 +719,11 @@
         // create three lockable nodes with same name
         try {
             Node testNode = testRootNode.addNode(nodeName1, testNodeType);
-            if (needsMixin(testNode, mixLockable)) {
-                testNode.addMixin(mixLockable);
-            }
+            ensureMixinType(testNode, mixLockable);
             testNode = testRootNode.addNode(nodeName1, testNodeType);
-            if (needsMixin(testNode, mixLockable)) {
-                testNode.addMixin(mixLockable);
-            }
+            ensureMixinType(testNode, mixLockable);
             testNode = testRootNode.addNode(nodeName1, testNodeType);
-            if (needsMixin(testNode, mixLockable)) {
-                testNode.addMixin(mixLockable);
-            }
+            ensureMixinType(testNode, mixLockable);
             testRootNode.save();
             return testNode;
         }



Mime
View raw message