jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r522894 - in /jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test: AbstractJCRTest.java api/SetPropertyNodeTest.java
Date Tue, 27 Mar 2007 13:06:03 GMT
Author: reschke
Date: Tue Mar 27 06:06:02 2007
New Revision: 522894

URL: http://svn.apache.org/viewvc?view=rev&rev=522894
Log:
JCR-817: add convenience method for checking ability to set a property; use if in SetPropertyNodeTest.java

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/SetPropertyNodeTest.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?view=diff&rev=522894&r1=522893&r2=522894
==============================================================================
--- 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 Mar 27 06:06:02 2007
@@ -26,8 +26,11 @@
 import javax.jcr.Repository;
 import javax.jcr.NamespaceException;
 import javax.jcr.RangeIterator;
+import javax.jcr.Value;
 import javax.jcr.nodetype.NodeDefinition;
 import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NodeType;
+
 import java.util.StringTokenizer;
 import java.util.Random;
 import java.util.List;
@@ -529,6 +532,28 @@
         String workspacenames[] = superuser.getWorkspace().getAccessibleWorkspaceNames();
         if (workspacenames == null || workspacenames.length < 2) {
             throw new NotExecutableException("This repository does not seem to support multiple
workspaces.");
+        }
+    }
+    
+    /**
+     * Checks that the repository can set the property to the required type, otherwise aborts
with
+     * {@link NotExecutableException}.
+     * @throws NotExecutableException when setting the property to the required
+     * type is not supported
+     */
+    protected void ensureCanSetProperty(Node node, String propertyName, Value val) throws
NotExecutableException, RepositoryException {
+        
+        boolean canSetIt = node.getPrimaryNodeType().canSetProperty(propertyName, val);
+        if (! canSetIt) {
+            // check mixins
+            NodeType mixins[] = node.getMixinNodeTypes();
+            for (int i = 0; i < mixins.length && !canSetIt; i++) {
+                canSetIt |= mixins[i].canSetProperty(propertyName, val);
+            }
+        }
+      
+        if (! canSetIt) {
+            throw new NotExecutableException("configured property name " + propertyName +
" can not be set on node " + node.getPath());
         }
     }
     

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyNodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyNodeTest.java?view=diff&rev=522894&r1=522893&r2=522894
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyNodeTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SetPropertyNodeTest.java
Tue Mar 27 06:06:02 2007
@@ -52,6 +52,10 @@
         */
         testRootNode.save();
 
+        // abort test if the repository does not allow setting
+        // reference properties on this node
+        ensureCanSetProperty(testNode, propertyName1, testNode.getSession().getValueFactory().createValue(n1));
+
         if (!n1.isNodeType(mixReferenceable)) {
             throw new NotExecutableException("Node " + nodeName2 + " with nodetype " + testNodeType
+ " is not mix:referenceable.");
         }



Mime
View raw message