Return-Path: Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: (qmail 59094 invoked from network); 28 Oct 2010 13:01:25 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 28 Oct 2010 13:01:25 -0000 Received: (qmail 99690 invoked by uid 500); 28 Oct 2010 13:01:25 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 99567 invoked by uid 500); 28 Oct 2010 13:01:23 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 99559 invoked by uid 99); 28 Oct 2010 13:01:23 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Oct 2010 13:01:23 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Oct 2010 13:01:22 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A30372388A41; Thu, 28 Oct 2010 13:00:25 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@jackrabbit.apache.org From: stefan@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101028130025.A30372388A41@eris.apache.org> 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; /** * JackrabbitNodeTest... @@ -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: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)