jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r157060 - in incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api: NodeItemIsModifiedTest.java NodeItemIsNewTest.java PropertyItemIsModifiedTest.java PropertyItemIsNewTest.java TestAll.java
Date Fri, 11 Mar 2005 08:44:28 GMT
Author: mreutegg
Date: Fri Mar 11 00:44:25 2005
New Revision: 157060

URL: http://svn.apache.org/viewcvs?view=rev&rev=157060
Log:
Test cases for Item.isNew() and Item.isModified()

Added:
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeItemIsModifiedTest.java
  (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeItemIsNewTest.java
  (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/PropertyItemIsModifiedTest.java
  (with props)
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/PropertyItemIsNewTest.java
  (with props)
Modified:
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/TestAll.java

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeItemIsModifiedTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeItemIsModifiedTest.java?view=auto&rev=157060
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeItemIsModifiedTest.java
(added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeItemIsModifiedTest.java
Fri Mar 11 00:44:25 2005
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.test.api;
+
+import org.apache.jackrabbit.test.AbstractJCRTest;
+
+import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+/**
+ * Test cases for {@link Item#isModified()} on a node.
+ * <p/>
+ * Configuration requirements:<br/>
+ * The node at {@link #testRoot} must allow a child node of type
+ * {@link #testNodeType} with name {@link #nodeName1}. The node type must
+ * support a non-mandatory string property with name {@link #propertyName1}.
+ *
+ * @test
+ * @sources NodeItemIsModifiedTest.java
+ * @executeClass org.apache.jackrabbit.test.api.NodeItemIsModifiedTest
+ * @keywords level2
+ */
+public class NodeItemIsModifiedTest extends AbstractJCRTest {
+
+    /**
+     * Test if Item.isModified() returns false after a new NodeItem is set
+     * (before node is saved (transient). That means the NodeItem don't exists
+     * persistent).
+     *
+     * @see javax.jcr.Item#isModified()
+     */
+    public void testTransientNewNodeItemIsModified () throws RepositoryException {
+        Node testNode = testRootNode.addNode(nodeName1, testNodeType);
+        Item testNodeItem = superuser.getItem(testNode.getPath());
+        // check testNodeItem.isModified() for a new NodeItem before save
+        assertFalse("Item.isModified() must return false directly after a new NodeItem is
added (before save of the parent node)", testNodeItem.isModified());
+    }
+
+    /**
+     * Test if Item.isModified() returns false after a new NodeItem is set
+     * and saved (persistent). That means the NodeItem exists persistently but
+     * isn't modified after save.
+     * This is equivalent to the test if Item.isModified() returns false for an
+     * already exixting and not modified NodeItem.
+     *
+     * @see javax.jcr.Item#isModified()
+     */
+    public void testPersistentNewNodeItemIsModified () throws RepositoryException {
+        Node testNode = testRootNode.addNode(nodeName1, testNodeType);
+        testRootNode.save();
+        Item testNodeItem = superuser.getItem(testNode.getPath());
+        // check testNodeItem.isModified() for a new NodeItem after save
+        assertFalse("Item.isModified() must return false after a new NodeItem is added and
the parent Node is saved", testNodeItem.isModified());
+    }
+
+    /**
+     * Test if Item.isModified() returns true for an already existing and modified
+     * NodeItem (modifications aren't saved (transient)).
+     * Modified means that a property is added with a string value.
+     *
+     * @see javax.jcr.Item#isModified()
+     */
+    public void testTransientNodeItemIsModified () throws RepositoryException {
+        Node testNode = testRootNode.addNode(nodeName1, testNodeType);
+        testRootNode.save();
+        // modify the persistent testNode
+        testNode.setProperty(propertyName1, "test");
+        Item testNodeItem = superuser.getItem(testNode.getPath());
+        // check testNodeItem.isModified() before save
+        assertTrue("Item.isModified() must return true directly after an existing NodeItem
is modified (before current node is saved)", testNodeItem.isModified());
+    }
+
+    /**
+     * Test if Item.isModified() returns false for an already exixting and modified
+     * NodeItem after the node is saved (persistent).
+     * Modified means that a property is added with a string value.
+     *
+     * @see javax.jcr.Item#isModified()
+     */
+    public void testPersistentNodeItemIsModified () throws RepositoryException {
+        Node testNode = testRootNode.addNode(nodeName1, testNodeType);
+        testRootNode.save();
+        // modify the persistent testNode
+        testNode.setProperty(propertyName1, "test");
+        testNode.save();
+        Item testNodeItem = superuser.getItem(testNode.getPath());
+        // check testNodeItem.isModified() after save
+        assertFalse("Item.isModified() must return false after an existing Property is modified
and the current Node is saved", testNodeItem.isModified());
+    }
+
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeItemIsModifiedTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeItemIsNewTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeItemIsNewTest.java?view=auto&rev=157060
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeItemIsNewTest.java
(added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeItemIsNewTest.java
Fri Mar 11 00:44:25 2005
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.test.api;
+
+import org.apache.jackrabbit.test.AbstractJCRTest;
+
+import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+/**
+ * Test cases for {@link Item#isNew()} on a node.
+ * <p/>
+ * Configuration requirements:<br/>
+ * The node at {@link #testRoot} must allow a child node of type
+ * {@link #testNodeType} with name {@link #nodeName1}.
+ *
+ * @test
+ * @sources NodeItemIsNewTest.java
+ * @executeClass org.apache.jackrabbit.test.api.NodeItemIsNewTest
+ * @keywords level2
+ */
+public class NodeItemIsNewTest extends AbstractJCRTest {
+
+    /**
+     * Test if Item.isNew() returns true directly after a new NodeItem is added
+     * (before node is saved (transient)).
+     *
+     * @see javax.jcr.Item#isNew()
+     */
+    public void testTransientNodeItemIsNew () throws RepositoryException {
+        Node testNode = testRootNode.addNode(nodeName1, testNodeType);
+        Item testNodeItem = superuser.getItem(testNode.getPath());
+        // check testNodeItem is new before save
+        assertTrue("Item.isNew() must return true directly after a new NodeItem is added
(before save of the parent node)", testNodeItem.isNew());
+    }
+
+    /**
+     * Test if Item.isNew() returns false after a NodeItem is added and
+     * the node is saved (persistent).
+     *
+     * @see javax.jcr.Item#isNew()
+     */
+    public void testPersistentNodeItemIsNew () throws RepositoryException {
+        Node testNode = testRootNode.addNode(nodeName1, testNodeType);
+        testRootNode.save();
+        Item testNodeItem = superuser.getItem(testNode.getPath());
+        // check testNodeItem is new after save
+        assertFalse("Item.isNew() must return false after a new NodeItem is added and the
parent Node is saved", testNodeItem.isNew());
+    }
+
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeItemIsNewTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/PropertyItemIsModifiedTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/PropertyItemIsModifiedTest.java?view=auto&rev=157060
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/PropertyItemIsModifiedTest.java
(added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/PropertyItemIsModifiedTest.java
Fri Mar 11 00:44:25 2005
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.test.api;
+
+import org.apache.jackrabbit.test.AbstractJCRTest;
+
+import javax.jcr.Item;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Node;
+
+/**
+ * Test cases for {@link Item#isModified()} on a property.
+ * <p/>
+ * Configuration requirements:<br/>
+ * The node at {@link #testRoot} must allow a child node of type
+ * {@link #testNodeType} with name {@link #nodeName1}. The node type must
+ * support a non-mandatory string property with name {@link #propertyName1}.
+ *
+ * @test
+ * @sources PropertyItemIsModifiedTest.java
+ * @executeClass org.apache.jackrabbit.test.api.PropertyItemIsModifiedTest
+ * @keywords level2
+ */
+public class PropertyItemIsModifiedTest extends AbstractJCRTest {
+
+    protected Node testNode;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        // build persistent node
+        try {
+            testNode = testRootNode.addNode(nodeName1, testNodeType);
+            testRootNode.save();
+        } catch (RepositoryException e) {
+            fail("Failed to create test node." + e.getMessage());
+        }
+    }
+
+    /**
+     * Test if Item.isModified() returns false after a new PropertyItem is set
+     * (before node is saved (transient). That means the PropertyItem don't exists
+     * persistent).
+     *
+     * @see javax.jcr.Item#isModified()
+     */
+    public void testTransientNewPropertyItemIsModified () throws RepositoryException {
+        Property testProperty = testNode.setProperty(propertyName1, "test");
+        Item testPropertyItem = superuser.getItem(testProperty.getPath());
+        // check testPropertyItem.isModified() for a new PropertyItem before save
+        assertFalse("Item.isModified() must return false directly after a new PropertyItem
is set (before current node is saved)", testPropertyItem.isModified());
+    }
+
+    /**
+     * Test if Item.isModified() returns false after a new PropertyItem is set
+     * and saved (persistent). That means the PropertyItem exists persistently but
+     * isn't modified after save.
+     * This is equivalent to the test if Item.isModified() returns false for an
+     * already exixting and not modified PropertyItem.
+     *
+     * @see javax.jcr.Item#isModified()
+     */
+    public void testPersistentNewPropertyItemIsModified () throws RepositoryException {
+        Property testProperty = testNode.setProperty(propertyName1, "test");
+        testNode.save();
+        Item testPropertyItem = superuser.getItem(testProperty.getPath());
+        // check testPropertyItem.isModified() for a new PropertyItem after save
+        assertFalse("Item.isModified() must return false after a new PropertyItem is set
and current node is saved", testPropertyItem.isModified());
+    }
+
+    /**
+     * Test if Item.isModified() returns true for an already existing and modified
+     * PropertyItem (modifications aren't saved (transient)).
+     *
+     * @see javax.jcr.Item#isModified()
+     */
+    public void testTransientPropertyItemIsModified () throws RepositoryException {
+        Property testProperty = testNode.setProperty(propertyName1, "test1");
+        testNode.save();
+        testProperty.setValue("test2");
+        Item testPropertyItem = superuser.getItem(testProperty.getPath());
+        // check testPropertyItem.isModified() before save
+        assertTrue("Item.isModified() must return true directly after an existing Property
is modified (before current node is saved)", testPropertyItem.isModified());
+    }
+
+    /**
+     * Test if Item.isModified() returns false for an already exixting and modified
+     * PropertyItem after the current node is saved (persistent).
+     *
+     * @see javax.jcr.Item#isModified()
+     */
+    public void testPersistentPropertyItemIsModified () throws RepositoryException {
+        Property testProperty = testNode.setProperty(propertyName1, "test1");
+        testNode.save();
+        testProperty.setValue("test2");
+        testNode.save();
+        Item testPropertyItem = superuser.getItem(testProperty.getPath());
+        // check testPropertyItem.isModified() after save
+        assertFalse("Item.isModified() must return false after an existing Property is modified
and the current Node is saved", testPropertyItem.isModified());
+    }
+
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/PropertyItemIsModifiedTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/PropertyItemIsNewTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/PropertyItemIsNewTest.java?view=auto&rev=157060
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/PropertyItemIsNewTest.java
(added)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/PropertyItemIsNewTest.java
Fri Mar 11 00:44:25 2005
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.test.api;
+
+import org.apache.jackrabbit.test.AbstractJCRTest;
+
+import javax.jcr.Item;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Node;
+
+/**
+ * Test cases for {@link Item#isNew()} on a property.
+ * <p/>
+ * Configuration requirements:<br/>
+ * The node at {@link #testRoot} must allow a child node of type
+ * {@link #testNodeType} with name {@link #nodeName1}. The node type must
+ * support a non-mandatory string property with name {@link #propertyName1}.
+ *
+ * @test
+ * @sources PropertyItemIsNewTest.java
+ * @executeClass org.apache.jackrabbit.test.api.PropertyItemIsNewTest
+ * @keywords level2
+ */
+public class PropertyItemIsNewTest extends AbstractJCRTest {
+
+    protected Node testNode;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        // build persistent node
+        try {
+            testNode = testRootNode.addNode(nodeName1, testNodeType);
+            testRootNode.save();
+        } catch (RepositoryException e) {
+            fail("Failed to create test node." + e.getMessage());
+        }
+    }
+
+    /**
+     * Test if Item.isNew() returns true direct after a new PropertyItem is set
+     * (before node is saved (transient)).
+     *
+     * @see javax.jcr.Item#isNew()
+     */
+    public void testTransientPropertyItemIsNew () throws RepositoryException {
+        Property testProperty = testNode.setProperty(propertyName1, "test");
+        Item testPropertyItem = superuser.getItem(testProperty.getPath());
+        // check testPropertyItem.isNew() before save
+        assertTrue("Item.isNew() must return true directly after a new Property is set (before
current node is saved)", testPropertyItem.isNew());
+    }
+
+    /**
+     * Test if Item.isNew() returns false after a new PropertyItem is set and
+     * the node is saved (persistent).
+     * This is equivalent to the test if Item.isNew() returns false for an
+     * already exixting and not modified PropertyItem.
+     *
+     * @see javax.jcr.Item#isNew()
+     */
+    public void testPersistentPropertyItemIsNew () throws RepositoryException {
+        Property testProperty = testNode.setProperty(propertyName1, "test");
+        testNode.save();
+        Item testPropertyItem = superuser.getItem(testProperty.getPath());
+        // check testPropertyItem.isNew() after save
+        assertFalse("Item.isNew() must return false after a new PropertyItem is set and the
current Node is saved", testPropertyItem.isNew());
+    }
+
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/PropertyItemIsNewTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/TestAll.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/TestAll.java?view=diff&r1=157059&r2=157060
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/TestAll.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/TestAll.java Fri Mar
11 00:44:25 2005
@@ -81,6 +81,11 @@
         suite.addTestSuite(SetValueReferenceTest.class);
         suite.addTestSuite(SetValueStringTest.class);
 
+        suite.addTestSuite(NodeItemIsModifiedTest.class);
+        suite.addTestSuite(NodeItemIsNewTest.class);
+        suite.addTestSuite(PropertyItemIsModifiedTest.class);
+        suite.addTestSuite(PropertyItemIsNewTest.class);
+
         return suite;
     }
 }



Mime
View raw message