jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r157575 - in incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api: AddNodeTest.java NodeTest.java SetPropertyValueTest.java
Date Tue, 15 Mar 2005 19:14:40 GMT
Author: mreutegg
Date: Tue Mar 15 11:14:38 2005
New Revision: 157575

URL: http://svn.apache.org/viewcvs?view=rev&rev=157575
Log:
Extended test cases for Node.addNode() and Node.setProperty()

Modified:
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/AddNodeTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeTest.java
    incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/SetPropertyValueTest.java

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/AddNodeTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/AddNodeTest.java?view=diff&r1=157574&r2=157575
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/AddNodeTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/AddNodeTest.java Tue
Mar 15 11:14:38 2005
@@ -139,5 +139,11 @@
         } catch (RepositoryException e) {
             // correct.
         }
+        try {
+            testRootNode.addNode(nodeName1 + "[1]", testNodeType);
+            fail("Expected RepositoryException.");
+        } catch (RepositoryException e) {
+            // correct.
+        }
     }
 }

Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeTest.java?view=diff&r1=157574&r2=157575
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/api/NodeTest.java Tue Mar
15 11:14:38 2005
@@ -949,7 +949,6 @@
         }
     }
 
-
     /**
      * Creates a new node, saves it uses second session to verify if node has
      * been added.
@@ -968,5 +967,71 @@
         Session testSession = helper.getReadOnlySession();
         testSession.getItem(testNode.getPath());
         testSession.logout();
+    }
+
+    /**
+     * Tests if a {@link javax.jcr.RepositoryException} is thrown when calling
+     * <code>Node.save()</code> on a newly added node
+     */
+    public void testSaveOnNewNodeRepositoryException() throws Exception {
+        // get default workspace test root node using superuser session
+        Node defaultRootNode = (Node) superuser.getItem(testRootNode.getPath());
+
+        // create a node
+        Node newNode = defaultRootNode.addNode(nodeName1, testNodeType);
+
+        try {
+            newNode.save();
+            fail("Calling Node.save() on a newly added node should throw a RepositoryException");
+        } catch (RepositoryException success) {
+            // ok
+        }
+    }
+
+    /**
+     * Tests if the primary node type is properly stored in jcr:primaryType
+     */
+    public void testPrimaryType() throws Exception {
+        // get default workspace test root node using superuser session
+        Node defaultRootNode = (Node) superuser.getItem(testRootNode.getPath());
+
+        Node testNode = defaultRootNode.addNode(nodeName1, testNodeType);
+        assertEquals("The primary node type is not properly stored in jcr:primaryType",testNodeType,testNode.getProperty(jcrPrimaryType).getString());
+    }
+
+    /**
+     * Tests if jcr:primaryType is protected
+     */
+    public void testPrimaryTypeProtected() throws Exception {
+        // get default workspace test root node using superuser session
+        Node defaultRootNode = (Node) superuser.getItem(testRootNode.getPath());
+
+        Node testNode = defaultRootNode.addNode(nodeName1, testNodeType);
+        try {
+            testNode.setProperty(jcrPrimaryType,ntBase);
+            fail("Manually setting jcr:primaryType should throw a ConstraintViolationException");
+        }
+        catch (ConstraintViolationException success) {
+            // ok
+        }
+    }
+
+    /**
+     * Tests if jcr:mixinTypes is protected
+     */
+    public void testMixinTypesProtected() throws Exception {
+        // get default workspace test root node using superuser session
+        Node defaultRootNode = (Node) superuser.getItem(testRootNode.getPath());
+
+        Node testNode = defaultRootNode.addNode(nodeName1, testNodeType);
+        testNode.addMixin(mixReferenceable);
+
+        try {
+            testNode.setProperty(jcrMixinTypes,mixLockable);
+            fail("Manually setting jcr:mixinTypes should throw a ConstraintViolationException");
+        }
+        catch (ConstraintViolationException success) {
+            // ok
+        }
     }
 }

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=157574&r2=157575
==============================================================================
--- 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
Tue Mar 15 11:14:38 2005
@@ -50,6 +50,7 @@
     private Value[] vArray2 = new Value[3];
     private Value[] vArrayMixed = new Value[3];
     private Value[] vArrayNull = new Value[3];
+    private Value[] vArrayWithNulls = new Value[5];
 
     protected void setUp() throws Exception {
         super.setUp();
@@ -66,6 +67,9 @@
         vArrayMixed[0] = new StringValue("abc");
         vArrayMixed[1] = new BooleanValue(true);
         vArrayMixed[2] = new LongValue(2147483650L);
+
+        vArrayWithNulls[1] = new StringValue("a");
+        vArrayWithNulls[3] = new StringValue("z");
     }
 
     /**
@@ -268,6 +272,18 @@
         assertEquals("Node.setProperty(String, nullValueArray[]) did not set the property
to an empty Value[]",
                 Arrays.asList(new Value[0]),
                 Arrays.asList(testNode.getProperty(propertyName2).getValues()));
+    }
+
+    /**
+     * Tests if <code>Node.setProperty(String, Value[])</code> correctly compacts
+     * the value array by removing all null values
+     */
+    public void testCompactValueArrayWithNulls() throws Exception {
+        testRootNode.setProperty(propertyName2, vArrayWithNulls);
+        superuser.save();
+        assertEquals("Node.setProperty(String, valueArrayWithNulls[]) did not compact the
value array by removing the null values",
+                2,
+                testRootNode.getProperty(propertyName2).getValues().length);
     }
 
     /**



Mime
View raw message