jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1497796 - in /jackrabbit/branches/2.6: ./ jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/NodeTypeTest.java
Date Fri, 28 Jun 2013 14:50:10 GMT
Author: reschke
Date: Fri Jun 28 14:50:10 2013
New Revision: 1497796

URL: http://svn.apache.org/r1497796
Log:
JCR-3322: add TCK coverage of isNodeType(expandedName) (ported to 2.6)

Modified:
    jackrabbit/branches/2.6/   (props changed)
    jackrabbit/branches/2.6/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java
    jackrabbit/branches/2.6/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/NodeTypeTest.java

Propchange: jackrabbit/branches/2.6/
------------------------------------------------------------------------------
  Merged /jackrabbit/trunk:r1497787

Modified: jackrabbit/branches/2.6/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.6/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java?rev=1497796&r1=1497795&r2=1497796&view=diff
==============================================================================
--- jackrabbit/branches/2.6/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java
(original)
+++ jackrabbit/branches/2.6/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java
Fri Jun 28 14:50:10 2013
@@ -633,7 +633,7 @@ public abstract class AbstractJCRTest ex
         String prefix = getPrefix(jcrName);
         String namespace = session.getNamespaceURI(prefix);
         String localname = getLocalName(jcrName);
-        return (namespace.length() > 0 ? "{" + namespace + "}" : "") + localname;
+        return (namespace.length() > 0 ? "{" + namespace + "}" : "{}") + localname;
     }
 
     /**

Modified: jackrabbit/branches/2.6/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/NodeTypeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.6/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/NodeTypeTest.java?rev=1497796&r1=1497795&r2=1497796&view=diff
==============================================================================
--- jackrabbit/branches/2.6/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/NodeTypeTest.java
(original)
+++ jackrabbit/branches/2.6/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/NodeTypeTest.java
Fri Jun 28 14:50:10 2013
@@ -21,9 +21,6 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
 
-import org.apache.jackrabbit.test.AbstractJCRTest;
-import org.apache.jackrabbit.test.NotExecutableException;
-
 import javax.jcr.ItemNotFoundException;
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
@@ -35,6 +32,11 @@ import javax.jcr.nodetype.NodeTypeIterat
 import javax.jcr.nodetype.NodeTypeManager;
 import javax.jcr.nodetype.PropertyDefinition;
 
+import org.apache.jackrabbit.test.AbstractJCRTest;
+import org.apache.jackrabbit.test.NotExecutableException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 /**
  * Tests if the node type hierarchy is correctly mapped to the methods
  * defined in {@link NodeType}.
@@ -46,6 +48,8 @@ import javax.jcr.nodetype.PropertyDefini
  */
 public class NodeTypeTest extends AbstractJCRTest {
 
+    private static Logger log = LoggerFactory.getLogger(NodeTypeTest.class);
+
     /**
      * The session we use for the tests
      */
@@ -291,6 +295,35 @@ public class NodeTypeTest extends Abstra
     }
 
     /**
+     * Like {@link #testIsNodeType()}, but using qualified names
+     */
+    public void testIsNodeTypeQName() throws RepositoryException {
+
+        // find a primary node type but not "nt:base"
+        NodeTypeIterator types = manager.getPrimaryNodeTypes();
+        while (types.hasNext()) {
+            NodeType type = types.nextNodeType();
+            String typename = type.getName();
+            String ns = session.getNamespaceURI(AbstractJCRTest.getPrefix(typename));
+            if (ns.length() != 0 && !ns.contains(":")) {
+                log.warn("Node type '" + typename + "' has invalid namespace '" + ns
+                        + "', thus skipping testIsNodeTypeQName() for this type");
+            } else {
+                String qn = AbstractJCRTest.getQualifiedName(session, typename);
+                assertTrue("isNodeType(String nodeTypeName) must return true if " + "NodeType
is nodeTypeName",
+                        type.isNodeType(qn));
+            }
+            if (type.isMixin()) {
+                assertFalse("isNodeType(String nodeTypeName) must return " + "false if NodeType
is not a subtype of "
+                        + "nodeTypeName", type.isNodeType(NodeType.NT_BASE));
+            } else {
+                assertTrue("isNodeType(String nodeTypeName) must return true if " + "NodeType
is a subtype of nodeTypeName",
+                        type.isNodeType(NodeType.NT_BASE));
+            }
+        }
+    }
+
+    /**
      * Test if all property defs returned by getDeclatedPropertyDefs() are also
      * returned by getPropertyDefs(). All existing node types are tested.
      */



Mime
View raw message