jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r572636 - in /jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test: AbstractJCRTest.java api/lock/SetValueLockExceptionTest.java
Date Tue, 04 Sep 2007 11:54:57 GMT
Author: reschke
Date: Tue Sep  4 04:54:57 2007
New Revision: 572636

URL: http://svn.apache.org/viewvc?rev=572636&view=rev
Log:
JCR-817: Extend ensureCanSetProperty so it can used property type / multiple flag. Use it
in SetValueLockExceptionTest.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/lock/SetValueLockExceptionTest.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=572636&r1=572635&r2=572636&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 Sep  4 04:54:57 2007
@@ -544,12 +544,13 @@
     }
 
 
-    private boolean canSetProperty(NodeType nodeType, String propertyName, int propertyType)
{
+    private boolean canSetProperty(NodeType nodeType, String propertyName, int propertyType,
boolean isMultiple) {
         PropertyDefinition propDefs[] = nodeType.getPropertyDefinitions();
 
         for (int i = 0; i < propDefs.length; i++) {
             if (propDefs[i].getName().equals(propertyName) || propDefs[i].getName().equals("*"))
{
-                if (propDefs[i].getRequiredType() == propertyType || propDefs[i].getRequiredType()
== PropertyType.UNDEFINED) {
+                if ((propDefs[i].getRequiredType() == propertyType || propDefs[i].getRequiredType()
== PropertyType.UNDEFINED)
+                    && propDefs[i].isMultiple() == isMultiple) {
                     return true;
                 }
             }
@@ -558,16 +559,16 @@
         return false;
     }
 
-    private boolean canSetProperty(Node node, String propertyName, int propertyType) throws
RepositoryException {
+    private boolean canSetProperty(Node node, String propertyName, int propertyType, boolean
isMultiple) throws RepositoryException {
 
-        if (canSetProperty(node.getPrimaryNodeType(), propertyName, propertyType)) {
+        if (canSetProperty(node.getPrimaryNodeType(), propertyName, propertyType, isMultiple))
{
             return true;
         }
         else {
             NodeType mixins[] = node.getMixinNodeTypes();
             boolean canSetIt = false;
             for (int i = 0; i < mixins.length && !canSetIt; i++) {
-                canSetIt |= canSetProperty(mixins[i], propertyName, propertyType);
+                canSetIt |= canSetProperty(mixins[i], propertyName, propertyType, isMultiple);
             }
             return canSetIt;
         }
@@ -579,9 +580,9 @@
      * @throws NotExecutableException when setting the property to the required
      * type is not supported
      */
-    protected void ensureCanSetProperty(Node node, String propertyName, Value value) throws
NotExecutableException, RepositoryException {
+    protected void ensureCanSetProperty(Node node, String propertyName, int propertyType,
boolean isMultiple) throws NotExecutableException, RepositoryException {
 
-        if (! canSetProperty(node, propertyName, value.getType())) {
+        if (! canSetProperty(node, propertyName, propertyType, isMultiple)) {
             throw new NotExecutableException("configured property name " + propertyName +
" can not be set on node " + node.getPath());
         }
     }
@@ -592,11 +593,21 @@
      * @throws NotExecutableException when setting the property to the required
      * type is not supported
      */
+    protected void ensureCanSetProperty(Node node, String propertyName, Value value) throws
NotExecutableException, RepositoryException {
+        ensureCanSetProperty(node, propertyName, value.getType(), false);
+    }
+
+    /**
+     * 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[] values) throws
NotExecutableException, RepositoryException {
       
         int propertyType = values.length == 0 ? PropertyType.UNDEFINED : values[0].getType();
         
-        if (! canSetProperty(node, propertyName, propertyType)) {
+        if (! canSetProperty(node, propertyName, propertyType, true)) {
             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/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=572636&r1=572635&r2=572636&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
Tue Sep  4 04:54:57 2007
@@ -98,15 +98,23 @@
             binaryValue = createRandomString(10).getBytes();
 
             ByteArrayInputStream in = new ByteArrayInputStream(binaryValue);
+            ensureCanSetProperty(testNode, binaryProp, PropertyType.BINARY, false);
             testNode.setProperty(binaryProp, in);
+            ensureCanSetProperty(testNode, booleanProp, PropertyType.BOOLEAN, false);
             testNode.setProperty(booleanProp, booleanValue);
+            ensureCanSetProperty(testNode, dateProp, PropertyType.DATE, false);
             testNode.setProperty(dateProp, dateValue);
+            ensureCanSetProperty(testNode, doubleProp, PropertyType.DOUBLE, false);
             testNode.setProperty(doubleProp, doubleValue);
+            ensureCanSetProperty(testNode, longProp, PropertyType.LONG, false);
             testNode.setProperty(longProp, longValue);
             if (referenceNode != null) {
+                ensureCanSetProperty(testNode, referenceProp, PropertyType.REFERENCE, false);
                 testNode.setProperty(referenceProp, referenceNode);
             }
+            ensureCanSetProperty(testNode, stringProp, PropertyType.STRING, false);
             testNode.setProperty(stringProp, stringValue);
+            ensureCanSetProperty(testNode, multiStringProp, PropertyType.STRING, true);
             testNode.setProperty(multiStringProp, multiString);
             testRootNode.save();
         }
@@ -223,7 +231,6 @@
      * Create a referenceable node under the testRootNode
      * or null if it is not possible to create one.
      * @param name
-     * @return
      * @throws RepositoryException
      */
     public Node createReferenceableNode(String name) throws RepositoryException {



Mime
View raw message