You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by an...@apache.org on 2009/05/28 12:41:42 UTC
svn commit: r779552 -
/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeSetPrimaryTypeTest.java
Author: angela
Date: Thu May 28 10:41:42 2009
New Revision: 779552
URL: http://svn.apache.org/viewvc?rev=779552&view=rev
Log:
JCR-1104: JSR 283 support
- Add some trivial tests for Node.setPrimaryType(String)
Modified:
jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeSetPrimaryTypeTest.java
Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeSetPrimaryTypeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeSetPrimaryTypeTest.java?rev=779552&r1=779551&r2=779552&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeSetPrimaryTypeTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeSetPrimaryTypeTest.java Thu May 28 10:41:42 2009
@@ -61,12 +61,18 @@
if (!nt.isAbstract()) {
try {
node.setPrimaryType(ntName);
+ // property value must be adjusted immediately
+ assertEquals("The value of the jcr:primaryType property must change upon setPrimaryType.", ntName, node.getProperty(jcrPrimaryType).getString());
+
+ // save changes -> reflected upon Node.getPrimaryNodeType and Property.getValue
superuser.save();
assertEquals("Node.getPrimaryNodeType must reflect the changes made.", ntName, node.getPrimaryNodeType().getName());
+ assertEquals("The value of the jcr:primaryType property must change upon setPrimaryType.", ntName, node.getProperty(jcrPrimaryType).getString());
otherSession = helper.getReadOnlySession();
assertEquals("Node.getPrimaryNodeType must reflect the changes made.", ntName, otherSession.getNode(node.getPath()).getPrimaryNodeType().getName());
+ assertEquals("The value of the jcr:primaryType property must change upon setPrimaryType.", ntName, otherSession.getNode(node.getPath()).getProperty(jcrPrimaryType).getString());
// was successful
return;
@@ -85,6 +91,36 @@
}
/**
+ * Passing the current primary type to {@link Node#setPrimaryType(String)}
+ * must always succeed.
+ *
+ * @throws RepositoryException
+ */
+ public void testSetCurrentType() throws RepositoryException {
+ Session session = testRootNode.getSession();
+
+ Node node = testRootNode.addNode(nodeName1, testNodeType);
+ superuser.save();
+
+ node.setPrimaryType(testNodeType);
+ superuser.save();
+ }
+
+ /**
+ * Passing the current primary type to {@link Node#setPrimaryType(String)}
+ * to a new node must always succeed.
+ *
+ * @throws RepositoryException
+ */
+ public void testSetCurrentTypeOnNew() throws RepositoryException {
+ Session session = testRootNode.getSession();
+
+ Node node = testRootNode.addNode(nodeName1, testNodeType);
+ node.setPrimaryType(testNodeType);
+ superuser.save();
+ }
+
+ /**
* Tests if <code>Node.setPrimaryType(String)</code> throws a
* <code>NoSuchNodeTypeException</code> if the
* name of an existing node type is passed.
@@ -101,6 +137,8 @@
try {
node.setPrimaryType(nonExistingMixinName);
+ // ev. only detected upon save
+ superuser.save();
fail("Node.setPrimaryType(String) must throw a NoSuchNodeTypeException if no nodetype exists with the given name.");
} catch (NoSuchNodeTypeException e) {
// success