jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1002668 - /jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserManagerImplTest.java
Date Wed, 29 Sep 2010 15:09:37 GMT
Author: angela
Date: Wed Sep 29 15:09:37 2010
New Revision: 1002668

URL: http://svn.apache.org/viewvc?rev=1002668&view=rev
Log:
JCR-2620 -  Authorizable#getProperty and #setProperty should deal with relativePath

Modified:
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserManagerImplTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserManagerImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserManagerImplTest.java?rev=1002668&r1=1002667&r2=1002668&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserManagerImplTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserManagerImplTest.java
Wed Sep 29 15:09:37 2010
@@ -217,6 +217,56 @@ public class UserManagerImplTest extends
         }
     }
 
+    public void testFindAuthorizableByRelativePath() throws NotExecutableException, RepositoryException
{
+        Principal p = getTestPrincipal();
+        Authorizable auth = null;
+
+        try {
+            auth= userMgr.createGroup(p);
+            Value[] vs = new Value[] {
+                    superuser.getValueFactory().createValue("v1"),
+                    superuser.getValueFactory().createValue("v2")
+            };
+
+            String relPath = "relPath/" + propertyName1;
+            String relPath2 = "another/" + propertyName1;
+            String relPath3 = "relPath/relPath/" + propertyName1;
+            auth.setProperty(relPath, vs);
+            auth.setProperty(relPath2, vs);
+            auth.setProperty(relPath3, superuser.getValueFactory().createValue("v3"));
+            save(superuser);
+
+            // relPath = "prop1", v = "v1" -> should find the target group
+            Iterator<Authorizable> result = userMgr.findAuthorizables(propertyName1,
"v1");
+            assertTrue("expected result", result.hasNext());
+            assertEquals(auth.getID(), result.next().getID());
+            assertFalse("expected no more results", result.hasNext());
+
+            // relPath = "prop1", v = "v1" -> should find the target group
+            result = userMgr.findAuthorizables(propertyName1, "v3");
+            assertTrue("expected result", result.hasNext());
+            assertEquals(auth.getID(), result.next().getID());
+            assertFalse("expected no more results", result.hasNext());
+
+            // relPath = "relPath/prop1", v = "v1" -> should find the target group
+            result = userMgr.findAuthorizables(relPath, "v1");
+            assertTrue("expected result", result.hasNext());
+            assertEquals(auth.getID(), result.next().getID());
+            assertFalse("expected no more results", result.hasNext());
+
+            // relPath : "./prop1", v = "v1" -> should not find the target group
+            result = userMgr.findAuthorizables("./" + propertyName1, "v1");
+            assertFalse("expected result", result.hasNext());
+            
+        } finally {
+            // remove the create group again.
+            if (auth != null) {
+                auth.remove();
+                save(superuser);
+            }
+        }
+    }
+
     public void testFindUser() throws RepositoryException, NotExecutableException {
         User u = null;
         try {



Mime
View raw message