You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by "Brian Whipple (JIRA)" <ji...@apache.org> on 2008/10/13 21:18:44 UTC

[jira] Created: (JCR-1807) Removing peer nodes throws RepositoryException

Removing peer nodes throws RepositoryException
----------------------------------------------

                 Key: JCR-1807
                 URL: https://issues.apache.org/jira/browse/JCR-1807
             Project: Jackrabbit
          Issue Type: Bug
          Components: jackrabbit-core
    Affects Versions: core 1.4.6
            Reporter: Brian Whipple


The following UnitTest will reproduce the error.  Note that 3 peer nodes must be removed to produce the exception.  Additional testing shows that the paths are corrupted after the second remove.

Also note that Node.getPath (per the comment in the test) must be invoked to produce the path corruption.

This unit test is based on the jackrabbit-jcr-tests test framework. I will attach the java file too.  Here is the test:

package org.apache.jackrabbit.test.api;

import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.RepositoryException;
import org.apache.jackrabbit.test.AbstractJCRTest;

/**
 * <code>RemoveNodeTest</code> contains the test cases for the method
 * <code>Node.remove()</code>.
 *
 * @test
 * @sources RemoveNodeTest.java
 * @executeClass org.apache.jackrabbit.test.api.RemoveNodeTest
 * @keywords level2
 */
public class RemoveNodeTest extends AbstractJCRTest
{

    private static final String CHILD_NAME = "child";

    public void testAddThenRemovePeerNodes() throws Exception
    {
        // Must remove at least three peers so need to add three peer nodes
        long NUM_SIB_NODES = 3;
        for (long i = 0; i < NUM_SIB_NODES; i++)
        {
            testRootNode.addNode(CHILD_NAME);
        }

        // If this method is not invoked the test will pass
        // Getting the child node paths contributes to the error
        getPaths();

        // Remove all nodes
        removeNodes();

        testRootNode.save();

        // Validate that all nodes have been removed.
        long numChildren = testRootNode.getNodes(CHILD_NAME).getSize();
        assertEquals("Invalid number of child nodes", 0, numChildren);
    }

    private void getPaths() throws RepositoryException
    {
        NodeIterator childNodes = testRootNode.getNodes(CHILD_NAME);
        while (childNodes.hasNext())
        {
            Node child = childNodes.nextNode();
            child.getPath();
        }
    }

    private void removeNodes() throws RepositoryException
    {
        NodeIterator childNodes = testRootNode.getNodes(CHILD_NAME);
        while (childNodes.hasNext())
        {
            Node child = childNodes.nextNode();
            child.remove();
        }
    }
}


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (JCR-1807) Removing peer nodes throws RepositoryException

Posted by "Brian Whipple (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JCR-1807?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12661677#action_12661677 ] 

Brian Whipple commented on JCR-1807:
------------------------------------

I believe this problem is related to JCR-1880.

> Removing peer nodes throws RepositoryException
> ----------------------------------------------
>
>                 Key: JCR-1807
>                 URL: https://issues.apache.org/jira/browse/JCR-1807
>             Project: Jackrabbit
>          Issue Type: Bug
>          Components: jackrabbit-core
>    Affects Versions: core 1.4.6
>            Reporter: Brian Whipple
>         Attachments: RemoveNodeTest.java, TestAll.java
>
>
> The following UnitTest will reproduce the error.  Note that 3 peer nodes must be removed to produce the exception.  Additional testing shows that the paths are corrupted after the second remove.
> Also note that Node.getPath (per the comment in the test) must be invoked to produce the path corruption.
> This unit test is based on the jackrabbit-jcr-tests test framework. I will attach the java file too.  Here is the test:
> package org.apache.jackrabbit.test.api;
> import javax.jcr.Node;
> import javax.jcr.NodeIterator;
> import javax.jcr.RepositoryException;
> import org.apache.jackrabbit.test.AbstractJCRTest;
> /**
>  * <code>RemoveNodeTest</code> contains the test cases for the method
>  * <code>Node.remove()</code>.
>  *
>  * @test
>  * @sources RemoveNodeTest.java
>  * @executeClass org.apache.jackrabbit.test.api.RemoveNodeTest
>  * @keywords level2
>  */
> public class RemoveNodeTest extends AbstractJCRTest
> {
>     private static final String CHILD_NAME = "child";
>     public void testAddThenRemovePeerNodes() throws Exception
>     {
>         // Must remove at least three peers so need to add three peer nodes
>         long NUM_SIB_NODES = 3;
>         for (long i = 0; i < NUM_SIB_NODES; i++)
>         {
>             testRootNode.addNode(CHILD_NAME);
>         }
>         // If this method is not invoked the test will pass
>         // Getting the child node paths contributes to the error
>         getPaths();
>         // Remove all nodes
>         removeNodes();
>         testRootNode.save();
>         // Validate that all nodes have been removed.
>         long numChildren = testRootNode.getNodes(CHILD_NAME).getSize();
>         assertEquals("Invalid number of child nodes", 0, numChildren);
>     }
>     private void getPaths() throws RepositoryException
>     {
>         NodeIterator childNodes = testRootNode.getNodes(CHILD_NAME);
>         while (childNodes.hasNext())
>         {
>             Node child = childNodes.nextNode();
>             child.getPath();
>         }
>     }
>     private void removeNodes() throws RepositoryException
>     {
>         NodeIterator childNodes = testRootNode.getNodes(CHILD_NAME);
>         while (childNodes.hasNext())
>         {
>             Node child = childNodes.nextNode();
>             child.remove();
>         }
>     }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (JCR-1807) Removing peer nodes throws RepositoryException

Posted by "Brian Whipple (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JCR-1807?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Brian Whipple updated JCR-1807:
-------------------------------

    Attachment: TestAll.java
                RemoveNodeTest.java

This new unit test can be used to reproduce the problem.

> Removing peer nodes throws RepositoryException
> ----------------------------------------------
>
>                 Key: JCR-1807
>                 URL: https://issues.apache.org/jira/browse/JCR-1807
>             Project: Jackrabbit
>          Issue Type: Bug
>          Components: jackrabbit-core
>    Affects Versions: core 1.4.6
>            Reporter: Brian Whipple
>         Attachments: RemoveNodeTest.java, TestAll.java
>
>
> The following UnitTest will reproduce the error.  Note that 3 peer nodes must be removed to produce the exception.  Additional testing shows that the paths are corrupted after the second remove.
> Also note that Node.getPath (per the comment in the test) must be invoked to produce the path corruption.
> This unit test is based on the jackrabbit-jcr-tests test framework. I will attach the java file too.  Here is the test:
> package org.apache.jackrabbit.test.api;
> import javax.jcr.Node;
> import javax.jcr.NodeIterator;
> import javax.jcr.RepositoryException;
> import org.apache.jackrabbit.test.AbstractJCRTest;
> /**
>  * <code>RemoveNodeTest</code> contains the test cases for the method
>  * <code>Node.remove()</code>.
>  *
>  * @test
>  * @sources RemoveNodeTest.java
>  * @executeClass org.apache.jackrabbit.test.api.RemoveNodeTest
>  * @keywords level2
>  */
> public class RemoveNodeTest extends AbstractJCRTest
> {
>     private static final String CHILD_NAME = "child";
>     public void testAddThenRemovePeerNodes() throws Exception
>     {
>         // Must remove at least three peers so need to add three peer nodes
>         long NUM_SIB_NODES = 3;
>         for (long i = 0; i < NUM_SIB_NODES; i++)
>         {
>             testRootNode.addNode(CHILD_NAME);
>         }
>         // If this method is not invoked the test will pass
>         // Getting the child node paths contributes to the error
>         getPaths();
>         // Remove all nodes
>         removeNodes();
>         testRootNode.save();
>         // Validate that all nodes have been removed.
>         long numChildren = testRootNode.getNodes(CHILD_NAME).getSize();
>         assertEquals("Invalid number of child nodes", 0, numChildren);
>     }
>     private void getPaths() throws RepositoryException
>     {
>         NodeIterator childNodes = testRootNode.getNodes(CHILD_NAME);
>         while (childNodes.hasNext())
>         {
>             Node child = childNodes.nextNode();
>             child.getPath();
>         }
>     }
>     private void removeNodes() throws RepositoryException
>     {
>         NodeIterator childNodes = testRootNode.getNodes(CHILD_NAME);
>         while (childNodes.hasNext())
>         {
>             Node child = childNodes.nextNode();
>             child.remove();
>         }
>     }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.