jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r1028281 - in /jackrabbit/trunk/jackrabbit-core/src/test: java/org/apache/jackrabbit/api/JackrabbitNodeTest.java resources/org/apache/jackrabbit/api/ resources/org/apache/jackrabbit/api/test_mixin_nodetypes.cnd
Date Thu, 28 Oct 2010 13:00:25 GMT
Author: stefan
Date: Thu Oct 28 13:00:25 2010
New Revision: 1028281

URL: http://svn.apache.org/viewvc?rev=1028281&view=rev
Log:
JCR-2788 Provide a JackrabbitNode#setMixins(String[] mixinNames) method

added simple test case

Added:
    jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/api/
    jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/api/test_mixin_nodetypes.cnd
      - copied, changed from r1026311, jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/nodetype/xml/test_mixin_nodetypes.cnd
Modified:
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/JackrabbitNodeTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/JackrabbitNodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/JackrabbitNodeTest.java?rev=1028281&r1=1028280&r2=1028281&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/JackrabbitNodeTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/JackrabbitNodeTest.java
Thu Oct 28 13:00:25 2010
@@ -16,11 +16,14 @@
  */
 package org.apache.jackrabbit.api;
 
+import org.apache.jackrabbit.commons.cnd.CndImporter;
 import org.apache.jackrabbit.test.AbstractJCRTest;
 
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
 import javax.jcr.RepositoryException;
+import java.io.InputStreamReader;
+import java.io.Reader;
 
 /**
  * <code>JackrabbitNodeTest</code>...
@@ -31,12 +34,18 @@ public class JackrabbitNodeTest  extends
     static final String SEQ_AFTER =  "jackraBbit";
     static final int RELPOS = 6;
 
+    static final String TEST_NODETYPES = "org/apache/jackrabbit/api/test_mixin_nodetypes.cnd";
+
     protected void setUp() throws Exception {
         super.setUp();
         assertTrue(testRootNode.getPrimaryNodeType().hasOrderableChildNodes());
         for (char c : SEQ_BEFORE.toCharArray()) {
             testRootNode.addNode(new String(new char[]{c}));
         }
+
+        Reader cnd = new InputStreamReader(getClass().getClassLoader().getResourceAsStream(TEST_NODETYPES));
+        CndImporter.registerNodeTypes(cnd, superuser);
+        cnd.close();
     }
 
     public void testRename() throws RepositoryException {
@@ -67,4 +76,43 @@ public class JackrabbitNodeTest  extends
             pos++;
         }
     }
+
+    public void testSetMixins() throws RepositoryException {
+        // create node with mixin test:AA
+        Node n = testRootNode.addNode("foo", "nt:folder");
+        n.addMixin("test:AA");
+        n.setProperty("test:propAA", "AA");
+        n.setProperty("test:propA", "A");
+        superuser.save();
+
+        // 'downgrade' from test:AA to test:A
+        ((JackrabbitNode) n).setMixins(new String[]{"test:A"});
+        superuser.save();
+
+        assertTrue(n.hasProperty("test:propA"));
+        assertFalse(n.hasProperty("test:propAA"));
+
+        // 'upgrade' from test:A to test:AA
+        ((JackrabbitNode) n).setMixins(new String[]{"test:AA"});
+        n.setProperty("test:propAA", "AA");
+        superuser.save();
+
+        assertTrue(n.hasProperty("test:propA"));
+        assertTrue(n.hasProperty("test:propAA"));
+
+        // replace test:AA with mix:title
+        ((JackrabbitNode) n).setMixins(new String[]{"mix:title"});
+        n.setProperty("jcr:title", "...");
+        n.setProperty("jcr:description", "blah blah");
+        superuser.save();
+
+        assertTrue(n.hasProperty("jcr:title"));
+        assertTrue(n.hasProperty("jcr:description"));
+        assertFalse(n.hasProperty("test:propA"));
+        assertFalse(n.hasProperty("test:propAA"));
+
+        // clean up
+        n.remove();
+        superuser.save();
+    }
 }

Copied: jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/api/test_mixin_nodetypes.cnd
(from r1026311, jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/nodetype/xml/test_mixin_nodetypes.cnd)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/api/test_mixin_nodetypes.cnd?p2=jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/api/test_mixin_nodetypes.cnd&p1=jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/nodetype/xml/test_mixin_nodetypes.cnd&r1=1026311&r2=1028281&rev=1028281&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/nodetype/xml/test_mixin_nodetypes.cnd
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/api/test_mixin_nodetypes.cnd
Thu Oct 28 13:00:25 2010
@@ -16,5 +16,9 @@
  */
 <test = "http://www.apache.org/jackrabbit/test">
 
-[test:mixinNode_protectedchild] mixin
-  + test:protectedchild (nt:unstructured) = nt:unstructured protected autocreated
+[test:A] mixin
+  - test:propA (STRING)
+
+[test:AA] > test:A
+  mixin
+  - test:propAA (STRING)



Mime
View raw message