jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r790118 [2/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
Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/SessionScopedLockTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/SessionScopedLockTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/SessionScopedLockTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/SessionScopedLockTest.java Wed Jul  1 11:07:13 2009
@@ -18,6 +18,7 @@
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.apache.jackrabbit.test.NotExecutableException;
 
 import javax.jcr.RepositoryException;
 import javax.jcr.Node;
@@ -50,7 +51,8 @@
     /**
      * Test locks are released when session logs out
      */
-    public void testImplicitUnlock() throws RepositoryException {
+    public void testImplicitUnlock() throws RepositoryException,
+            NotExecutableException {
         Session other = helper.getReadWriteSession();
         try {
             Node testNode = (Node) other.getItem(testRootNode.getPath());
@@ -73,7 +75,8 @@
     /**
      * Test locks are released when session logs out
      */
-    public void testImplicitUnlock2() throws RepositoryException {
+    public void testImplicitUnlock2() throws RepositoryException,
+            NotExecutableException {
         Session other = helper.getReadWriteSession();
         try {
             Node testNode = (Node) other.getItem(testRootNode.getPath());

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/SetValueLockExceptionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/SetValueLockExceptionTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/SetValueLockExceptionTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/lock/SetValueLockExceptionTest.java Wed Jul  1 11:07:13 2009
@@ -88,9 +88,7 @@
         else {
             // add a lockable node
             testNode = testRootNode.addNode(nodeName1, testNodeType);
-            if (needsMixin(testNode, mixLockable)) {
-                testNode.addMixin(mixLockable);
-            }
+            ensureMixinType(testNode, mixLockable);
 
             // add properties
             dateValue = Calendar.getInstance();

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/AddEventListenerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/AddEventListenerTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/AddEventListenerTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/AddEventListenerTest.java Wed Jul  1 11:07:13 2009
@@ -188,13 +188,10 @@
      * @throws RepositoryException if node creation fails.
      */
     private Node createReferenceable(String nodeName, String nodeType)
-            throws RepositoryException {
+            throws RepositoryException, NotExecutableException {
         Node n = testRootNode.addNode(nodeName, nodeType);
-        if (needsMixin(n, mixReferenceable)) {
-            n.addMixin(mixReferenceable);
-            // some implementations may require a save after addMixin()
-            testRootNode.save();
-        }
+        ensureMixinType(n, mixReferenceable);
+        testRootNode.save();
         return n;
     }
 }

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/EventJournalTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/EventJournalTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/EventJournalTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/EventJournalTest.java Wed Jul  1 11:07:13 2009
@@ -26,6 +26,8 @@
 import javax.jcr.observation.Event;
 import javax.jcr.observation.EventJournal;
 
+import org.apache.jackrabbit.test.NotExecutableException;
+
 /**
  * <code>EventJournalTest</code> performs EventJournal tests.
  */
@@ -107,11 +109,9 @@
         checkJournal(new String[]{n1.getPath(), n2.getPath()}, new String[0]);
     }
 
-    public void testUUID() throws RepositoryException {
+    public void testUUID() throws RepositoryException, NotExecutableException {
         Node n1 = testRootNode.addNode(nodeName1);
-        if (!n1.isNodeType(mixReferenceable)) {
-            n1.addMixin(mixReferenceable);
-        }
+        ensureMixinType(n1, mixReferenceable);
         superuser.save();
 
         Node n2 = n1.addNode(nodeName2);

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/GetUserDataTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/GetUserDataTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/GetUserDataTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/GetUserDataTest.java Wed Jul  1 11:07:13 2009
@@ -56,7 +56,7 @@
         checkSupportedOption(Repository.OPTION_VERSIONING_SUPPORTED);
 
         final Node n1 = testRootNode.addNode(nodeName1);
-        n1.addMixin(mixVersionable);
+        ensureMixinType(n1, mixVersionable);
         testRootNode.save();
 
         runWithUserData(new Callable() {

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/LockingTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/LockingTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/LockingTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/observation/LockingTest.java Wed Jul  1 11:07:13 2009
@@ -22,6 +22,8 @@
 import java.util.List;
 import java.util.ArrayList;
 
+import org.apache.jackrabbit.test.NotExecutableException;
+
 /**
  * Tests if locking a node triggers property added events for jcr:lockOwner
  * and jcr:lockIsDeep.
@@ -44,7 +46,8 @@
      * Tests if locking a node triggers property added events for the properties
      * jcr:lockOwner and jcr:lockIsDeep.
      */
-    public void testAddLockToNode() throws RepositoryException {
+    public void testAddLockToNode() throws RepositoryException,
+            NotExecutableException {
         Node lockable = createLockable(nodeName1, testNodeType);
         testRootNode.save();
         EventResult result = new EventResult(log);
@@ -76,7 +79,8 @@
      * Tests if unlocking a node triggers property removed events for the
      * properties jcr:lockOwner and jcr:lockIsDeep.
      */
-    public void testRemoveLockFromNode() throws RepositoryException {
+    public void testRemoveLockFromNode() throws RepositoryException,
+            NotExecutableException {
         Node lockable = createLockable(nodeName1, testNodeType);
         testRootNode.save();
         // lock the node
@@ -111,11 +115,9 @@
      * @return the lockable node
      */
     private Node createLockable(String nodeName, String nodeType)
-            throws RepositoryException {
+            throws RepositoryException, NotExecutableException {
         Node n = testRootNode.addNode(nodeName, nodeType);
-        if (needsMixin(n, mixLockable)) {
-            n.addMixin(mixLockable);
-        }
+        ensureMixinType(n, mixLockable);
         return n;
     }
 }
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLJoinTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLJoinTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLJoinTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SQLJoinTest.java Wed Jul  1 11:07:13 2009
@@ -41,16 +41,15 @@
     /**
      * Test a SQL query with a primary and mixin nodetype join.
      */
-    public void testJoin() throws RepositoryException {
+    public void testJoin() throws RepositoryException, NotExecutableException {
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
         String testMixin = mixReferenceable;
         if (needsMixin(n1, testMixin)) {
-            n1.addMixin(testMixin);
-        }
-        else {
+            ensureMixinType(n1, testMixin);
+        } else {
             testMixin = mixVersionable;
             if (needsMixin(n1, testMixin)) {
-                n1.addMixin(testMixin);
+                ensureMixinType(n1, testMixin);
             }
         }
 
@@ -74,16 +73,16 @@
     /**
      * Test a SQL query with a nt:base primary type and mixin nodetype join.
      */
-    public void testJoinNtBase() throws RepositoryException {
+    public void testJoinNtBase() throws RepositoryException,
+            NotExecutableException {
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
         String testMixin = mixReferenceable;
         if (needsMixin(n1, testMixin)) {
-            n1.addMixin(testMixin);
-        }
-        else {
+            ensureMixinType(n1, testMixin);
+        } else {
             testMixin = mixVersionable;
             if (needsMixin(n1, testMixin)) {
-                n1.addMixin(testMixin);
+                ensureMixinType(n1, testMixin);
             }
         }
 
@@ -107,15 +106,12 @@
     /**
      * Test a SQL query with a primary type and mixin nodetype join.
      */
-    public void testJoinFilterPrimaryType() throws RepositoryException {
+    public void testJoinFilterPrimaryType()
+            throws RepositoryException, NotExecutableException {
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1, mixReferenceable)) {
-            n1.addMixin(mixReferenceable);
-        }
+        ensureMixinType(n1, mixReferenceable);
         Node n2 = testRootNode.addNode(nodeName2, ntBase);
-        if (needsMixin(n2, mixReferenceable)) {
-            n2.addMixin(mixReferenceable);
-        }
+        ensureMixinType(n2, mixReferenceable);
         testRootNode.save();
 
         StringBuffer query = new StringBuffer("SELECT * FROM ");
@@ -140,15 +136,13 @@
      */
     public void testJoinSNS() throws RepositoryException, NotExecutableException {
         Node n1 = testRootNode.addNode(nodeName1, testNodeType);
-        if (needsMixin(n1, mixReferenceable)) {
-            n1.addMixin(mixReferenceable);
-        }
+        ensureMixinType(n1, mixReferenceable);
         if (!n1.getDefinition().allowsSameNameSiblings()) {
             throw new NotExecutableException("Node at " + testRoot + " does not allow same name siblings with name " + nodeName1);
         }
         testRootNode.addNode(nodeName1, testNodeType);
         Node n2 = testRootNode.addNode(nodeName2, testNodeType);
-        n2.addMixin(mixReferenceable);
+        ensureMixinType(n2, mixReferenceable);
         testRootNode.save();
 
         StringBuffer query = new StringBuffer("SELECT * FROM ");

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SaveTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SaveTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SaveTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SaveTest.java Wed Jul  1 11:07:13 2009
@@ -133,13 +133,7 @@
         // create a node that is versionable
         Node versionable = testRootNode.addNode(nodeName1, testNodeType);
         // or try to make it versionable if it is not
-        if (!versionable.isNodeType(mixVersionable)) {
-            if (versionable.canAddMixin(mixVersionable)) {
-                versionable.addMixin(mixVersionable);
-            } else {
-                fail("Node " + nodeName1 + " is not versionable and does not allow to add mix:versionable");
-            }
-        }
+        ensureMixinType(versionable, mixVersionable);
         testRootNode.save();
         versionable.checkin();
 
@@ -191,13 +185,7 @@
         // create a node that is lockable
         Node lockable = testRootNode.addNode(nodeName1, testNodeType);
         // or try to make it lockable if it is not
-        if (!lockable.isNodeType(mixLockable)) {
-            if (lockable.canAddMixin(mixLockable)) {
-                lockable.addMixin(mixLockable);
-            } else {
-                fail("Node " + nodeName1 + " is not lockable and does not allow to add mix:lockable");
-            }
-        }
+        ensureMixinType(lockable, mixLockable);
         testRootNode.save();
         lockable.lock(false, true);
 

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/BindVariableValueTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/BindVariableValueTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/BindVariableValueTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/BindVariableValueTest.java Wed Jul  1 11:07:13 2009
@@ -26,6 +26,8 @@
 import javax.jcr.query.Query;
 import javax.jcr.query.qom.QueryObjectModelConstants;
 
+import org.apache.jackrabbit.test.NotExecutableException;
+
 /**
  * <code>BindVariableValueTest</code>...
  */
@@ -170,14 +172,13 @@
         checkResult(sqlQuery.execute(), new Node[]{n});
     }
 
-    public void testReference() throws RepositoryException {
+    public void testReference() throws RepositoryException,
+            NotExecutableException {
         Node n = testRootNode.addNode(nodeName1, testNodeType);
         superuser.save();
 
-        if (!n.isNodeType(mixReferenceable)) {
-            n.addMixin(mixReferenceable);
-            superuser.save();
-        }
+        ensureMixinType(n, mixReferenceable);
+        superuser.save();
         n.setProperty(propertyName1, n);
         superuser.save();
 
@@ -189,14 +190,13 @@
         checkResult(sqlQuery.execute(), new Node[]{n});
     }
 
-    public void testWeakReference() throws RepositoryException {
+    public void testWeakReference() throws RepositoryException,
+            NotExecutableException {
         Node n = testRootNode.addNode(nodeName1, testNodeType);
         superuser.save();
 
-        if (!n.isNodeType(mixReferenceable)) {
-            n.addMixin(mixReferenceable);
-            superuser.save();
-        }
+        ensureMixinType(n, mixReferenceable);
+        superuser.save();
         n.setProperty(propertyName1, vf.createValue(n, true));
         superuser.save();
 

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/ChildNodeJoinConditionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/ChildNodeJoinConditionTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/ChildNodeJoinConditionTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/ChildNodeJoinConditionTest.java Wed Jul  1 11:07:13 2009
@@ -39,7 +39,7 @@
         super.setUp();
         n1 = testRootNode.addNode(nodeName1, testNodeType);
         n2 = n1.addNode(nodeName2, testNodeType);
-        n2.addMixin(mixReferenceable);
+        ensureMixinType(n2, mixReferenceable);
         superuser.save();
     }
 

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/DescendantNodeJoinConditionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/DescendantNodeJoinConditionTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/DescendantNodeJoinConditionTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/DescendantNodeJoinConditionTest.java Wed Jul  1 11:07:13 2009
@@ -39,7 +39,7 @@
         super.setUp();
         n1 = testRootNode.addNode(nodeName1, testNodeType);
         n2 = n1.addNode(nodeName2, testNodeType);
-        n2.addMixin(mixReferenceable);
+        ensureMixinType(n2, mixReferenceable);
         superuser.save();
     }
 

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/EquiJoinConditionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/EquiJoinConditionTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/EquiJoinConditionTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/EquiJoinConditionTest.java Wed Jul  1 11:07:13 2009
@@ -41,7 +41,7 @@
         n2 = n1.addNode(nodeName2, testNodeType);
         n2.setProperty(propertyName1, value);
         n2.setProperty(propertyName2, value);
-        n2.addMixin(mixReferenceable);
+        ensureMixinType(n2, mixReferenceable);
         superuser.save();
     }
 

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/LengthTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/LengthTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/LengthTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/LengthTest.java Wed Jul  1 11:07:13 2009
@@ -108,14 +108,8 @@
     }
 
     public void testReferenceLength() throws RepositoryException, NotExecutableException {
-        try {
-            if (!node.isNodeType(mixReferenceable)) {
-                node.addMixin(mixReferenceable);
-                superuser.save();
-            }
-        } catch (RepositoryException e) {
-            throw new NotExecutableException("Cannot add mix:referenceable to node");
-        }
+        ensureMixinType(node, mixReferenceable);
+        superuser.save();
         node.setProperty(propertyName1, node);
         superuser.save();
         checkOperators(propertyName1, node.getProperty(propertyName1).getLength());
@@ -123,14 +117,8 @@
 
     public void testWeakReferenceLength()
             throws RepositoryException, NotExecutableException {
-        try {
-            if (!node.isNodeType(mixReferenceable)) {
-                node.addMixin(mixReferenceable);
-                superuser.save();
-            }
-        } catch (RepositoryException e) {
-            throw new NotExecutableException("Cannot add mix:referenceable to node");
-        }
+        ensureMixinType(node, mixReferenceable);
+        superuser.save();
         node.setProperty(propertyName1, vf.createValue(node, true));
         superuser.save();
         checkOperators(propertyName1, node.getProperty(propertyName1).getLength());
@@ -219,14 +207,8 @@
     }
 
     public void testLengthReferenceLiteral() throws RepositoryException, NotExecutableException {
-        try {
-            if (!node.isNodeType(mixReferenceable)) {
-                node.addMixin(mixReferenceable);
-                superuser.save();
-            }
-        } catch (RepositoryException e) {
-            throw new NotExecutableException("Cannot add mix:referenceable to node");
-        }
+        ensureMixinType(node, mixReferenceable);
+        superuser.save();
         try {
             executeQueries(propertyName1, QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, vf.createValue(node));
             fail("Reference literal cannot be converted to long");
@@ -236,14 +218,8 @@
     }
 
     public void testLengthWeakReferenceLiteral() throws RepositoryException, NotExecutableException {
-        try {
-            if (!node.isNodeType(mixReferenceable)) {
-                node.addMixin(mixReferenceable);
-                superuser.save();
-            }
-        } catch (RepositoryException e) {
-            throw new NotExecutableException("Cannot add mix:referenceable to node");
-        }
+        ensureMixinType(node, mixReferenceable);
+        superuser.save();
         try {
             executeQueries(propertyName1, QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, vf.createValue(node, true));
             fail("Reference literal cannot be converted to long");

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/NodeLocalNameTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/NodeLocalNameTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/NodeLocalNameTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/NodeLocalNameTest.java Wed Jul  1 11:07:13 2009
@@ -27,6 +27,8 @@
 import java.util.Calendar;
 import java.math.BigDecimal;
 
+import org.apache.jackrabbit.test.NotExecutableException;
+
 /**
  * <code>NodeLocalNameTest</code> checks if conversion of literals is correctly
  * performed and operators work as specified.
@@ -127,20 +129,18 @@
         checkQOM(qom, new Node[]{});
     }
 
-    public void testReferenceLiteral() throws RepositoryException {
-        if (!node1.isNodeType(mixReferenceable)) {
-            node1.addMixin(mixReferenceable);
-        }
+    public void testReferenceLiteral() throws RepositoryException,
+            NotExecutableException {
+        ensureMixinType(node1, mixReferenceable);
         superuser.save();
         Value literal = superuser.getValueFactory().createValue(node1);
         QueryObjectModel qom = createQuery(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, literal);
         checkQOM(qom, new Node[]{});
     }
 
-    public void testWeakReferenceLiteral() throws RepositoryException {
-        if (!node1.isNodeType(mixReferenceable)) {
-            node1.addMixin(mixReferenceable);
-        }
+    public void testWeakReferenceLiteral() throws RepositoryException,
+            NotExecutableException {
+        ensureMixinType(node1, mixReferenceable);
         superuser.save();
         Value literal = superuser.getValueFactory().createValue(node1, true);
         QueryObjectModel qom = createQuery(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, literal);

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/NodeNameTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/NodeNameTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/NodeNameTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/NodeNameTest.java Wed Jul  1 11:07:13 2009
@@ -28,6 +28,8 @@
 import java.util.Calendar;
 import java.math.BigDecimal;
 
+import org.apache.jackrabbit.test.NotExecutableException;
+
 /**
  * <code>NodeNameTest</code> checks if conversion of literals is correctly
  * performed and operators work as specified.
@@ -212,10 +214,9 @@
         }
     }
 
-    public void testReferenceLiteral() throws RepositoryException {
-        if (!node1.isNodeType(mixReferenceable)) {
-            node1.addMixin(mixReferenceable);
-        }
+    public void testReferenceLiteral() throws RepositoryException,
+            NotExecutableException {
+        ensureMixinType(node1, mixReferenceable);
         superuser.save();
         Value literal = vf.createValue(node1);
         try {
@@ -234,10 +235,9 @@
         }
     }
 
-    public void testWeakReferenceLiteral() throws RepositoryException {
-        if (!node1.isNodeType(mixReferenceable)) {
-            node1.addMixin(mixReferenceable);
-        }
+    public void testWeakReferenceLiteral() throws RepositoryException,
+            NotExecutableException {
+        ensureMixinType(node1, mixReferenceable);
         superuser.save();
         Value literal = vf.createValue(node1, true);
         try {

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/SameNodeJoinConditionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/SameNodeJoinConditionTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/SameNodeJoinConditionTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/SameNodeJoinConditionTest.java Wed Jul  1 11:07:13 2009
@@ -36,7 +36,7 @@
         super.setUp();
         n1 = testRootNode.addNode(nodeName1, testNodeType);
         n2 = n1.addNode(nodeName2, testNodeType);
-        n2.addMixin(mixReferenceable);
+        ensureMixinType(n2, mixReferenceable);
         superuser.save();
     }
 

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/retention/HoldTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/retention/HoldTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/retention/HoldTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/retention/HoldTest.java Wed Jul  1 11:07:13 2009
@@ -312,13 +312,7 @@
     private Node getLockedChildNode() throws NotExecutableException, RepositoryException {
         checkSupportedOption(Repository.OPTION_LOCKING_SUPPORTED);
         Node child = testRootNode.addNode(nodeName2, testNodeType);
-        if (!child.isNodeType(mixLockable)) {
-            if (child.canAddMixin(mixLockable)) {
-                child.addMixin(mixLockable);
-            } else {
-                throw new NotExecutableException();
-            }
-        }
+        ensureMixinType(child, mixLockable);
         testRootNode.save();
         child.lock(false, true); // session-scoped lock clean upon superuser-logout.
         return child;
@@ -391,13 +385,7 @@
     private Node getVersionableChildNode() throws NotExecutableException, RepositoryException {
         checkSupportedOption(Repository.OPTION_VERSIONING_SUPPORTED);
         Node child = testRootNode.addNode(nodeName2, testNodeType);
-        if (!child.isNodeType(mixVersionable)) {
-            if (child.canAddMixin(mixVersionable)) {
-                child.addMixin(mixVersionable);
-            } else {
-                throw new NotExecutableException();
-            }
-        }
+        ensureMixinType(child, mixVersionable);
         testRootNode.save();
         return child;
     }

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/retention/RetentionPolicyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/retention/RetentionPolicyTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/retention/RetentionPolicyTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/retention/RetentionPolicyTest.java Wed Jul  1 11:07:13 2009
@@ -305,13 +305,7 @@
     private Node getLockedChildNode() throws NotExecutableException, RepositoryException {
         checkSupportedOption(Repository.OPTION_LOCKING_SUPPORTED);
         Node child = testRootNode.addNode(nodeName2, testNodeType);
-        if (!child.isNodeType(mixLockable)) {
-            if (child.canAddMixin(mixLockable)) {
-                child.addMixin(mixLockable);
-            } else {
-                throw new NotExecutableException();
-            }
-        }
+        ensureMixinType(child, mixLockable);
         testRootNode.save();
         child.lock(false, true); // session-scoped lock clean upon superuser-logout.
         return child;
@@ -378,13 +372,7 @@
     private Node getVersionableChildNode() throws NotExecutableException, RepositoryException {
         checkSupportedOption(Repository.OPTION_VERSIONING_SUPPORTED);
         Node child = testRootNode.addNode(nodeName2, testNodeType);
-        if (!child.isNodeType(mixVersionable)) {
-            if (child.canAddMixin(mixVersionable)) {
-                child.addMixin(mixVersionable);
-            } else {
-                throw new NotExecutableException();
-            }
-        }
+        ensureMixinType(child, mixVersionable);
         testRootNode.save();
         return child;
     }

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/AbstractVersionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/AbstractVersionTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/AbstractVersionTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/AbstractVersionTest.java Wed Jul  1 11:07:13 2009
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.test.api.version;
 
 import org.apache.jackrabbit.test.AbstractJCRTest;
+import org.apache.jackrabbit.test.NotExecutableException;
 
 import javax.jcr.nodetype.NodeTypeManager;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
@@ -132,11 +133,10 @@
      * @return versionable node.
      * @throws RepositoryException
      */
-    protected Node createVersionableNode(Node parent, String name, NodeType nodetype) throws RepositoryException {
+    protected Node createVersionableNode(Node parent, String name, NodeType nodetype)
+            throws RepositoryException, NotExecutableException {
         Node versionableNode = parent.addNode(name, nodetype.getName());
-        if (!nodetype.isNodeType(mixVersionable)) {
-            versionableNode.addMixin(mixVersionable);
-        }
+        ensureMixinType(versionableNode, mixVersionable);
         parent.save();
 
         return versionableNode;

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/FrozenNodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/FrozenNodeTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/FrozenNodeTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/FrozenNodeTest.java Wed Jul  1 11:07:13 2009
@@ -21,6 +21,8 @@
 import javax.jcr.version.Version;
 import javax.jcr.version.VersionManager;
 
+import org.apache.jackrabbit.test.NotExecutableException;
+
 /**
  * <code>CheckinTest</code> covers tests related to {@link javax.jcr.Node#checkin()}.
  *
@@ -70,9 +72,10 @@
     /**
      * @throws RepositoryException
      */
-    public void testFrozenUUUID() throws RepositoryException {
+    public void testFrozenUUUID() throws RepositoryException,
+            NotExecutableException {
         // make versionable node referenceable
-        versionableNode.addMixin(mixReferenceable);
+        ensureMixinType(versionableNode, mixReferenceable);
         versionableNode.getSession().save();
         VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
         String path = versionableNode.getPath();
@@ -86,9 +89,10 @@
     /**
      * @throws RepositoryException
      */
-    public void testFrozenChildUUUID() throws RepositoryException {
+    public void testFrozenChildUUUID() throws RepositoryException,
+            NotExecutableException {
         Node n1 = versionableNode.addNode("child");
-        n1.addMixin(mixReferenceable);
+        ensureMixinType(n1, mixReferenceable);
         versionableNode.getSession().save();
         VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
         String path = versionableNode.getPath();

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/GetReferencesNodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/GetReferencesNodeTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/GetReferencesNodeTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/GetReferencesNodeTest.java Wed Jul  1 11:07:13 2009
@@ -99,12 +99,11 @@
         assertFalse(nodeToBeReferencedIsReference);
     }
 
-    private void initTestNodes() throws RepositoryException {
+    private void initTestNodes() throws RepositoryException,
+            NotExecutableException {
         // create a versionable node with reference property
         testNode = testRootNode.addNode(nodeName1, versionableNodeType);
-        if (needsMixin(testNode, mixVersionable)) {
-          testNode.addMixin(mixVersionable);
-        }
+        ensureMixinType(testNode, mixVersionable);
 
         // node to be referenced, does not have to be versionable
         nodeToBeReferenced = testRootNode.addNode(nodeName2, versionableNodeType);

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/MergeNodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/MergeNodeTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/MergeNodeTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/MergeNodeTest.java Wed Jul  1 11:07:13 2009
@@ -479,14 +479,7 @@
         }
 
         // try to make nodeToMerge lockable if it is not
-        if (!nodeToMerge.isNodeType(mixLockable)) {
-            if (nodeToMerge.canAddMixin(mixLockable)) {
-                nodeToMerge.addMixin(mixLockable);
-            } else {
-                throw new NotExecutableException("Node " + nodeToMerge.getName() + " is not lockable and " +
-                        "does not allow to add mix:lockable");
-            }
-        }
+        ensureMixinType(nodeToMerge, mixLockable);
         nodeToMerge.getParent().save();
 
         // lock the node
@@ -525,14 +518,7 @@
         }
 
         // try to make nodeToMerge lockable if it is not
-        if (!nodeToMerge.isNodeType(mixLockable)) {
-            if (nodeToMerge.canAddMixin(mixLockable)) {
-                nodeToMerge.addMixin(mixLockable);
-            } else {
-                throw new NotExecutableException("Node " + nodeToMerge.getName() + " is not lockable and " +
-                        "does not allow to add mix:lockable");
-            }
-        }
+        ensureMixinType(nodeToMerge, mixLockable);
         nodeToMerge.getParent().getSession().save();
 
         // lock the node

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/RestoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/RestoreTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/RestoreTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/RestoreTest.java Wed Jul  1 11:07:13 2009
@@ -943,12 +943,11 @@
      * Test the restore of the OPV=Version child nodes.
      * @throws RepositoryException
      */
-    public void testRestoreName() throws RepositoryException {
+    public void testRestoreName() throws RepositoryException,
+            NotExecutableException {
         // V1.0 of versionableNode has no child
         Node child1 = versionableNode.addNode(nodeName4);
-        if (!child1.isNodeType(mixVersionable)) {
-            child1.addMixin(mixVersionable);
-        }
+        ensureMixinType(child1, mixVersionable);
         versionableNode.getSession().save();
         // create v1.0 of child
         Version v1Child = child1.checkin();
@@ -984,12 +983,11 @@
      * Test the restore of the OPV=Version child nodes.
      * @throws RepositoryException
      */
-    public void testRestoreNameJcr2() throws RepositoryException {
+    public void testRestoreNameJcr2() throws RepositoryException,
+            NotExecutableException {
         // V1.0 of versionableNode has no child
         Node child1 = versionableNode.addNode(nodeName4);
-        if (!child1.isNodeType(mixVersionable)) {
-            child1.addMixin(mixVersionable);
-        }
+        ensureMixinType(child1, mixVersionable);
         versionableNode.getSession().save();
         // create v1.0 of child
         Version v1Child = child1.checkin();
@@ -1025,21 +1023,18 @@
      * Test the child ordering of restored nodes.
      * @throws RepositoryException
      */
-    public void testRestoreOrder() throws RepositoryException {
+    public void testRestoreOrder() throws RepositoryException,
+            NotExecutableException {
         // create a test-root that has orderable child nodes
         Node testRoot = versionableNode.addNode(nodeName4, "nt:unstructured");
-        testRoot.addMixin(mixVersionable);
+        ensureMixinType(testRoot, mixVersionable);
         versionableNode.getSession().save();
 
         // create children of vNode and checkin
         Node child1 = testRoot.addNode(nodeName1);
-        if (!child1.isNodeType(mixVersionable)) {
-            child1.addMixin(mixVersionable);
-        }
+        ensureMixinType(child1, mixVersionable);
         Node child2 = testRoot.addNode(nodeName2);
-        if (!child2.isNodeType(mixVersionable)) {
-            child2.addMixin(mixVersionable);
-        }
+        ensureMixinType(child2, mixVersionable);
         testRoot.getSession().save();
         child1.checkin();
         child2.checkin();
@@ -1069,21 +1064,18 @@
      * Test the child ordering of restored nodes.
      * @throws RepositoryException
      */
-    public void testRestoreOrderJcr2() throws RepositoryException {
+    public void testRestoreOrderJcr2() throws RepositoryException,
+            NotExecutableException {
         // create a test-root that has orderable child nodes
         Node testRoot = versionableNode.addNode(nodeName4, "nt:unstructured");
-        testRoot.addMixin(mixVersionable);
+        ensureMixinType(testRoot, mixVersionable);
         versionableNode.getSession().save();
 
         // create children of vNode and checkin
         Node child1 = testRoot.addNode(nodeName1);
-        if (!child1.isNodeType(mixVersionable)) {
-            child1.addMixin(mixVersionable);
-        }
+        ensureMixinType(child1, mixVersionable);
         Node child2 = testRoot.addNode(nodeName2);
-        if (!child2.isNodeType(mixVersionable)) {
-            child2.addMixin(mixVersionable);
-        }
+        ensureMixinType(child2, mixVersionable);
         testRoot.getSession().save();
         versionManager.checkin(child1.getPath());
         versionManager.checkin(child2.getPath());
@@ -1113,21 +1105,18 @@
      * Test the child ordering of restored nodes.
      * @throws RepositoryException
      */
-    public void testRestoreOrderJcr2_2() throws RepositoryException {
+    public void testRestoreOrderJcr2_2() throws RepositoryException,
+            NotExecutableException {
         // create a test-root that has orderable child nodes
         Node testRoot = versionableNode.addNode(nodeName4, "nt:unstructured");
-        testRoot.addMixin(mixVersionable);
+        ensureMixinType(testRoot, mixVersionable);
         versionableNode.getSession().save();
 
         // create children of vNode and checkin
         Node child1 = testRoot.addNode(nodeName1);
-        if (!child1.isNodeType(mixVersionable)) {
-            child1.addMixin(mixVersionable);
-        }
+        ensureMixinType(child1, mixVersionable);
         Node child2 = testRoot.addNode(nodeName2);
-        if (!child2.isNodeType(mixVersionable)) {
-            child2.addMixin(mixVersionable);
-        }
+        ensureMixinType(child2, mixVersionable);
         testRoot.getSession().save();
         versionManager.checkin(child1.getPath());
         versionManager.checkin(child2.getPath());
@@ -1157,21 +1146,18 @@
      * Test the child ordering of restored nodes.
      * @throws RepositoryException
      */
-    public void testRestoreOrderJcr2_3() throws RepositoryException {
+    public void testRestoreOrderJcr2_3() throws RepositoryException,
+            NotExecutableException {
         // create a test-root that has orderable child nodes
         Node testRoot = versionableNode.addNode(nodeName4, "nt:unstructured");
-        testRoot.addMixin(mixVersionable);
+        ensureMixinType(testRoot, mixVersionable);
         versionableNode.getSession().save();
 
         // create children of vNode and checkin
         Node child1 = testRoot.addNode(nodeName1);
-        if (!child1.isNodeType(mixVersionable)) {
-            child1.addMixin(mixVersionable);
-        }
+        ensureMixinType(child1, mixVersionable);
         Node child2 = testRoot.addNode(nodeName2);
-        if (!child2.isNodeType(mixVersionable)) {
-            child2.addMixin(mixVersionable);
-        }
+        ensureMixinType(child2, mixVersionable);
         testRoot.getSession().save();
         versionManager.checkin(child1.getPath());
         versionManager.checkin(child2.getPath());
@@ -1201,21 +1187,18 @@
      * Test the child ordering of restored nodes.
      * @throws RepositoryException
      */
-    public void testRestoreOrderJcr2_4() throws RepositoryException {
+    public void testRestoreOrderJcr2_4() throws RepositoryException,
+            NotExecutableException {
         // create a test-root that has orderable child nodes
         Node testRoot = versionableNode.addNode(nodeName4, "nt:unstructured");
-        testRoot.addMixin(mixVersionable);
+        ensureMixinType(testRoot, mixVersionable);
         versionableNode.getSession().save();
 
         // create children of vNode and checkin
         Node child1 = testRoot.addNode(nodeName1);
-        if (!child1.isNodeType(mixVersionable)) {
-            child1.addMixin(mixVersionable);
-        }
+        ensureMixinType(child1, mixVersionable);
         Node child2 = testRoot.addNode(nodeName2);
-        if (!child2.isNodeType(mixVersionable)) {
-            child2.addMixin(mixVersionable);
-        }
+        ensureMixinType(child2, mixVersionable);
         testRoot.getSession().save();
         versionManager.checkin(child1.getPath());
         versionManager.checkin(child2.getPath());
@@ -1245,21 +1228,18 @@
      * Test the child ordering of restored nodes.
      * @throws RepositoryException
      */
-    public void testRestoreOrder2() throws RepositoryException {
+    public void testRestoreOrder2() throws RepositoryException,
+            NotExecutableException {
         // create a test-root that has orderable child nodes
         Node testRoot = versionableNode.addNode(nodeName4, "nt:unstructured");
-        testRoot.addMixin(mixVersionable);
+        ensureMixinType(testRoot, mixVersionable);
         versionableNode.getSession().save();
 
         // create children of vNode and checkin
         Node child1 = testRoot.addNode(nodeName1);
-        if (!child1.isNodeType(mixVersionable)) {
-            child1.addMixin(mixVersionable);
-        }
+        ensureMixinType(child1, mixVersionable);
         Node child2 = testRoot.addNode(nodeName2);
-        if (!child2.isNodeType(mixVersionable)) {
-            child2.addMixin(mixVersionable);
-        }
+        ensureMixinType(child2, mixVersionable);
         testRoot.getSession().save();
         child1.checkin();
         child2.checkin();
@@ -1289,21 +1269,18 @@
      * Test the child ordering of restored nodes.
      * @throws RepositoryException
      */
-    public void testRestoreOrder2Jcr2() throws RepositoryException {
+    public void testRestoreOrder2Jcr2() throws RepositoryException,
+            NotExecutableException {
         // create a test-root that has orderable child nodes
         Node testRoot = versionableNode.addNode(nodeName4, "nt:unstructured");
-        testRoot.addMixin(mixVersionable);
+        ensureMixinType(testRoot, mixVersionable);
         versionableNode.getSession().save();
 
         // create children of vNode and checkin
         Node child1 = testRoot.addNode(nodeName1);
-        if (!child1.isNodeType(mixVersionable)) {
-            child1.addMixin(mixVersionable);
-        }
+        ensureMixinType(child1, mixVersionable);
         Node child2 = testRoot.addNode(nodeName2);
-        if (!child2.isNodeType(mixVersionable)) {
-            child2.addMixin(mixVersionable);
-        }
+        ensureMixinType(child2, mixVersionable);
         testRoot.getSession().save();
         versionManager.checkin(child1.getPath());
         versionManager.checkin(child2.getPath());
@@ -1333,21 +1310,18 @@
      * Test the child ordering of restored nodes.
      * @throws RepositoryException
      */
-    public void testRestoreOrder2Jcr2_2() throws RepositoryException {
+    public void testRestoreOrder2Jcr2_2() throws RepositoryException,
+            NotExecutableException {
         // create a test-root that has orderable child nodes
         Node testRoot = versionableNode.addNode(nodeName4, "nt:unstructured");
-        testRoot.addMixin(mixVersionable);
+        ensureMixinType(testRoot, mixVersionable);
         versionableNode.getSession().save();
 
         // create children of vNode and checkin
         Node child1 = testRoot.addNode(nodeName1);
-        if (!child1.isNodeType(mixVersionable)) {
-            child1.addMixin(mixVersionable);
-        }
+        ensureMixinType(child1, mixVersionable);
         Node child2 = testRoot.addNode(nodeName2);
-        if (!child2.isNodeType(mixVersionable)) {
-            child2.addMixin(mixVersionable);
-        }
+        ensureMixinType(child2, mixVersionable);
         testRoot.getSession().save();
         versionManager.checkin(child1.getPath());
         versionManager.checkin(child2.getPath());
@@ -1377,21 +1351,18 @@
      * Test the child ordering of restored nodes.
      * @throws RepositoryException
      */
-    public void testRestoreOrder2Jcr2_3() throws RepositoryException {
+    public void testRestoreOrder2Jcr2_3() throws RepositoryException,
+            NotExecutableException {
         // create a test-root that has orderable child nodes
         Node testRoot = versionableNode.addNode(nodeName4, "nt:unstructured");
-        testRoot.addMixin(mixVersionable);
+        ensureMixinType(testRoot, mixVersionable);
         versionableNode.getSession().save();
 
         // create children of vNode and checkin
         Node child1 = testRoot.addNode(nodeName1);
-        if (!child1.isNodeType(mixVersionable)) {
-            child1.addMixin(mixVersionable);
-        }
+        ensureMixinType(child1, mixVersionable);
         Node child2 = testRoot.addNode(nodeName2);
-        if (!child2.isNodeType(mixVersionable)) {
-            child2.addMixin(mixVersionable);
-        }
+        ensureMixinType(child2, mixVersionable);
         testRoot.getSession().save();
         versionManager.checkin(child1.getPath());
         versionManager.checkin(child2.getPath());
@@ -1421,21 +1392,18 @@
      * Test the child ordering of restored nodes.
      * @throws RepositoryException
      */
-    public void testRestoreOrder2Jcr2_4() throws RepositoryException {
+    public void testRestoreOrder2Jcr2_4() throws RepositoryException,
+            NotExecutableException {
         // create a test-root that has orderable child nodes
         Node testRoot = versionableNode.addNode(nodeName4, "nt:unstructured");
-        testRoot.addMixin(mixVersionable);
+        ensureMixinType(testRoot, mixVersionable);
         versionableNode.getSession().save();
 
         // create children of vNode and checkin
         Node child1 = testRoot.addNode(nodeName1);
-        if (!child1.isNodeType(mixVersionable)) {
-            child1.addMixin(mixVersionable);
-        }
+        ensureMixinType(child1, mixVersionable);
         Node child2 = testRoot.addNode(nodeName2);
-        if (!child2.isNodeType(mixVersionable)) {
-            child2.addMixin(mixVersionable);
-        }
+        ensureMixinType(child2, mixVersionable);
         testRoot.getSession().save();
         versionManager.checkin(child1.getPath());
         versionManager.checkin(child2.getPath());

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/AbstractVersionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/AbstractVersionTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/AbstractVersionTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/AbstractVersionTest.java Wed Jul  1 11:07:13 2009
@@ -24,6 +24,7 @@
 import javax.jcr.version.VersionHistory;
 
 import org.apache.jackrabbit.test.AbstractJCRTest;
+import org.apache.jackrabbit.test.NotExecutableException;
 
 /**
  * <code>AbstractVersionTest</code> is the abstract base class for all
@@ -132,11 +133,10 @@
      * @return versionable node.
      * @throws RepositoryException
      */
-    protected Node createVersionableNode(Node parent, String name, NodeType nodetype) throws RepositoryException {
+    protected Node createVersionableNode(Node parent, String name, NodeType nodetype)
+            throws RepositoryException, NotExecutableException {
         Node versionableNode = parent.addNode(name, nodetype.getName());
-        if (!nodetype.isNodeType(mixSimpleVersionable)) {
-            versionableNode.addMixin(mixSimpleVersionable);
-        }
+        ensureMixinType(versionableNode, mixSimpleVersionable);
         parent.getSession().save();
 
         return versionableNode;

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/FrozenNodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/FrozenNodeTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/FrozenNodeTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/FrozenNodeTest.java Wed Jul  1 11:07:13 2009
@@ -21,6 +21,8 @@
 import javax.jcr.version.Version;
 import javax.jcr.version.VersionManager;
 
+import org.apache.jackrabbit.test.NotExecutableException;
+
 /**
  * <code>SVFrozenNodeTest</code> covers tests related to frozen nodes in
  * simple versioning
@@ -71,9 +73,10 @@
     /**
      * @throws RepositoryException
      */
-    public void testFrozenUUUID() throws RepositoryException {
+    public void testFrozenUUUID() throws RepositoryException,
+            NotExecutableException {
         // make versionable node referenceable
-        versionableNode.addMixin(mixReferenceable);
+        ensureMixinType(versionableNode, mixReferenceable);
         versionableNode.getSession().save();
         VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
         String path = versionableNode.getPath();
@@ -87,9 +90,10 @@
     /**
      * @throws RepositoryException
      */
-    public void testFrozenChildUUUID() throws RepositoryException {
+    public void testFrozenChildUUUID() throws RepositoryException,
+            NotExecutableException {
         Node n1 = versionableNode.addNode("child");
-        n1.addMixin(mixReferenceable);
+        ensureMixinType(n1, mixReferenceable);
         versionableNode.getSession().save();
         VersionManager versionManager = versionableNode.getSession().getWorkspace().getVersionManager();
         String path = versionableNode.getPath();

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/RestoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/RestoreTest.java?rev=790118&r1=790117&r2=790118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/RestoreTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/version/simple/RestoreTest.java Wed Jul  1 11:07:13 2009
@@ -888,12 +888,11 @@
      * Test the restore of the OPV=Version child nodes.
      * @throws RepositoryException
      */
-    public void testRestoreName() throws RepositoryException {
+    public void testRestoreName() throws RepositoryException,
+            NotExecutableException {
         // V1.0 of versionableNode has no child
         Node child1 = versionableNode.addNode(nodeName4);
-        if (!child1.isNodeType(mixVersionable)) {
-            child1.addMixin(mixVersionable);
-        }
+        ensureMixinType(child1, mixVersionable);
         versionableNode.getSession().save();
         // create v1.0 of child
         Version v1Child = child1.checkin();
@@ -929,12 +928,11 @@
      * Test the restore of the OPV=Version child nodes.
      * @throws RepositoryException
      */
-    public void testRestoreNameJcr2() throws RepositoryException {
+    public void testRestoreNameJcr2() throws RepositoryException,
+            NotExecutableException {
         // V1.0 of versionableNode has no child
         Node child1 = versionableNode.addNode(nodeName4);
-        if (!child1.isNodeType(mixVersionable)) {
-            child1.addMixin(mixVersionable);
-        }
+        ensureMixinType(child1, mixVersionable);
         versionableNode.getSession().save();
         // create v1.0 of child
         Version v1Child = child1.checkin();
@@ -970,21 +968,18 @@
      * Test the child ordering of restored nodes.
      * @throws RepositoryException
      */
-    public void testRestoreOrder() throws RepositoryException {
+    public void testRestoreOrder() throws RepositoryException,
+            NotExecutableException {
         // create a test-root that has orderable child nodes
         Node testRoot = versionableNode.addNode(nodeName4, "nt:unstructured");
-        testRoot.addMixin(mixVersionable);
+        ensureMixinType(testRoot, mixVersionable);
         versionableNode.getSession().save();
 
         // create children of vNode and checkin
         Node child1 = testRoot.addNode(nodeName1);
-        if (!child1.isNodeType(mixVersionable)) {
-            child1.addMixin(mixVersionable);
-        }
+        ensureMixinType(child1, mixVersionable);
         Node child2 = testRoot.addNode(nodeName2);
-        if (!child2.isNodeType(mixVersionable)) {
-            child2.addMixin(mixVersionable);
-        }
+        ensureMixinType(child2, mixVersionable);
         testRoot.getSession().save();
         child1.checkin();
         child2.checkin();
@@ -1014,21 +1009,18 @@
      * Test the child ordering of restored nodes.
      * @throws RepositoryException
      */
-    public void testRestoreOrderJcr2() throws RepositoryException {
+    public void testRestoreOrderJcr2() throws RepositoryException,
+            NotExecutableException {
         // create a test-root that has orderable child nodes
         Node testRoot = versionableNode.addNode(nodeName4, "nt:unstructured");
-        testRoot.addMixin(mixVersionable);
+        ensureMixinType(testRoot, mixVersionable);
         versionableNode.getSession().save();
 
         // create children of vNode and checkin
         Node child1 = testRoot.addNode(nodeName1);
-        if (!child1.isNodeType(mixVersionable)) {
-            child1.addMixin(mixVersionable);
-        }
+        ensureMixinType(child1, mixVersionable);
         Node child2 = testRoot.addNode(nodeName2);
-        if (!child2.isNodeType(mixVersionable)) {
-            child2.addMixin(mixVersionable);
-        }
+        ensureMixinType(child2, mixVersionable);
         testRoot.getSession().save();
         versionManager.checkin(child1.getPath());
         versionManager.checkin(child2.getPath());
@@ -1058,21 +1050,18 @@
      * Test the child ordering of restored nodes.
      * @throws RepositoryException
      */
-    public void testRestoreOrderJcr2_2() throws RepositoryException {
+    public void testRestoreOrderJcr2_2() throws RepositoryException,
+            NotExecutableException {
         // create a test-root that has orderable child nodes
         Node testRoot = versionableNode.addNode(nodeName4, "nt:unstructured");
-        testRoot.addMixin(mixVersionable);
+        ensureMixinType(testRoot, mixVersionable);
         versionableNode.getSession().save();
 
         // create children of vNode and checkin
         Node child1 = testRoot.addNode(nodeName1);
-        if (!child1.isNodeType(mixVersionable)) {
-            child1.addMixin(mixVersionable);
-        }
+        ensureMixinType(child1, mixVersionable);
         Node child2 = testRoot.addNode(nodeName2);
-        if (!child2.isNodeType(mixVersionable)) {
-            child2.addMixin(mixVersionable);
-        }
+        ensureMixinType(child2, mixVersionable);
         testRoot.getSession().save();
         versionManager.checkin(child1.getPath());
         versionManager.checkin(child2.getPath());
@@ -1102,21 +1091,18 @@
      * Test the child ordering of restored nodes.
      * @throws RepositoryException
      */
-    public void testRestoreOrderJcr2_3() throws RepositoryException {
+    public void testRestoreOrderJcr2_3() throws RepositoryException,
+            NotExecutableException {
         // create a test-root that has orderable child nodes
         Node testRoot = versionableNode.addNode(nodeName4, "nt:unstructured");
-        testRoot.addMixin(mixVersionable);
+        ensureMixinType(testRoot, mixVersionable);
         versionableNode.getSession().save();
 
         // create children of vNode and checkin
         Node child1 = testRoot.addNode(nodeName1);
-        if (!child1.isNodeType(mixVersionable)) {
-            child1.addMixin(mixVersionable);
-        }
+        ensureMixinType(child1, mixVersionable);
         Node child2 = testRoot.addNode(nodeName2);
-        if (!child2.isNodeType(mixVersionable)) {
-            child2.addMixin(mixVersionable);
-        }
+        ensureMixinType(child2, mixVersionable);
         testRoot.getSession().save();
         versionManager.checkin(child1.getPath());
         versionManager.checkin(child2.getPath());
@@ -1146,21 +1132,18 @@
      * Test the child ordering of restored nodes.
      * @throws RepositoryException
      */
-    public void testRestoreOrderJcr2_4() throws RepositoryException {
+    public void testRestoreOrderJcr2_4() throws RepositoryException,
+            NotExecutableException {
         // create a test-root that has orderable child nodes
         Node testRoot = versionableNode.addNode(nodeName4, "nt:unstructured");
-        testRoot.addMixin(mixVersionable);
+        ensureMixinType(testRoot, mixVersionable);
         versionableNode.getSession().save();
 
         // create children of vNode and checkin
         Node child1 = testRoot.addNode(nodeName1);
-        if (!child1.isNodeType(mixVersionable)) {
-            child1.addMixin(mixVersionable);
-        }
+        ensureMixinType(child1, mixVersionable);
         Node child2 = testRoot.addNode(nodeName2);
-        if (!child2.isNodeType(mixVersionable)) {
-            child2.addMixin(mixVersionable);
-        }
+        ensureMixinType(child2, mixVersionable);
         testRoot.getSession().save();
         versionManager.checkin(child1.getPath());
         versionManager.checkin(child2.getPath());
@@ -1190,21 +1173,18 @@
      * Test the child ordering of restored nodes.
      * @throws RepositoryException
      */
-    public void testRestoreOrder2() throws RepositoryException {
+    public void testRestoreOrder2() throws RepositoryException,
+            NotExecutableException {
         // create a test-root that has orderable child nodes
         Node testRoot = versionableNode.addNode(nodeName4, "nt:unstructured");
-        testRoot.addMixin(mixVersionable);
+        ensureMixinType(testRoot, mixVersionable);
         versionableNode.getSession().save();
 
         // create children of vNode and checkin
         Node child1 = testRoot.addNode(nodeName1);
-        if (!child1.isNodeType(mixVersionable)) {
-            child1.addMixin(mixVersionable);
-        }
+        ensureMixinType(child1, mixVersionable);
         Node child2 = testRoot.addNode(nodeName2);
-        if (!child2.isNodeType(mixVersionable)) {
-            child2.addMixin(mixVersionable);
-        }
+        ensureMixinType(child2, mixVersionable);
         testRoot.getSession().save();
         child1.checkin();
         child2.checkin();
@@ -1234,21 +1214,18 @@
      * Test the child ordering of restored nodes.
      * @throws RepositoryException
      */
-    public void testRestoreOrder2Jcr2() throws RepositoryException {
+    public void testRestoreOrder2Jcr2() throws RepositoryException,
+            NotExecutableException {
         // create a test-root that has orderable child nodes
         Node testRoot = versionableNode.addNode(nodeName4, "nt:unstructured");
-        testRoot.addMixin(mixVersionable);
+        ensureMixinType(testRoot, mixVersionable);
         versionableNode.getSession().save();
 
         // create children of vNode and checkin
         Node child1 = testRoot.addNode(nodeName1);
-        if (!child1.isNodeType(mixVersionable)) {
-            child1.addMixin(mixVersionable);
-        }
+        ensureMixinType(child1, mixVersionable);
         Node child2 = testRoot.addNode(nodeName2);
-        if (!child2.isNodeType(mixVersionable)) {
-            child2.addMixin(mixVersionable);
-        }
+        ensureMixinType(child2, mixVersionable);
         testRoot.getSession().save();
         versionManager.checkin(child1.getPath());
         versionManager.checkin(child2.getPath());
@@ -1278,21 +1255,18 @@
      * Test the child ordering of restored nodes.
      * @throws RepositoryException
      */
-    public void testRestoreOrder2Jcr2_2() throws RepositoryException {
+    public void testRestoreOrder2Jcr2_2() throws RepositoryException,
+            NotExecutableException {
         // create a test-root that has orderable child nodes
         Node testRoot = versionableNode.addNode(nodeName4, "nt:unstructured");
-        testRoot.addMixin(mixVersionable);
+        ensureMixinType(testRoot, mixVersionable);
         versionableNode.getSession().save();
 
         // create children of vNode and checkin
         Node child1 = testRoot.addNode(nodeName1);
-        if (!child1.isNodeType(mixVersionable)) {
-            child1.addMixin(mixVersionable);
-        }
+        ensureMixinType(child1, mixVersionable);
         Node child2 = testRoot.addNode(nodeName2);
-        if (!child2.isNodeType(mixVersionable)) {
-            child2.addMixin(mixVersionable);
-        }
+        ensureMixinType(child2, mixVersionable);
         testRoot.getSession().save();
         versionManager.checkin(child1.getPath());
         versionManager.checkin(child2.getPath());
@@ -1322,21 +1296,18 @@
      * Test the child ordering of restored nodes.
      * @throws RepositoryException
      */
-    public void testRestoreOrder2Jcr2_3() throws RepositoryException {
+    public void testRestoreOrder2Jcr2_3() throws RepositoryException,
+            NotExecutableException {
         // create a test-root that has orderable child nodes
         Node testRoot = versionableNode.addNode(nodeName4, "nt:unstructured");
-        testRoot.addMixin(mixVersionable);
+        ensureMixinType(testRoot, mixVersionable);
         versionableNode.getSession().save();
 
         // create children of vNode and checkin
         Node child1 = testRoot.addNode(nodeName1);
-        if (!child1.isNodeType(mixVersionable)) {
-            child1.addMixin(mixVersionable);
-        }
+        ensureMixinType(child1, mixVersionable);
         Node child2 = testRoot.addNode(nodeName2);
-        if (!child2.isNodeType(mixVersionable)) {
-            child2.addMixin(mixVersionable);
-        }
+        ensureMixinType(child2, mixVersionable);
         testRoot.getSession().save();
         versionManager.checkin(child1.getPath());
         versionManager.checkin(child2.getPath());
@@ -1366,21 +1337,18 @@
      * Test the child ordering of restored nodes.
      * @throws RepositoryException
      */
-    public void testRestoreOrder2Jcr2_4() throws RepositoryException {
+    public void testRestoreOrder2Jcr2_4() throws RepositoryException,
+            NotExecutableException {
         // create a test-root that has orderable child nodes
         Node testRoot = versionableNode.addNode(nodeName4, "nt:unstructured");
-        testRoot.addMixin(mixVersionable);
+        ensureMixinType(testRoot, mixVersionable);
         versionableNode.getSession().save();
 
         // create children of vNode and checkin
         Node child1 = testRoot.addNode(nodeName1);
-        if (!child1.isNodeType(mixVersionable)) {
-            child1.addMixin(mixVersionable);
-        }
+        ensureMixinType(child1, mixVersionable);
         Node child2 = testRoot.addNode(nodeName2);
-        if (!child2.isNodeType(mixVersionable)) {
-            child2.addMixin(mixVersionable);
-        }
+        ensureMixinType(child2, mixVersionable);
         testRoot.getSession().save();
         versionManager.checkin(child1.getPath());
         versionManager.checkin(child2.getPath());



Mime
View raw message