Author: angela
Date: Tue Feb 21 18:36:38 2017
New Revision: 1783916

URL: http://svn.apache.org/viewvc?rev=1783916&view=rev
Log:
OAK-5743 : UserQueryManager: omits nt-name when searching for properties 
without path deliminator

Added:
    
jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/FindAuthorizablesRelativePathTest.java
      - copied, changed from r1783887, 
jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/FindAuthorizablesTest.java
Modified:
    
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/query/UserQueryManager.java
    
jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/FindAuthorizablesTest.java

Modified: 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/query/UserQueryManager.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/query/UserQueryManager.java?rev=1783916&r1=1783915&r2=1783916&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/query/UserQueryManager.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/query/UserQueryManager.java
 Tue Feb 21 18:36:38 2017
@@ -23,6 +23,7 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
 
+import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import javax.jcr.RepositoryException;
@@ -44,6 +45,7 @@ import org.apache.jackrabbit.oak.namepat
 import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters;
 import org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal;
 import org.apache.jackrabbit.oak.spi.security.user.AuthorizableType;
+import org.apache.jackrabbit.oak.spi.security.user.UserConstants;
 import org.apache.jackrabbit.util.ISO9075;
 import org.apache.jackrabbit.util.Text;
 import org.slf4j.Logger;
@@ -185,28 +187,17 @@ public class UserQueryManager {
             stmt.append(searchRoot);
         }
 
-        String propName;
+        String propName = Text.getName(relPath);
         String path;
         String ntName;
-        if (relPath.indexOf('/') == -1) {
-            // search for properties somewhere in the authorizable tree
-            propName = relPath;
+        if (relPath.indexOf('/') == -1 && !isReserved(propName)) {
+            // arbitrary property specified in query and no explicit relative 
path specified
+            // -> need to search within the whole in the authorizable tree
             path = null;
             ntName = null;
         } else {
-            propName = Text.getName(relPath);
-            String[] segments = Text.explode(relPath, '/', false);
-            StringBuilder sb = new StringBuilder();
-            for (int i = 0; i < segments.length - 1; i++) {
-                if (!PathUtils.denotesCurrent(segments[i])) {
-                    if (i > 0) {
-                        sb.append('/');
-                    }
-                    sb.append(segments[i]);
-                }
-            }
-            path = Strings.emptyToNull(sb.toString());
-            ntName = 
namePathMapper.getJcrName(QueryUtil.getNodeTypeName(type));
+            path = getQueryPath(relPath);
+            ntName = (path == null) ? 
namePathMapper.getJcrName(QueryUtil.getNodeTypeName(type)) : null;
         }
 
         stmt.append("//");
@@ -304,6 +295,32 @@ public class UserQueryManager {
         }
     }
 
+    @CheckForNull
+    private static String getQueryPath(@Nonnull String relPath) {
+        if (relPath.indexOf('/') == -1) {
+            // just a single segment -> don't include the path in the query
+            return null;
+        } else {
+            // compute the relative path excluding the trailing property name
+            String[] segments = Text.explode(relPath, '/', false);
+            StringBuilder sb = new StringBuilder();
+            for (int i = 0; i < segments.length - 1; i++) {
+                if (!PathUtils.denotesCurrent(segments[i])) {
+                    if (i > 0) {
+                        sb.append('/');
+                    }
+                    sb.append(segments[i]);
+                }
+            }
+            return Strings.emptyToNull(sb.toString());
+        }
+    }
+
+    @CheckForNull
+    private static boolean isReserved(@Nonnull String propName) {
+        return UserConstants.GROUP_PROPERTY_NAMES.contains(propName) || 
UserConstants.USER_PROPERTY_NAMES.contains(propName);
+    }
+
     /**
      * Predicate asserting that a given user/group is only included once in the
      * result set.

Copied: 
jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/FindAuthorizablesRelativePathTest.java
 (from r1783887, 
jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/FindAuthorizablesTest.java)
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/FindAuthorizablesRelativePathTest.java?p2=jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/FindAuthorizablesRelativePathTest.java&p1=jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/FindAuthorizablesTest.java&r1=1783887&r2=1783916&rev=1783916&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/FindAuthorizablesTest.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/FindAuthorizablesRelativePathTest.java
 Tue Feb 21 18:36:38 2017
@@ -17,392 +17,105 @@
 package org.apache.jackrabbit.oak.jcr.security.user;
 
 import java.security.Principal;
-import java.util.HashSet;
 import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 
-import com.google.common.collect.Lists;
-import org.apache.jackrabbit.api.JackrabbitSession;
-import org.apache.jackrabbit.api.security.principal.PrincipalIterator;
-import org.apache.jackrabbit.api.security.principal.PrincipalManager;
 import org.apache.jackrabbit.api.security.user.Authorizable;
 import org.apache.jackrabbit.api.security.user.Group;
-import org.apache.jackrabbit.api.security.user.User;
 import org.apache.jackrabbit.api.security.user.UserManager;
-import org.apache.jackrabbit.oak.spi.security.user.UserConstants;
 import org.apache.jackrabbit.test.NotExecutableException;
-import org.apache.jackrabbit.util.Text;
 import org.junit.Test;
 
 /**
  * Tests for the query API exposed by {@link UserManager}.
  */
-public class FindAuthorizablesTest extends AbstractUserTest {
+public class FindAuthorizablesRelativePathTest extends AbstractUserTest {
 
-    @Test
-    public void testFindAuthorizable() throws RepositoryException, 
NotExecutableException {
-        Set<Principal> principals = new HashSet<Principal>();
-        PrincipalManager pMgr = ((JackrabbitSession) 
superuser).getPrincipalManager();
-        Principal p = pMgr.getPrincipal(superuser.getUserID());
-        if (p != null) {
-            principals.add(p);
-            PrincipalIterator principalIterator = pMgr.getGroupMembership(p);
-            while (principalIterator.hasNext()) {
-                principals.add(principalIterator.nextPrincipal());
-            }
-        }
+    private Principal p;
+    private Group gr;
 
-        Authorizable auth;
-        for (Principal principal : principals) {
-            auth = userMgr.getAuthorizable(principal);
-            if (auth != null) {
-                if (!auth.isGroup() && 
auth.hasProperty(UserConstants.REP_PRINCIPAL_NAME)) {
-                    String val = 
auth.getProperty(UserConstants.REP_PRINCIPAL_NAME)[0].getString();
-                    Iterator<Authorizable> users = 
userMgr.findAuthorizables(UserConstants.REP_PRINCIPAL_NAME, val);
-
-                    // the result must contain 1 authorizable
-                    assertTrue(users.hasNext());
-                    Authorizable first = users.next();
-                    assertEquals(first.getID(), val);
-
-                    // since id is unique -> there should be no more users in
-                    // the iterator left
-                    assertFalse(users.hasNext());
-                }
-            }
-        }
+    private String relPath;
+    private String relPath2;
+    private String relPath3;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        p = getTestPrincipal();
+        gr = userMgr.createGroup(p);
+
+        Value[] vs = new Value[]{
+                superuser.getValueFactory().createValue("v1"),
+                superuser.getValueFactory().createValue("v2")
+        };
+        relPath = "relPath/" + propertyName1;
+        relPath2 = "another/" + propertyName1;
+        relPath3 = "relPath/child/" + propertyName1;
+        gr.setProperty(relPath, vs);
+        gr.setProperty(relPath2, vs);
+        gr.setProperty(relPath3, 
superuser.getValueFactory().createValue("v3"));
+        superuser.save();
     }
 
-    @Test
-    public void testFindAuthorizableByAddedProperty() throws 
RepositoryException, NotExecutableException {
-        Principal p = getTestPrincipal();
-        Authorizable auth = null;
-
+    @Override
+    protected void tearDown() throws Exception {
         try {
-            auth = userMgr.createGroup(p);
-            auth.setProperty("E-Mail", new 
Value[]{superuser.getValueFactory().createValue("anyVal")});
-            superuser.save();
-
-            boolean found = false;
-            Iterator<Authorizable> result = 
userMgr.findAuthorizables("E-Mail", "anyVal");
-            while (result.hasNext()) {
-                Authorizable a = result.next();
-                if (a.getID().equals(auth.getID())) {
-                    found = true;
-                }
-            }
-
-            assertTrue(found);
-        } finally {
-            // remove the create group again.
-            if (auth != null) {
-                auth.remove();
-                superuser.save();
-            }
-        }
-    }
-
-    @Test
-    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"));
-            superuser.save();
-
-            // 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 = "v3" -> 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();
-                superuser.save();
-            }
-        }
-    }
-
-    @Test
-    public void testFindUserInAllUsers() throws RepositoryException, 
NotExecutableException {
-        User u = null;
-        try {
-            Principal p = getTestPrincipal();
-            String uid = createUserId();
-            u = userMgr.createUser(uid, "pw", p, null);
-            superuser.save();
-
-            boolean found = false;
-            Iterator<Authorizable> it = userMgr.findAuthorizables("./" + 
UserConstants.REP_PRINCIPAL_NAME, null, UserManager.SEARCH_TYPE_USER);
-            while (it.hasNext() && !found) {
-                User nu = (User) it.next();
-                found = nu.getID().equals(uid);
-            }
-            assertTrue("Searching for 'null' must find the created user.", 
found);
-        } finally {
-            if (u != null) {
-                u.remove();
-                superuser.save();
-            }
-        }
-    }
-
-    @Test
-    public void testFindUserInAllUsers2() throws RepositoryException, 
NotExecutableException {
-        User u = null;
-        try {
-            Principal p = getTestPrincipal();
-            String uid = createUserId();
-            u = userMgr.createUser(uid, "pw", p, null);
-            superuser.save();
-
-            boolean found = false;
-            Iterator<Authorizable> it = 
userMgr.findAuthorizables(UserConstants.REP_PRINCIPAL_NAME, null, 
UserManager.SEARCH_TYPE_USER);
-            while (it.hasNext() && !found) {
-                User nu = (User) it.next();
-                found = nu.getID().equals(uid);
-            }
-            assertTrue("Searching for 'null' must find the created user.", 
found);
-        } finally {
-            if (u != null) {
-                u.remove();
-                superuser.save();
-            }
-        }
-    }
-
-    @Test
-    public void testFindUserInAllGroups() throws RepositoryException, 
NotExecutableException {
-        User u = null;
-        try {
-            Principal p = getTestPrincipal();
-            String uid = createUserId();
-            u = userMgr.createUser(uid, "pw", p, null);
-            superuser.save();
-
-            Iterator<Authorizable> it = 
userMgr.findAuthorizables(UserConstants.REP_PRINCIPAL_NAME, null, 
UserManager.SEARCH_TYPE_GROUP);
-            while (it.hasNext()) {
-                if (it.next().getPrincipal().getName().equals(p.getName())) {
-                    fail("Searching for Groups should never find a user");
-                }
-            }
-        } finally {
-            if (u != null) {
-                u.remove();
-                superuser.save();
-            }
-        }
-    }
-
-    @Test
-    public void testFindUserByPrincipalName() throws RepositoryException, 
NotExecutableException {
-        User u = null;
-        try {
-            Principal p = getTestPrincipal();
-            String uid = createUserId();
-
-            u = userMgr.createUser(uid, "pw", p, null);
-            superuser.save();
-
-            boolean found = false;
-
-            Iterator<Authorizable> it = 
userMgr.findAuthorizables(UserConstants.REP_PRINCIPAL_NAME, p.getName(), 
UserManager.SEARCH_TYPE_USER);
-            while (it.hasNext() && !found) {
-                User nu = (User) it.next();
-                found = nu.getPrincipal().getName().equals(p.getName());
-            }
-            assertTrue("Searching for principal-name must find the created 
user.", found);
-
-            // but search groups should not find anything
-            it = userMgr.findAuthorizables(UserConstants.REP_PRINCIPAL_NAME, 
p.getName(), UserManager.SEARCH_TYPE_GROUP);
-            assertFalse(it.hasNext());
-
-        } finally {
-            if (u != null) {
-                u.remove();
-                superuser.save();
-            }
-        }
-    }
-
-    @Test
-    public void testFindUserWithGroupType() throws RepositoryException, 
NotExecutableException {
-        User u = null;
-        try {
-            Principal p = getTestPrincipal();
-            String uid = createUserId();
-
-            u = userMgr.createUser(uid, "pw", p, null);
-            superuser.save();
-
-            // but search groups should not find anything
-            Iterator<Authorizable> it = 
userMgr.findAuthorizables(UserConstants.REP_PRINCIPAL_NAME, p.getName(), 
UserManager.SEARCH_TYPE_GROUP);
-            assertFalse("Searching for Groups should not find the user", 
it.hasNext());
-
-        } finally {
-            if (u != null) {
-                u.remove();
-                superuser.save();
-            }
-        }
-    }
-
-    @Test
-    public void testFindGroupInAllGroups() throws RepositoryException, 
NotExecutableException {
-        Group gr = null;
-        try {
-            Principal p = getTestPrincipal();
-            gr = userMgr.createGroup(p);
-            superuser.save();
-
-            boolean found = false;
-            Iterator<Authorizable> it = 
userMgr.findAuthorizables(UserConstants.REP_PRINCIPAL_NAME, null, 
UserManager.SEARCH_TYPE_GROUP);
-            while (it.hasNext() && !found) {
-                Group ng = (Group) it.next();
-                found = ng.getPrincipal().getName().equals(p.getName());
-            }
-            assertTrue("Searching for 'null' must find the created group.", 
found);
-        } finally {
             if (gr != null) {
                 gr.remove();
                 superuser.save();
             }
+        } finally{
+            super.tearDown();
         }
     }
 
-    @Test
-    public void testFindGroupByPrinicpalName() throws RepositoryException, 
NotExecutableException {
-        Group gr = null;
-        try {
-            Principal p = getTestPrincipal();
-            gr = userMgr.createGroup(p);
-            superuser.save();
-
-            boolean found = false;
-            Iterator<Authorizable> it = 
userMgr.findAuthorizables(UserConstants.REP_PRINCIPAL_NAME, p.getName(), 
UserManager.SEARCH_TYPE_GROUP);
-            assertTrue(it.hasNext());
-            Group ng = (Group) it.next();
-            assertEquals("Searching for principal-name must find the created 
group.", p.getName(), ng.getPrincipal().getName());
-            assertFalse("Only a single group must be found for a given 
principal name.", it.hasNext());
-        } finally {
-            if (gr != null) {
-                gr.remove();
-                superuser.save();
-            }
-        }
+    private static void assertSingleResult(Iterator<Authorizable> result, 
String expectedId) throws RepositoryException {
+        assertTrue("expected result", result.hasNext());
+        assertEquals(expectedId, result.next().getID());
+        assertFalse("expected no more results", result.hasNext());
     }
 
     @Test
-    public void testFindGroupWithUserType() throws RepositoryException, 
NotExecutableException {
-        Group gr = null;
-        try {
-            Principal p = getTestPrincipal();
-            gr = userMgr.createGroup(p);
-            superuser.save();
-
-            Iterator<Authorizable> it = 
userMgr.findAuthorizables(UserConstants.REP_PRINCIPAL_NAME, p.getName(), 
UserManager.SEARCH_TYPE_USER);
-            assertFalse(it.hasNext());
-        } finally {
-            if (gr != null) {
-                gr.remove();
-                superuser.save();
-            }
-        }
+    public void testFindV1ByName() throws NotExecutableException, 
RepositoryException {
+        // relPath = "prop1", v = "v1" -> should find the target group
+        Iterator<Authorizable> result = 
userMgr.findAuthorizables(propertyName1, "v1");
+        assertSingleResult(result, gr.getID());
     }
 
     @Test
-    public void testFindGroupInAllUsers() throws RepositoryException, 
NotExecutableException {
-        Group gr = null;
-        try {
-            Principal p = getTestPrincipal();
-            gr = userMgr.createGroup(p);
-            superuser.save();
-
-            boolean found = false;
-            Iterator<Authorizable> it = 
userMgr.findAuthorizables(UserConstants.REP_PRINCIPAL_NAME, null, 
UserManager.SEARCH_TYPE_USER);
-            while (it.hasNext()) {
-                if (it.next().getPrincipal().getName().equals(p.getName())) {
-                    fail("Searching for Users should never find a group");
-                }
-            }
-        } finally {
-            if (gr != null) {
-                gr.remove();
-                superuser.save();
-            }
-        }
+    public void testFindV3ByName() throws NotExecutableException, 
RepositoryException {
+        // relPath = "prop1", v = "v3" -> should find the target group
+        Iterator<Authorizable> result = 
userMgr.findAuthorizables(propertyName1, "v3");
+        assertSingleResult(result, gr.getID());
     }
 
     @Test
-    public void testFindAllUsersDoesNotContainGroup() throws 
RepositoryException {
-        Iterator<Authorizable> it = 
userMgr.findAuthorizables(UserConstants.REP_PRINCIPAL_NAME, null, 
UserManager.SEARCH_TYPE_USER);
-        while (it.hasNext()) {
-            assertFalse(it.next().isGroup());
-        }
+    public void testFindV1ByRelativePath() throws NotExecutableException, 
RepositoryException {
+        // relPath = "relPath/prop1", v = "v1" -> should find the target group
+        Iterator<Authorizable> result = userMgr.findAuthorizables(relPath, 
"v1");
+        assertSingleResult(result, gr.getID());
     }
 
     @Test
-    public void testFindAllGroupsDoesNotContainUser() throws 
RepositoryException {
-        Iterator<Authorizable> it = 
userMgr.findAuthorizables(UserConstants.REP_PRINCIPAL_NAME, null, 
UserManager.SEARCH_TYPE_GROUP);
-        while (it.hasNext()) {
-            assertTrue(it.next().isGroup());
-        }
+    public void testFindV1ByAltRelativePath() throws NotExecutableException, 
RepositoryException {
+        // relPath = "another/prop1", v = "v1" -> should find the target group
+        Iterator<Authorizable> result = userMgr.findAuthorizables(relPath2, 
"v1");
+        assertSingleResult(result, gr.getID());
     }
 
     @Test
-    public void testFindUserWithSpecialCharIdByPrincipalName() throws 
RepositoryException {
-        List<String> ids = Lists.newArrayList("'", "]", "']", 
Text.escapeIllegalJcrChars("']"), Text.escape("']"));
-        for (String id : ids) {
-            User user = null;
-            try {
-                user = userMgr.createUser(id, "pw");
-                superuser.save();
+    public void testFindV1AtGroupNode() throws NotExecutableException, 
RepositoryException {
+        // relPath : "./prop1", v = "v1" -> should not find the target group
+        Iterator<Authorizable> result = userMgr.findAuthorizables("./" + 
propertyName1, "v1");
+        assertFalse("expected result", result.hasNext());
+    }
 
-                boolean found = false;
-                Iterator<Authorizable> it = 
userMgr.findAuthorizables(UserConstants.REP_PRINCIPAL_NAME, id, 
UserManager.SEARCH_TYPE_USER);
-                while (it.hasNext() && !found) {
-                    Authorizable a = it.next();
-                    found = id.equals(a.getID());
-                }
-                assertTrue(found);
-            } finally {
-                if (user != null) {
-                    user.remove();
-                    superuser.save();
-                }
-            }
-        }
+    @Test
+    public void testFindV3AtGroupNode() throws NotExecutableException, 
RepositoryException {
+        // relPath : "./prop1", v = "v3" -> should not find the target group
+        Iterator<Authorizable> result = userMgr.findAuthorizables("./" + 
propertyName1, "v3");
+        assertFalse("expected result", result.hasNext());
     }
 }
\ No newline at end of file

Modified: 
jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/FindAuthorizablesTest.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/FindAuthorizablesTest.java?rev=1783916&r1=1783915&r2=1783916&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/FindAuthorizablesTest.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/FindAuthorizablesTest.java
 Tue Feb 21 18:36:38 2017
@@ -106,56 +106,6 @@ public class FindAuthorizablesTest exten
     }
 
     @Test
-    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"));
-            superuser.save();
-
-            // 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 = "v3" -> 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();
-                superuser.save();
-            }
-        }
-    }
-
-    @Test
     public void testFindUserInAllUsers() throws RepositoryException, 
NotExecutableException {
         User u = null;
         try {


Reply via email to