Return-Path: X-Original-To: apmail-jackrabbit-commits-archive@www.apache.org Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id F12E2D14D for ; Thu, 5 Jul 2012 13:14:18 +0000 (UTC) Received: (qmail 95464 invoked by uid 500); 5 Jul 2012 13:14:18 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 95426 invoked by uid 500); 5 Jul 2012 13:14:18 -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 95416 invoked by uid 99); 5 Jul 2012 13:14:18 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Jul 2012 13:14:18 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.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, 05 Jul 2012 13:14:15 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id E5FC823888E4; Thu, 5 Jul 2012 13:13:54 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1357590 - /jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ShareableNodeTest.java Date: Thu, 05 Jul 2012 13:13:54 -0000 To: commits@jackrabbit.apache.org From: reschke@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120705131354.E5FC823888E4@eris.apache.org> Author: reschke Date: Thu Jul 5 13:13:54 2012 New Revision: 1357590 URL: http://svn.apache.org/viewvc?rev=1357590&view=rev Log: JCR-3371: fix removeMixin(mix:shareable) test case to allow removal of mixin; add an additional one that tests with a shared set Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ShareableNodeTest.java Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ShareableNodeTest.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ShareableNodeTest.java?rev=1357590&r1=1357589&r2=1357590&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ShareableNodeTest.java (original) +++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ShareableNodeTest.java Thu Jul 5 13:13:54 2012 @@ -1079,8 +1079,7 @@ public class ShareableNodeTest extends A } /** - * Remove mix:shareable from a shareable node. This is unsupported in - * Jackrabbit (6.13.22). + * Remove mix:shareable from a shareable node. */ public void testRemoveMixin() throws Exception { // setup parent node and first child @@ -1090,15 +1089,65 @@ public class ShareableNodeTest extends A // add mixin ensureMixinType(b, mixShareable); - b.save(); + b.getSession().save(); + // Removing the mixin will either succeed or will fail with a + // ConstraintViolationException + // (per Section 14.15 of JSR-283 specification) try { // remove mixin b.removeMixin(mixShareable); - b.save(); - fail("Removing mix:shareable should fail."); + b.getSession().save(); + // If this happens, then b shouldn't be shareable anymore ... + assertFalse(b.isNodeType(mixShareable)); + } catch (ConstraintViolationException e) { + // one possible outcome if removing 'mix:shareable' isn't supported } catch (UnsupportedRepositoryOperationException e) { - // expected + // also possible if the implementation doesn't support this + // capability + } + } + + /** + * Remove mix:shareable from a shareable node that has 2 nodes in the shared set. + */ + public void testRemoveMixinFromSharedNode() throws Exception { + // setup parent nodes and first child + Node a1 = testRootNode.addNode("a1"); + Node a2 = testRootNode.addNode("a2"); + Node b1 = a1.addNode("b1"); + testRootNode.getSession().save(); + + // add mixin + ensureMixinType(b1, mixShareable); + b1.getSession().save(); + + // clone + Workspace workspace = b1.getSession().getWorkspace(); + workspace.clone(workspace.getName(), b1.getPath(), a2.getPath() + "/b2", false); + + Node[] shared = getSharedSet(b1); + assertEquals(2, shared.length); + b1 = shared[0]; + Node b2 = shared[1]; + assertTrue(b2.isSame(b1)); + + // Removing the mixin will either succeed or will fail with a + // ConstraintViolationException + // (per Section 14.15 of JSR-283 specification) + try { + // remove mixin + b1.removeMixin(mixShareable); + b1.getSession().save(); + // If this happens, then b1 shouldn't be shareable anymore + // ... + assertFalse(b1.isNodeType(mixShareable)); + assertFalse(b2.isSame(b1)); + } catch (ConstraintViolationException e) { + // one possible outcome if removing 'mix:shareable' isn't supported + } catch (UnsupportedRepositoryOperationException e) { + // also possible if the implementation doesn't support this + // capability } }