jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1486864 - in /jackrabbit/trunk: jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/ jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/ jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/
Date Tue, 28 May 2013 11:05:39 GMT
Author: jukka
Date: Tue May 28 11:05:39 2013
New Revision: 1486864

URL: http://svn.apache.org/r1486864
Log:
JCR-3601: AbstractJCRTest.cleanUpTestRoot() does not properly set testNodeType

Always use an unstructured type for the test root.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/JackrabbitRepositoryStub.properties
    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/RepositoryStub.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/SaveTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/JackrabbitRepositoryStub.properties
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/JackrabbitRepositoryStub.properties?rev=1486864&r1=1486863&r2=1486864&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/JackrabbitRepositoryStub.properties
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/JackrabbitRepositoryStub.properties
Tue May 28 11:05:39 2013
@@ -24,6 +24,7 @@ javax.jcr.tck.readonly.pwd=
 # global test configuration
 javax.jcr.tck.testroot=/testroot
 javax.jcr.tck.nodetype=nt:unstructured
+javax.jcr.tck.nodetypetestroot=nt:unstructured
 javax.jcr.tck.nodetypenochildren=nt:address
 javax.jcr.tck.nodename1=node1
 javax.jcr.tck.nodename2=node2
@@ -356,11 +357,6 @@ javax.jcr.tck.NodeTypeCreationTest.testr
 # JAVAX.JCR.QUERY CONFIGURATION
 # ==============================================================================
 
-# Test class: SaveTest
-# Test method: testConstraintViolationException
-# Specified node type must not allow child nodes.
-javax.jcr.tck.SaveTest.testConstraintViolationException.nodetype=nt:query
-
 # Test class: XPathQueryLevel1Test
 javax.jcr.tck.XPathQueryLevel1Test.testroot=/testdata/query
 

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=1486864&r1=1486863&r2=1486864&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
Tue May 28 11:05:39 2013
@@ -36,7 +36,6 @@ import javax.jcr.nodetype.ConstraintViol
 import javax.jcr.nodetype.NodeType;
 import javax.jcr.nodetype.PropertyDefinition;
 import javax.jcr.retention.RetentionManager;
-import javax.jcr.retention.RetentionPolicy;
 
 import java.util.StringTokenizer;
 import java.util.Random;
@@ -239,6 +238,11 @@ public abstract class AbstractJCRTest ex
     protected String testNodeType;
 
     /**
+     * The node type name for the test root node.
+     */
+    protected String testNodeTypeTestRoot;
+
+    /**
      * A node type that does not allow any child nodes, such as nt:base.
      */
     protected String testNodeTypeNoChildren;
@@ -309,6 +313,10 @@ public abstract class AbstractJCRTest ex
         // cut off '/' to build testPath
         testPath = testRoot.substring(1);
         testNodeType = getProperty(RepositoryStub.PROP_NODETYPE);
+        testNodeTypeTestRoot = getProperty(RepositoryStub.PROP_NODETYPETESTROOT);
+        if (testNodeTypeTestRoot == null) {
+            testNodeTypeTestRoot = testNodeType; // backwards compatibility
+        }
         testNodeTypeNoChildren = getProperty(RepositoryStub.PROP_NODETYPENOCHILDREN);
         // setup node names
         nodeName1 = getProperty(RepositoryStub.PROP_NODE_NAME1);
@@ -840,29 +848,28 @@ public abstract class AbstractJCRTest ex
         s.refresh(false);
         Node root = s.getRootNode();
         Node testRootNode;
-        
-        RetentionManager rm;
-        try {
-            rm = s.getRetentionManager();
-        } catch (UnsupportedRepositoryOperationException ex) {
-            rm = null;
-        }
-        
+
         if (root.hasNode(testPath)) {
+            RetentionManager rm;
+            try {
+                rm = s.getRetentionManager();
+            } catch (UnsupportedRepositoryOperationException e) {
+                rm = null;
+            }
+
             // clean test root
             testRootNode = root.getNode(testPath);
-            for (NodeIterator children = testRootNode.getNodes(); children.hasNext();) {
+            NodeIterator children = testRootNode.getNodes();
+            while (children.hasNext()) {
                 Node child = children.nextNode();
 
                 // Remove retention policy if needed
-                if (rm != null) {
-                    RetentionPolicy pol = rm.getRetentionPolicy(child.getPath());
-                    if (pol != null) {
-                        rm.removeRetentionPolicy(child.getPath());
-                        s.save();
-                    }
+                String childPath = child.getPath();
+                if (rm != null && rm.getRetentionPolicy(childPath) != null) {
+                    rm.removeRetentionPolicy(childPath);
+                    s.save();
                 }
-                
+
                 NodeDefinition nodeDef = child.getDefinition();
                 if (!nodeDef.isMandatory() && !nodeDef.isProtected()) {
                     // try to remove child
@@ -882,7 +889,7 @@ public abstract class AbstractJCRTest ex
                 if (currentNode.hasNode(name)) {
                     currentNode = currentNode.getNode(name);
                 } else {
-                    currentNode = currentNode.addNode(name, testNodeType);
+                    currentNode = currentNode.addNode(name, testNodeTypeTestRoot);
                 }
             }
             testRootNode = currentNode;

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryStub.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryStub.java?rev=1486864&r1=1486863&r2=1486864&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryStub.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryStub.java
Tue May 28 11:05:39 2013
@@ -62,6 +62,8 @@ public abstract class RepositoryStub {
 
     public static final String PROP_NODETYPE = "nodetype";
 
+    public static final String PROP_NODETYPETESTROOT = "nodetypetestroot";
+
     public static final String PROP_NODETYPENOCHILDREN = "nodetypenochildren";
 
     public static final String PROP_TESTROOT = "testroot";

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=1486864&r1=1486863&r2=1486864&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
Tue May 28 11:05:39 2013
@@ -157,7 +157,7 @@ public class SaveTest extends AbstractJC
     public void testConstraintViolationException() throws RepositoryException, NotExecutableException
{
         checkNtQuery();
         Query query = superuser.getWorkspace().getQueryManager().createQuery(statement, Query.XPATH);
-        testRootNode.addNode(nodeName1, testNodeType);
+        testRootNode.addNode(nodeName1, testNodeTypeNoChildren);
         try {
             query.storeAsNode(testRoot + "/" + nodeName1 + "/" + nodeName2);
             superuser.save();



Mime
View raw message