jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jean-Michel Pittet <pit...@gmail.com>
Subject Re: Questions on TCK test; testAddNodeRepositoryExceptionSaveOnNewNode
Date Wed, 01 Jun 2005 12:28:44 GMT
Hi Doug,

Thanks for downloading and running the TCK.

>     org.apache.jackrabbit.test.api.AddNodeTest
>     testAddNodeRepositoryExceptionSaveOnNewNode
> This test adds a new node and attempts to save it. It expects a
> RepositoryException. My implementation fails that test because my save
> succeeds and does not throw an exception.

Spec v.1.0 (page177):

    In order to save a newly added node, save must be called either on
the Session, or on the new node's parent or higher-order ancestor
(grandparent, etc.). An attempt to call save only on the newly added
node will throw a RepositoryException . In the context of this method
the relPath provided must not have an index on its final element. If
it does then a RepositoryException is thrown.

> 1. Why is an immediate save of a newly created node considered invalid?

The *parent* of the newly created node must first be saved, since the
addition of the node is considered an alteration to its parent.

> 2. What, if any, is the expected action between the creation of the node
> and the save?

see above

> 3. Where in the Jackrabbit code is this exception thrown?

Item.save throws this exception.

Here the test:
     * Creates new nodes using {@link Node#addNode(String)} and
     * {@link Node#addNode(String, String)}, then tries to call
     * {@link javax.jcr.Node#save()} on the new nodes. <br/><br/>
     * This should throw an {@link RepositoryException}.
    public void testAddNodeRepositoryExceptionSaveOnNewNode() throws
RepositoryException {
        // get default workspace test root node using superuser session
        Node defaultRootNode = (Node) superuser.getItem(testRootNode.getPath());

        // add a node
        Node testNode = defaultRootNode.addNode(nodeName1, testNodeType);
        Node testNode2 = defaultRootNode.addNode(nodeName2);

        try {
            // try to call save on newly created node
            fail("Calling Node.save() on a newly created node should
throw RepositoryException");
        } catch (RepositoryException e) {
            // ok, works as expected.
        try {
            // try to call save on newly created node
            fail("Calling Node.save() on a newly created node should
throw RepositoryException");
        } catch (RepositoryException e) {
            // ok, works as expected.


standardize your content-repository !          http://jcr.day.com
-------------------------------------< jean-michel.pittet@day.com >---

This message is a private communication. If you are not the intended
recipient, please do not read, copy, or use it, and do not disclose it
to others. Please notify the sender of the delivery error by replying
to this message, and then delete it from your system. Thank you.

The sender does not assume any liability for timely, trouble free,
complete, virus free, secure, error free or uninterrupted arrival of
this e-mail. For verification please request a hard copy version.

Jean-Michel Pittet - Director of Engineering - Day Software
jean-michel.pittet@day.com, +41 61 226 98 98, CH-4001 Basel

View raw message