jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r160691 - in incubator/jackrabbit/trunk/src: java/org/apache/jackrabbit/core/ java/org/apache/jackrabbit/core/nodetype/ test/org/apache/jackrabbit/test/api/
Date Sat, 09 Apr 2005 16:30:51 GMT
Author: stefan
Date: Sat Apr  9 09:30:47 2005
New Revision: 160691

URL: http://svn.apache.org/viewcvs?view=rev&rev=160691
Log:
fixed incorrect test cases and fixed code that caused valid testcases to fail

Modified:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/AbstractWorkspaceCopyBetweenTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyStringTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyValueTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCloneReferenceableTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCloneSameNameSibsTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveTest.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java?view=diff&r1=160690&r2=160691
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java Sat Apr 
9 09:30:47 2005
@@ -2476,15 +2476,19 @@
         }
 
         // check lock status
-        checkLock();
+        if (isLocked()) {
+            return false;
+        }
 
         QName ntName;
         try {
             ntName = QName.fromJCRName(mixinName, session.getNamespaceResolver());
         } catch (IllegalNameException ine) {
-            throw new RepositoryException("invalid mixin type name: " + mixinName, ine);
+            throw new RepositoryException("invalid mixin type name: "
+                    + mixinName, ine);
         } catch (UnknownPrefixException upe) {
-            throw new RepositoryException("invalid mixin type name: " + mixinName, upe);
+            throw new RepositoryException("invalid mixin type name: "
+                    + mixinName, upe);
         }
 
         NodeTypeManagerImpl ntMgr = session.getNodeTypeManager();
@@ -2496,7 +2500,8 @@
             return false;
         }
 
-        // build effective node type of mixins & primary type in order to detect conflicts
+        // build effective node type of mixins & primary type
+        // in order to detect conflicts
         NodeTypeRegistry ntReg = ntMgr.getNodeTypeRegistry();
         EffectiveNodeType entExisting;
         try {

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyImpl.java?view=diff&r1=160690&r2=160691
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyImpl.java Sat Apr
 9 09:30:47 2005
@@ -1053,6 +1053,25 @@
         // check lock status
         ((NodeImpl) getParent()).checkLock();
 
+        if (values != null) {
+            // check type of values
+            int valueType = PropertyType.UNDEFINED;
+            for (int i = 0; i < values.length; i++) {
+                if (values[i] == null) {
+                    // skip null values as those will be purged later
+                    continue;
+                }
+                if (valueType == PropertyType.UNDEFINED) {
+                    valueType = values[i].getType();
+                } else if (valueType != values[i].getType()) {
+                    // inhomogeneous types
+                    String msg = "inhomogeneous type of values";
+                    log.debug(msg);
+                    throw new ValueFormatException(msg);
+                }
+            }
+        }
+
         int reqType = definition.getRequiredType();
 
         InternalValue[] internalValues = null;

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java?view=diff&r1=160690&r2=160691
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java
(original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeImpl.java
Sat Apr  9 09:30:47 2005
@@ -481,6 +481,10 @@
             // determine type of values
             int type = PropertyType.UNDEFINED;
             for (int i = 0; i < values.length; i++) {
+                if (values[i] == null) {
+                    // skip null values as those would be purged
+                    continue;
+                }
                 if (type == PropertyType.UNDEFINED) {
                     type = values[i].getType();
                 } else if (type != values[i].getType()) {

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/AbstractWorkspaceCopyBetweenTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/AbstractWorkspaceCopyBetweenTest.java?view=diff&r1=160690&r2=160691
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/AbstractWorkspaceCopyBetweenTest.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/AbstractWorkspaceCopyBetweenTest.java
Sat Apr  9 09:30:47 2005
@@ -35,6 +35,11 @@
     protected Session superuserW2;
 
     /**
+     * A read-write session for the non default workspace
+     */
+    protected Session rwSessionW2;
+
+    /**
      * The workspace in the non default session.
      */
     Workspace workspaceW2;
@@ -59,6 +64,7 @@
 
         // init second workspace
         superuserW2 = helper.getSuperuserSession(workspaceName);
+        rwSessionW2 = helper.getReadWriteSession(workspaceName);
         workspaceW2 = superuserW2.getWorkspace();
 
         initNodesW2();

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyStringTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyStringTest.java?view=diff&r1=160690&r2=160691
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyStringTest.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyStringTest.java
Sat Apr  9 09:30:47 2005
@@ -210,10 +210,16 @@
 
     /**
      * Tests if <code>Node.setProperty(String, String[])</code> throws a {@link
-     * javax.jcr.ValueFormatException} when trying to set a single-value
-     * property to a multi-value
+     * javax.jcr.ValueFormatException} when trying to set an existing
+     * single-valued property to a multi-value
      */
     public void testSetSingleStringArrayValueFormatException() throws Exception {
+        // prerequisite: existing single-valued STRING property
+        if (!testNode.hasProperty(propertyName1)) {
+            testNode.setProperty(propertyName1, s1);
+            testNode.getParent().save();
+        }
+
         try {
             testNode.setProperty(propertyName1, sArray1);
             fail("setProperty(singleValueProperty, String[]) not throwing a ValueFormatException");
@@ -315,10 +321,16 @@
 
     /**
      * Tests if <code>Node.setProperty(String, String[], int)</code> throws a
-     * {@link javax.jcr.ValueFormatException} when trying to set a single-value
-     * property to a multi-value
+     * {@link javax.jcr.ValueFormatException} when trying to set an existing
+     * single-value property to a multi-value
      */
     public void testSetSingleStringArrayValueFormatExceptionWithPropertyType() throws Exception
{
+        // prerequisite: existing single-valued STRING property
+        if (!testNode.hasProperty(propertyName1)) {
+            testNode.setProperty(propertyName1, s1);
+            testNode.getParent().save();
+        }
+
         try {
             testNode.setProperty(propertyName1, sArray1, PropertyType.STRING);
             fail("setProperty(singleValueProperty, String[], int) not throwing a ValueFormatException");

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyValueTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyValueTest.java?view=diff&r1=160690&r2=160691
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyValueTest.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyValueTest.java
Sat Apr  9 09:30:47 2005
@@ -223,10 +223,16 @@
 
     /**
      * Tests if <code>Node.setProperty(String, Value[])</code> throws a {@link
-     * javax.jcr.ValueFormatException} when trying to set a single-value
-     * property to a multi-value
+     * javax.jcr.ValueFormatException} when trying to set an existing
+     * single-valued property to a multi-value
      */
     public void testSetSingleValueArrayValueFormatException() throws Exception {
+        // prerequisite: existing single-valued property
+        if (!testNode.hasProperty(propertyName1)) {
+            testNode.setProperty(propertyName1, v1);
+            testNode.getParent().save();
+        }
+
         try {
             testNode.setProperty(propertyName1, vArray1);
             fail("setProperty(singleValueProperty, Value[]) not throwing a ValueFormatException");
@@ -357,10 +363,16 @@
 
     /**
      * Tests if <code>Node.setProperty(String, Value[], int)</code> throws a
-     * {@link javax.jcr.ValueFormatException} when trying to set a single-value
-     * property to a multi-value
+     * {@link javax.jcr.ValueFormatException} when trying to set an existing
+     * single-valued property to a multi-value
      */
     public void testSetSingleValueArrayValueFormatExceptionWithPropertyType() throws Exception
{
+        // prerequisite: existing single-valued property
+        if (!testNode.hasProperty(propertyName1)) {
+            testNode.setProperty(propertyName1, v1);
+            testNode.getParent().save();
+        }
+
         try {
             testNode.setProperty(propertyName1, vArray1, PropertyType.STRING);
             fail("setProperty(singleValueProperty, Value[], int) not throwing a ValueFormatException");

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCloneReferenceableTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCloneReferenceableTest.java?view=diff&r1=160690&r2=160691
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCloneReferenceableTest.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCloneReferenceableTest.java
Sat Apr  9 09:30:47 2005
@@ -18,6 +18,7 @@
 
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
+import javax.jcr.ItemExistsException;
 
 /**
  * <code>WorkspaceCloneReferenceableTest</code> contains tests for cloning
@@ -61,7 +62,7 @@
      */
     public void testCloneNodesRemoveExistingTrue() throws RepositoryException {
         // add mixin referenceable to node1
-        /*addMixinReferenceableToNode(testRootNode, node1);
+        addMixinReferenceableToNode(testRootNode, node1);
 
         // clone a node from default workspace to have the same uuid on second workspace
         String dstAbsPath = node2W2.getPath() + "/" + nodeName2;
@@ -70,7 +71,6 @@
 
         // clone node1 from default workspace to second workspace
         dstAbsPath = node2W2.getPath() + "/" + nodeName3;
-        //@TODO: Testcase corrupts workspace and functionality is not implemented right now,
so it's commented.
         workspaceW2.clone(workspace.getName(), node1.getPath(), dstAbsPath, true);
         Node clonedNode2 = node2W2.getNode(nodeName3);
 
@@ -80,8 +80,7 @@
 
         // ... and is copied to this workspace as part of the copied subtree (that is, not
into the former location of the old node).
         Node clonedNodeMoved = clonedNode2.getNode(clonedNode.getName());
-        assertTrue(testRootNodeW2.hasNode(clonedNodeMoved.getName()));*/
-        fail("Testcase corrupts workspace, so it's commented.");
+        assertTrue(testRootNodeW2.hasNode(clonedNodeMoved.getName()));
     }
 
     /**
@@ -90,21 +89,18 @@
      */
     public void testCloneNodesRemoveExistingFalse() throws RepositoryException {
         // add mixin referenceable to node1
-        /*addMixinReferenceableToNode(testRootNode, node1);
+        addMixinReferenceableToNode(testRootNode, node1);
 
         // clone a node from default workspace to have the same uuid on second workspace
         workspaceW2.clone(workspace.getName(), node1.getPath(), testRootNodeW2.getPath()
+ "/" + nodeName2, false);
 
         // clone node1 from default workspace to second workspace
         try {
-            //@TODO: Testcase corrupts workspace, so it's commented.
             workspaceW2.clone(workspace.getName(), node1.getPath(), testRootNodeW2.getPath()
+ "/" + nodeName3, false);
             fail("If removeExisting is false then a UUID collision should throw a ItemExistsException");
         } catch (ItemExistsException e) {
             // successful
-        } */
-
-        fail("Testcase corrupts workspace, so it's commented.");
+        }
     }
 
     /**

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCloneSameNameSibsTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCloneSameNameSibsTest.java?view=diff&r1=160690&r2=160691
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCloneSameNameSibsTest.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCloneSameNameSibsTest.java
Sat Apr  9 09:30:47 2005
@@ -19,6 +19,7 @@
 import javax.jcr.ItemExistsException;
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
+import javax.jcr.NodeIterator;
 
 /**
  * <code>WorkspaceCloneSameNameSibsTest</code> contains tests for cloning nodes
@@ -38,7 +39,7 @@
      */
     public void testCloneNodesOrderingSupportedByParent() throws RepositoryException {
         // test assumes that repositry supports Orderable Child Node Support (optional)
-        /*String[] orderList = {nodeName1, nodeName2, nodeName3};
+        String[] orderList = {nodeName1, nodeName2, nodeName3};
 
         // copy node three times below a node and check the order
         for (int i = 0; i < orderList.length; i++) {
@@ -54,9 +55,7 @@
 
             assertTrue(n.getName().equals(orderList[cnt]));
             cnt++;
-        } */
-        //@TODO: Testcase corrupts workspace, so it's commented.
-        fail("Testcase corrupts workspace, so it's commented.");
+        }
     }
 
     /**

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesTest.java?view=diff&r1=160690&r2=160691
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesTest.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyBetweenWorkspacesTest.java
Sat Apr  9 09:30:47 2005
@@ -160,20 +160,25 @@
         // we assume repository supports locking
         String dstAbsPath = node2W2.getPath() + "/" + node1.getName();
 
+        // get lock target node in destination wsp through other session
+        Node lockTarget = (Node) rwSessionW2.getItem(node2W2.getPath());
+
         // add mixin "lockable" to be able to lock the node
-        if (!node2W2.getPrimaryNodeType().isNodeType(mixLockable)) {
-            node2W2.addMixin(mixLockable);
-            testRootNodeW2.save();
+        if (!lockTarget.getPrimaryNodeType().isNodeType(mixLockable)) {
+            lockTarget.addMixin(mixLockable);
+            lockTarget.getParent().save();
         }
 
-        // lock dst parent node
-        node2W2.lock(true, true);
+        // lock dst parent node using other session
+        lockTarget.lock(true, true);
 
         try {
             workspaceW2.copy(workspace.getName(), node1.getPath(), dstAbsPath);
             fail("LockException was expected.");
         } catch (LockException e) {
             // successful
+        } finally {
+            lockTarget.unlock();
         }
     }
 

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyTest.java?view=diff&r1=160690&r2=160691
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyTest.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceCopyTest.java
Sat Apr  9 09:30:47 2005
@@ -138,20 +138,28 @@
         // we assume repository supports locking
         String dstAbsPath = node2.getPath() + "/" + node1.getName();
 
+        // get other session
+        Session otherSession = helper.getReadWriteSession();
+
+        // get lock target node in destination wsp through other session
+        Node lockTarget = (Node) otherSession.getItem(node2.getPath());
+
         // add mixin "lockable" to be able to lock the node
-        if (!node2.getPrimaryNodeType().isNodeType(mixLockable)) {
-            node2.addMixin(mixLockable);
-            testRootNode.save();
+        if (!lockTarget.getPrimaryNodeType().isNodeType(mixLockable)) {
+            lockTarget.addMixin(mixLockable);
+            lockTarget.getParent().save();
         }
 
-        // lock dst parent node
-        node2.lock(true, true);
+        // lock dst parent node using other session
+        lockTarget.lock(true, true);
 
         try {
             workspace.copy(node1.getPath(), dstAbsPath);
             fail("LockException was expected.");
         } catch (LockException e) {
             // successful
+        } finally {
+            lockTarget.unlock();
         }
     }
 }

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveTest.java?view=diff&r1=160690&r2=160691
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveTest.java
(original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/WorkspaceMoveTest.java
Sat Apr  9 09:30:47 2005
@@ -139,20 +139,28 @@
         // we assume repository supports locking
         String dstAbsPath = node2.getPath() + "/" + node1.getName();
 
+        // get other session
+        Session otherSession = helper.getReadWriteSession();
+
+        // get lock target node in destination wsp through other session
+        Node lockTarget = (Node) otherSession.getItem(node2.getPath());
+
         // add mixin "lockable" to be able to lock the node
-        if (!node2.getPrimaryNodeType().isNodeType(mixLockable)) {
-            node2.addMixin(mixLockable);
-            testRootNode.save();
+        if (!lockTarget.getPrimaryNodeType().isNodeType(mixLockable)) {
+            lockTarget.addMixin(mixLockable);
+            lockTarget.getParent().save();
         }
 
-        // lock dst parent node
-        node2.lock(true, true);
+        // lock dst parent node using other session
+        lockTarget.lock(true, true);
 
         try {
             workspace.move(node1.getPath(), dstAbsPath);
             fail("LockException was expected.");
         } catch (LockException e) {
             // successful
+        } finally {
+            lockTarget.unlock();
         }
     }
 }



Mime
View raw message