jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r790056 - in /jackrabbit/trunk: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/
Date Wed, 01 Jul 2009 08:12:49 GMT
Author: angela
Date: Wed Jul  1 08:12:49 2009
New Revision: 790056

URL: http://svn.apache.org/viewvc?rev=790056&view=rev
Log:
JCR-2177: Node.getWeakReferences throws UnsupportedOperationException if not referenceable

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/GetWeakReferencesTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ReferencesTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java?rev=790056&r1=790055&r2=790056&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
Wed Jul  1 08:12:49 2009
@@ -4667,6 +4667,11 @@
         // check state of this instance
         sanityCheck();
 
+        // shortcut if node isn't referenceable
+        if (!isNodeType(NameConstants.MIX_REFERENCEABLE)) {
+            return PropertyIteratorAdapter.EMPTY;
+        }
+
         Value ref = getSession().getValueFactory().createValue(this, true);
         List<Property> props = new ArrayList<Property>();
         QueryManagerImpl qm = (QueryManagerImpl) session.getWorkspace().getQueryManager();
@@ -4700,6 +4705,11 @@
         // check state of this instance
         sanityCheck();
 
+        // shortcut if node isn't referenceable
+        if (!isNodeType(NameConstants.MIX_REFERENCEABLE)) {
+            return PropertyIteratorAdapter.EMPTY;
+        }
+        
         try {
             StringBuilder stmt = new StringBuilder();
             stmt.append("//*[@").append(ISO9075.encode(name));

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/GetWeakReferencesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/GetWeakReferencesTest.java?rev=790056&r1=790055&r2=790056&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/GetWeakReferencesTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/GetWeakReferencesTest.java
Wed Jul  1 08:12:49 2009
@@ -97,4 +97,24 @@
         assertEquals("wrong weak reference property", referring.getProperty(propertyName1).getPath(),
p.getPath());
         assertFalse("no more weak references expected", it.hasNext());
     }
+
+    public void testNonReferenceable() throws RepositoryException, NotExecutableException
{
+        Node nonReferenceable = null;
+        if (testRootNode.isNodeType(mixReferenceable)) {
+            Node child = testRootNode.addNode(nodeName1, testNodeType);
+            superuser.save();
+            if (!child.isNodeType(mixReferenceable)) {
+                nonReferenceable = child;
+            }
+        } else {
+            nonReferenceable = testRootNode;
+        }
+
+        if (nonReferenceable == null) {
+            throw new NotExecutableException("Test node is referenceable.");
+        }
+
+        // getWeakReferences must return an empty iterator and must not throw.
+        assertFalse(nonReferenceable.getWeakReferences().hasNext());
+    }
 }

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ReferencesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ReferencesTest.java?rev=790056&r1=790055&r2=790056&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ReferencesTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/ReferencesTest.java
Wed Jul  1 08:12:49 2009
@@ -206,4 +206,24 @@
             fail("too many referers: " + iter.nextProperty().getPath());
         }
     }
+
+    public void testNonReferenceable() throws RepositoryException, NotExecutableException
{
+        Node nonReferenceable = null;
+        if (testRootNode.isNodeType(mixReferenceable)) {
+            Node child = testRootNode.addNode(nodeName1, testNodeType);
+            superuser.save();
+            if (!child.isNodeType(mixReferenceable)) {
+                nonReferenceable = child;
+            }
+        } else {
+            nonReferenceable = testRootNode;
+        }
+
+        if (nonReferenceable == null) {
+            throw new NotExecutableException("Test node is referenceable.");
+        }
+
+        // getReferences must return an empty iterator and must not throw.        
+        assertFalse(nonReferenceable.getReferences().hasNext());
+    }
 }



Mime
View raw message