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 EA962CB85 for ; Wed, 30 May 2012 10:28:12 +0000 (UTC) Received: (qmail 55081 invoked by uid 500); 30 May 2012 10:28:12 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 54863 invoked by uid 500); 30 May 2012 10:28:08 -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 54824 invoked by uid 99); 30 May 2012 10:28:07 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 May 2012 10:28:07 +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; Wed, 30 May 2012 10:28:03 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id ABF9B23889FA; Wed, 30 May 2012 10:27:42 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1344187 - in /jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test: AbstractJCRTest.java api/NodeDiscoveringNodeTypesTest.java Date: Wed, 30 May 2012 10:27:42 -0000 To: commits@jackrabbit.apache.org From: reschke@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120530102742.ABF9B23889FA@eris.apache.org> Author: reschke Date: Wed May 30 10:27:42 2012 New Revision: 1344187 URL: http://svn.apache.org/viewvc?rev=1344187&view=rev Log: JCR-3322: test case coverage for isNodeType(expandedName) Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeDiscoveringNodeTypesTest.java Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java?rev=1344187&r1=1344186&r2=1344187&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java (original) +++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java Wed May 30 10:27:42 2012 @@ -589,21 +589,54 @@ public abstract class AbstractJCRTest ex } /** - * Returns the local name for the given name. - * - * @param name the name. + * Returns the local name for the given jcrName. + * + * @param jcrName + * the name. * @return the local name part. */ - protected static String getLocalName(String name) { - int idx = name.indexOf(':'); + protected static String getLocalName(String jcrName) { + int idx = jcrName.indexOf(':'); + if (idx != -1) { + return jcrName.substring(idx + 1); + } else { + return jcrName; + } + } + + /** + * Returns the prefix for the given jcrName. + * + * @param jcrName + * the name. + * @return the prefix part (empty string when not prefixed) + */ + protected static String getPrefix(String jcrName) { + int idx = jcrName.indexOf(':'); if (idx != -1) { - return name.substring(idx + 1); + return jcrName.substring(0, idx); } else { - return name; + return ""; } } /** + * Returns the expanded name for the given jcrName. + * + * @param jcrName + * the name. + * @return the expanded name representation + * @throws RepositoryException + * @throws NamespaceException + */ + protected static String getQualifiedName(Session session, String jcrName) throws RepositoryException { + String prefix = getPrefix(jcrName); + String namespace = session.getNamespaceURI(prefix); + String localname = getLocalName(jcrName); + return (!namespace.isEmpty() ? "{" + namespace + "}" : "") + localname; + } + + /** * Returns the name of a workspace that is not accessible from * session. * @param session the session. Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeDiscoveringNodeTypesTest.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeDiscoveringNodeTypesTest.java?rev=1344187&r1=1344186&r2=1344187&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeDiscoveringNodeTypesTest.java (original) +++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeDiscoveringNodeTypesTest.java Wed May 30 10:27:42 2012 @@ -66,7 +66,7 @@ public class NodeDiscoveringNodeTypesTes } /** - * Releases the session aquired in {@link #setUp()}. + * Releases the session acquired in {@link #setUp()}. */ protected void tearDown() throws Exception { if (session != null) { @@ -103,7 +103,7 @@ public class NodeDiscoveringNodeTypesTes /** * Test if getMixinNodeType returns the node types according to the property - * "jcr:mixinTypes". Therefor a node with mixin types is located recursively + * "jcr:mixinTypes". Therefore a node with mixin types is located recursively * in the entire repository. A NotExecutableException is thrown when no such * node is found. */ @@ -165,22 +165,29 @@ public class NodeDiscoveringNodeTypesTes "nodeTypeName is the name of the primary node type", testRootNode.isNodeType(nodeTypeName)); + String expNodeTypeName = getQualifiedName(testRootNode.getSession(), nodeTypeName); + assertTrue("isNodeType(String expNodeTypeName) must return true if " + + "expNodeTypeName is the name of the primary node type", testRootNode.isNodeType(expNodeTypeName)); + // test with mixin node's name // (if such a node is available) Node nodeWithMixin = locateNodeWithMixinNodeTypes(testRootNode); if (nodeWithMixin != null) { NodeType types[] = nodeWithMixin.getMixinNodeTypes(); nodeTypeName = types[0].getName(); - assertTrue("isNodeType(String nodeTypeName) must return true if " + - "nodeTypeName is the name of one of the " + - "mixin node types", - nodeWithMixin.isNodeType(nodeTypeName)); + expNodeTypeName = getQualifiedName(testRootNode.getSession(), nodeTypeName); + assertTrue("isNodeType(String nodeTypeName) must return true if " + "nodeTypeName is the name of one of the " + + "mixin node types", nodeWithMixin.isNodeType(nodeTypeName)); + assertTrue("isNodeType(String expNodeTypeName) must return true if " + "expNodeTypeName is the name of one of the " + + "mixin node types", nodeWithMixin.isNodeType(expNodeTypeName)); } // test with the name of predefined supertype "nt:base" assertTrue("isNodeType(String nodeTypeName) must return true if " + "nodeTypeName is the name of a node type of a supertype", testRootNode.isNodeType(ntBase)); + assertTrue("isNodeType(String nodeTypeName) must return true if " + + "nodeTypeName is the name of a node type of a supertype", testRootNode.isNodeType(NodeType.NT_BASE)); } //-----------------------< internal >---------------------------------------