jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1507308 [2/2] - /jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/
Date Fri, 26 Jul 2013 13:40:29 GMT
Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/MemberNodeImportTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/MemberNodeImportTest.java?rev=1507308&r1=1507307&r2=1507308&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/MemberNodeImportTest.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/MemberNodeImportTest.java Fri Jul 26 13:40:29 2013
@@ -25,7 +25,7 @@ import javax.jcr.NodeIterator;
 import javax.jcr.PropertyType;
 import javax.jcr.Value;
 
-import com.google.common.collect.ImmutableList;
+import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.api.security.user.Authorizable;
 import org.apache.jackrabbit.api.security.user.Group;
 import org.apache.jackrabbit.oak.spi.security.user.UserConstants;
@@ -35,6 +35,11 @@ import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 /**
  * Testing import behavior if user mgt is configured to store group members
  * in a tree structure.
@@ -43,14 +48,9 @@ import org.junit.Test;
 public class MemberNodeImportTest extends AbstractImportTest {
 
     @Override
-    protected List<String> getPathsToRemove() {
-        return ImmutableList.of(GROUPPATH + "/s", GROUPPATH + "/gFolder");
-    }
-
-    @Override
     @Before
-    public void setUp() throws Exception {
-        super.setUp();
+    public void before() throws Exception {
+        super.before();
         // FIXME: create JCR repository with user mgt setup that stores group members in a tree structure (blocked by OAK-482)
     }
 
@@ -59,6 +59,11 @@ public class MemberNodeImportTest extend
         return ImportBehavior.NAME_BESTEFFORT;
     }
 
+    @Override
+    protected String getTargetPath() {
+        return GROUPPATH;
+    }
+
     @Test
     public void testImportGroupMembersFromNodesBestEffort() throws Exception {
         String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><sv:node sv:name=\"s\" xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" xmlns:sling=\"http://sling.apache.org/jcr/sling/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" xmlns:fn_old=\"http://www.w3.org/2004/10/xpath-functions\" xmlns:fn=\"http://www.w3.org/2005/xpath-functions\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\" xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" xmlns:rep=\"internal\"><sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:AuthorizableFolder</sv:value></sv:property><sv:property sv:name=\"jcr:created\" sv:type=\"Date\"><sv:value>2010-08-17T18:22:20.086+02:00</sv:value></sv:property><sv:property sv:name=\"jcr:createdBy\" sv:type=\"String\"><sv:value>admin</sv:value></sv:property><sv:node sv:name=\"sh\"><sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:AuthorizableFolder</sv:value></sv:property><sv:property sv:name=\"jcr:created
 \" sv:type=\"Date\"><sv:value>2010-08-17T18:22:20.086+02:00</sv:value></sv:property><sv:property sv:name=\"jcr:createdBy\" sv:type=\"String\"><sv:value>admin</sv:value></sv:property><sv:node sv:name=\"shrimps\"><sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:Group</sv:value></sv:property><sv:property sv:name=\"jcr:uuid\" sv:type=\"String\"><sv:value>08429aec-6f09-30db-8c83-1a2a57fc760c</sv:value></sv:property><sv:property sv:name=\"jcr:created\" sv:type=\"Date\">" +
@@ -67,13 +72,13 @@ public class MemberNodeImportTest extend
                 "\"WeakReference\"><sv:value>16d5d24f-5b09-3199-9bd4-e5f57bf11237</sv:value></sv:property><sv:property sv:name=\"susi\" sv:type=\"WeakReference\"><sv:value>536931d8-0dec-318c-b3db-9612bdd004d4</sv:value></sv:property></sv:node></sv:node></sv:node></sv:node></sv:node></sv:node>";
 
         List<String> createdUsers = new LinkedList<String>();
-        Node groupsNode = superuser.getNode(GROUPPATH);
+        Node groupsNode = getTargetNode();
         try {
             String[] users = {"angi", "adi", "hansi", "lisi", "luzi", "susi", "pipi", "hari", "gabi", "eddi",
                     "debbi", "cati", "admin", "anonymous"};
 
             doImport(groupsNode.getPath(), xml);
-            superuser.save();
+            adminSession.save();
 
             for (String user : users) {
                 if (userMgr.getAuthorizable(user) == null) {
@@ -81,7 +86,7 @@ public class MemberNodeImportTest extend
                     createdUsers.add(user);
                 }
             }
-            superuser.save();
+            adminSession.save();
 
             Authorizable aShrimps = userMgr.getAuthorizable("shrimps");
             assertNotNull(aShrimps);
@@ -94,27 +99,27 @@ public class MemberNodeImportTest extend
 
 
         } finally {
-            superuser.refresh(false);
+            adminSession.refresh(false);
             for (String user : createdUsers) {
                 Authorizable a = userMgr.getAuthorizable(user);
                 if (a != null && !a.isGroup()) {
                     a.remove();
                 }
             }
-            superuser.save();
+            adminSession.save();
             for (NodeIterator it = groupsNode.getNodes(); it.hasNext(); ) {
                 it.nextNode().remove();
             }
             if (!userMgr.isAutoSave()) {
-                superuser.save();
+                adminSession.save();
             }
         }
     }
 
     @Test
     public void testImportNonExistingMemberBestEffort() throws Exception {
-        Node n = testRootNode.addNode(nodeName1, ntUnstructured);
-        n.addMixin(mixReferenceable);
+        Node n = adminSession.getRootNode().addNode("node", JcrConstants.NT_UNSTRUCTURED);
+        n.addMixin(JcrConstants.MIX_REFERENCEABLE);
 
         List<String> invalid = new ArrayList<String>();
         invalid.add(UUID.randomUUID().toString()); // random uuid
@@ -132,12 +137,12 @@ public class MemberNodeImportTest extend
                     "</sv:node>";
             try {
                 // BESTEFFORT behavior -> must import non-existing members.
-                doImport(GROUPPATH, xml);
+                doImport(getTargetPath(), xml);
                 Authorizable a = userMgr.getAuthorizable("g1");
                 if (a.isGroup()) {
                     // the rep:members property must contain the invalid value
                     boolean found = false;
-                    Node grNode = superuser.getNode(a.getPath());
+                    Node grNode = adminSession.getNode(a.getPath());
                     for (Value memberValue : grNode.getProperty(UserConstants.REP_MEMBERS).getValues()) {
                         assertEquals(PropertyType.WEAKREFERENCE, memberValue.getType());
                         if (id.equals(memberValue.getString())) {
@@ -148,12 +153,12 @@ public class MemberNodeImportTest extend
                     assertTrue("ImportBehavior.BESTEFFORT must import non-existing members.",found);
 
                     // declared members must not list the invalid entry.
-                    assertNotDeclaredMember((Group) a, id, superuser);
+                    assertNotDeclaredMember((Group) a, id, adminSession);
                 } else {
                     fail("'g1' was not imported as Group.");
                 }
             } finally {
-                superuser.refresh(false);
+                adminSession.refresh(false);
             }
         }
     }
@@ -187,12 +192,12 @@ public class MemberNodeImportTest extend
 
         try {
             // BESTEFFORT behavior -> must import non-existing members.
-            doImport(GROUPPATH, xml);
+            doImport(getTargetPath(), xml);
             Authorizable g1 = userMgr.getAuthorizable("g1");
             if (g1.isGroup()) {
                 // the rep:members property must contain the invalid value
                 boolean found = false;
-                Node grNode = superuser.getNode(g1.getPath());
+                Node grNode = adminSession.getNode(g1.getPath());
                 for (Value memberValue : grNode.getProperty(UserConstants.REP_MEMBERS).getValues()) {
                     assertEquals(PropertyType.WEAKREFERENCE, memberValue.getType());
                     if (nonExistingId.equals(memberValue.getString())) {
@@ -214,18 +219,18 @@ public class MemberNodeImportTest extend
             - g is member of g1
             - g1 isn't member of g
             */
-            doImport(GROUPPATH + "/gFolder", xml2);
+            doImport(getTargetPath() + "/gFolder", xml2);
 
             Authorizable g = userMgr.getAuthorizable("g");
             assertNotNull(g);
             if (g.isGroup()) {
-                assertNotDeclaredMember((Group) g, g1Id, superuser);
+                assertNotDeclaredMember((Group) g, g1Id, adminSession);
             } else {
                 fail("'g' was not imported as Group.");
             }
 
         } finally {
-            superuser.refresh(false);
+            adminSession.refresh(false);
         }
     }
 }

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportAbortTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportAbortTest.java?rev=1507308&r1=1507307&r2=1507308&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportAbortTest.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportAbortTest.java Fri Jul 26 13:40:29 2013
@@ -18,76 +18,26 @@ package org.apache.jackrabbit.oak.jcr.se
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.UUID;
 import javax.jcr.RepositoryException;
-import javax.security.auth.Subject;
 
-import com.google.common.collect.ImmutableList;
-import org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl;
 import org.apache.jackrabbit.oak.spi.xml.ImportBehavior;
 import org.junit.Test;
 
+import static org.junit.Assert.fail;
+
 /**
- * Testing {@link ImportBehavior#ABORT} for user/group import
+ * Testing {@link ImportBehavior#ABORT} for user import
  */
 public class UserImportAbortTest extends AbstractImportTest {
 
     @Override
-    protected List<String> getPathsToRemove() {
-        return ImmutableList.of(GROUPPATH + "/gFolder", USERPATH + "/t");
-    }
-
-    @Override
     protected String getImportBehavior() {
         return ImportBehavior.NAME_ABORT;
     }
 
-    @Test
-    public void testImportNonExistingMemberAbort() throws Exception {
-        List<String> invalid = new ArrayList<String>();
-        invalid.add(UUID.randomUUID().toString()); // random uuid
-        invalid.add(getExistingUUID()); // uuid of non-authorizable node
-
-        for (String id : invalid) {
-            String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
-                    "<sv:node sv:name=\"gFolder\" xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" xmlns:fn_old=\"http://www.w3.org/2004/10/xpath-functions\" xmlns:fn=\"http://www.w3.org/2005/xpath-functions\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" xmlns:rep=\"internal\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\">" +
-                    "   <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:AuthorizableFolder</sv:value></sv:property>" +
-                        "<sv:node sv:name=\"g1\"><sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:Group</sv:value></sv:property>" +
-                        "   <sv:property sv:name=\"jcr:uuid\" sv:type=\"String\"><sv:value>0120a4f9-196a-3f9e-b9f5-23f31f914da7</sv:value></sv:property>" +
-                        "   <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>g1</sv:value></sv:property>" +
-                        "   <sv:property sv:name=\"rep:members\" sv:type=\"WeakReference\"><sv:value>" +id+ "</sv:value></sv:property>" +
-                        "</sv:node>" +
-                    "</sv:node>";
-            try {
-                doImport(GROUPPATH, xml);
-                // import behavior ABORT -> should throw.
-                fail("importing invalid members -> must throw.");
-            } catch (RepositoryException e) {
-                // success as well
-            } finally {
-                adminSession.refresh(false);
-            }
-        }
-    }
-
-    @Test
-    public void testImportSelfAsGroupAbort() throws Exception {
-        String invalidId = "0120a4f9-196a-3f9e-b9f5-23f31f914da7"; // uuid of the group itself
-        String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
-                "<sv:node sv:name=\"gFolder\" xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" xmlns:fn_old=\"http://www.w3.org/2004/10/xpath-functions\" xmlns:fn=\"http://www.w3.org/2005/xpath-functions\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" xmlns:rep=\"internal\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\">" +
-                "   <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:AuthorizableFolder</sv:value></sv:property>" +
-                "<sv:node sv:name=\"g1\"><sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:Group</sv:value></sv:property>" +
-                "   <sv:property sv:name=\"jcr:uuid\" sv:type=\"String\"><sv:value>"+invalidId+"</sv:value></sv:property>" +
-                "   <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>g1</sv:value></sv:property>" +
-                "   <sv:property sv:name=\"rep:members\" sv:type=\"WeakReference\"><sv:value>" +invalidId+ "</sv:value></sv:property>" +
-                "</sv:node>" +
-                "</sv:node>";
-        try {
-            doImport(GROUPPATH, xml);
-            fail("Importing self as group with ImportBehavior.ABORT must fail.");
-        } catch (RepositoryException e) {
-            // success.
-        }
+    @Override
+    protected String getTargetPath() {
+        return USERPATH;
     }
 
     @Test
@@ -105,11 +55,8 @@ public class UserImportAbortTest extends
                     "   <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>t</sv:value></sv:property>" +
                     "   <sv:property sv:name=\"rep:impersonators\" sv:type=\"String\"><sv:value>" +principalName+ "</sv:value></sv:property>" +
                     "</sv:node>";
-            Subject subj = new Subject();
-            subj.getPrincipals().add(new PrincipalImpl(principalName));
-
             try {
-                doImport(USERPATH, xml);
+                doImport(getTargetPath(), xml);
                 fail("UserImporter.ImportBehavior.ABORT -> importing invalid impersonators must throw.");
             } catch (RepositoryException e) {
                 // success
@@ -121,28 +68,22 @@ public class UserImportAbortTest extends
 
     @Test
     public void testImportNonExistingImpersonationAbort() throws Exception {
-        List<String> nonExisting = new ArrayList<String>();
-        nonExisting.add("anybody"); // an non-existing princ-name
-
-        for (String principalName : nonExisting) {
-            String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
-                    "<sv:node sv:name=\"t\" xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" xmlns:fn_old=\"http://www.w3.org/2004/10/xpath-functions\" xmlns:fn=\"http://www.w3.org/2005/xpath-functions\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" xmlns:rep=\"internal\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\">" +
-                    "   <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:User</sv:value></sv:property>" +
-                    "   <sv:property sv:name=\"jcr:uuid\" sv:type=\"String\"><sv:value>e358efa4-89f5-3062-b10d-d7316b65649e</sv:value></sv:property>" +
-                    "   <sv:property sv:name=\"rep:password\" sv:type=\"String\"><sv:value>{sha1}8efd86fb78a56a5145ed7739dcb00c78581c5375</sv:value></sv:property>" +
-                    "   <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>t</sv:value></sv:property><sv:property sv:name=\"rep:impersonators\" sv:type=\"String\"><sv:value>" +principalName+ "</sv:value></sv:property>" +
-                    "</sv:node>";
-            Subject subj = new Subject();
-            subj.getPrincipals().add(new PrincipalImpl(principalName));
-
-            try {
-                doImport(USERPATH, xml);
-                fail("UserImporter.ImportBehavior.ABORT -> importing invalid impersonators must throw.");
-            } catch (RepositoryException e) {
-                // success
-            } finally {
-                adminSession.refresh(false);
-            }
+        String nonExistingPrincipalName = "anybody";
+        String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+                "<sv:node sv:name=\"t\" xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" xmlns:fn_old=\"http://www.w3.org/2004/10/xpath-functions\" xmlns:fn=\"http://www.w3.org/2005/xpath-functions\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" xmlns:rep=\"internal\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\">" +
+                "   <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:User</sv:value></sv:property>" +
+                "   <sv:property sv:name=\"jcr:uuid\" sv:type=\"String\"><sv:value>e358efa4-89f5-3062-b10d-d7316b65649e</sv:value></sv:property>" +
+                "   <sv:property sv:name=\"rep:password\" sv:type=\"String\"><sv:value>{sha1}8efd86fb78a56a5145ed7739dcb00c78581c5375</sv:value></sv:property>" +
+                "   <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>t</sv:value></sv:property>" +
+                "   <sv:property sv:name=\"rep:impersonators\" sv:type=\"String\"><sv:value>" +nonExistingPrincipalName+ "</sv:value></sv:property>" +
+                "</sv:node>";
+        try {
+            doImport(getTargetPath(), xml);
+            fail("UserImporter.ImportBehavior.ABORT -> importing invalid impersonators must throw.");
+        } catch (RepositoryException e) {
+            // success
+        } finally {
+            adminSession.refresh(false);
         }
     }
 }

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportBestEffortTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportBestEffortTest.java?rev=1507308&r1=1507307&r2=1507308&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportBestEffortTest.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportBestEffortTest.java Fri Jul 26 13:40:29 2013
@@ -17,172 +17,35 @@
 package org.apache.jackrabbit.oak.jcr.security.user;
 
 import java.security.Principal;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
 import javax.jcr.ImportUUIDBehavior;
 import javax.jcr.ItemExistsException;
-import javax.jcr.Node;
-import javax.jcr.PropertyType;
-import javax.jcr.Value;
 import javax.security.auth.Subject;
 
-import com.google.common.collect.ImmutableList;
 import org.apache.jackrabbit.api.security.principal.PrincipalIterator;
 import org.apache.jackrabbit.api.security.user.Authorizable;
-import org.apache.jackrabbit.api.security.user.Group;
 import org.apache.jackrabbit.api.security.user.Impersonation;
 import org.apache.jackrabbit.api.security.user.User;
-import org.apache.jackrabbit.oak.spi.security.user.UserConstants;
 import org.apache.jackrabbit.oak.spi.xml.ImportBehavior;
-import org.apache.jackrabbit.test.NotExecutableException;
 import org.junit.Test;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 /**
- * Testing {@link ImportBehavior#BESTEFFORT} for user/group import
+ * Testing {@link ImportBehavior#BESTEFFORT} for user import
  */
 public class UserImportBestEffortTest extends AbstractImportTest {
 
     @Override
-    protected List<String> getPathsToRemove() {
-        return ImmutableList.of(GROUPPATH + "/gFolder", USERPATH + "/t", USERPATH + "/uFolder");
-    }
-
-    @Override
     protected String getImportBehavior() {
         return ImportBehavior.NAME_BESTEFFORT;
     }
 
-    @Test
-    public void testImportNonExistingMemberBestEffort() throws Exception {
-        List<String> invalid = new ArrayList<String>();
-        invalid.add(UUID.randomUUID().toString()); // random uuid
-        invalid.add(getExistingUUID()); // uuid of non-authorizable node
-
-        for (String id : invalid) {
-            String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
-                    "<sv:node sv:name=\"gFolder\" xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" xmlns:fn_old=\"http://www.w3.org/2004/10/xpath-functions\" xmlns:fn=\"http://www.w3.org/2005/xpath-functions\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" xmlns:rep=\"internal\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\">" +
-                    "   <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:AuthorizableFolder</sv:value></sv:property>" +
-                        "<sv:node sv:name=\"g1\"><sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:Group</sv:value></sv:property>" +
-                        "   <sv:property sv:name=\"jcr:uuid\" sv:type=\"String\"><sv:value>0120a4f9-196a-3f9e-b9f5-23f31f914da7</sv:value></sv:property>" +
-                        "   <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>g1</sv:value></sv:property>" +
-                        "   <sv:property sv:name=\"rep:members\" sv:type=\"WeakReference\"><sv:value>" +id+ "</sv:value></sv:property>" +
-                        "</sv:node>" +
-                    "</sv:node>";
-            try {
-                // BESTEFFORT behavior -> must import non-existing members.
-                doImport(GROUPPATH, xml);
-                Authorizable a = userMgr.getAuthorizable("g1");
-                if (a.isGroup()) {
-                    // the rep:members property must contain the invalid value
-                    boolean found = false;
-                    Node grNode = adminSession.getNode(a.getPath());
-                    for (Value memberValue : grNode.getProperty(UserConstants.REP_MEMBERS).getValues()) {
-                        assertEquals(PropertyType.WEAKREFERENCE, memberValue.getType());
-                        if (id.equals(memberValue.getString())) {
-                            found = true;
-                            break;
-                        }
-                    }
-                    assertTrue("ImportBehavior.BESTEFFORT must import non-existing members.",found);
-
-                    // declared members must not list the invalid entry.
-                    assertNotDeclaredMember((Group) a, id, adminSession);
-                } else {
-                    fail("'g1' was not imported as Group.");
-                }
-            } finally {
-                adminSession.refresh(false);
-            }
-        }
-    }
-
-    @Test
-    public void testImportNonExistingMemberBestEffort2() throws Exception {
-
-        String g1Id = "0120a4f9-196a-3f9e-b9f5-23f31f914da7";
-        String nonExistingId = "b2f5ff47-4366-31b6-a533-d8dc3614845d"; // groupId of 'g' group.
-        if (userMgr.getAuthorizable("g") != null) {
-            throw new NotExecutableException();
-        }
-        String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
-                "<sv:node sv:name=\"gFolder\" xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" xmlns:fn_old=\"http://www.w3.org/2004/10/xpath-functions\" xmlns:fn=\"http://www.w3.org/2005/xpath-functions\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" xmlns:rep=\"internal\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\">" +
-                "   <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:AuthorizableFolder</sv:value></sv:property>" +
-                "<sv:node sv:name=\"g1\"><sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:Group</sv:value></sv:property>" +
-                "   <sv:property sv:name=\"jcr:uuid\" sv:type=\"String\"><sv:value>" + g1Id + "</sv:value></sv:property>" +
-                "   <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>g1</sv:value></sv:property>" +
-                "   <sv:property sv:name=\"rep:members\" sv:type=\"WeakReference\"><sv:value>" +nonExistingId+ "</sv:value></sv:property>" +
-                "</sv:node>" +
-                "</sv:node>";
-
-        // BESTEFFORT behavior -> must import non-existing members.
-        doImport(GROUPPATH, xml);
-        Authorizable g1 = userMgr.getAuthorizable("g1");
-        if (g1.isGroup()) {
-            // the rep:members property must contain the invalid value
-            boolean found = false;
-            Node grNode = adminSession.getNode(g1.getPath());
-            for (Value memberValue : grNode.getProperty(UserConstants.REP_MEMBERS).getValues()) {
-                assertEquals(PropertyType.WEAKREFERENCE, memberValue.getType());
-                if (nonExistingId.equals(memberValue.getString())) {
-                    found = true;
-                    break;
-                }
-            }
-            assertTrue("ImportBehavior.BESTEFFORT must import non-existing members.",found);
-        } else {
-            fail("'g1' was not imported as Group.");
-        }
-    }
-
-    @Test
-    public void testImportCircularMembership() throws Exception {
-
-        String g1Id = "0120a4f9-196a-3f9e-b9f5-23f31f914da7";
-        String nonExistingId = "b2f5ff47-4366-31b6-a533-d8dc3614845d"; // groupId of 'g' group.
-        if (userMgr.getAuthorizable("g") != null) {
-            throw new NotExecutableException();
-        }
-
-        String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
-                "<sv:node sv:name=\"gFolder\" xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" xmlns:fn_old=\"http://www.w3.org/2004/10/xpath-functions\" xmlns:fn=\"http://www.w3.org/2005/xpath-functions\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" xmlns:rep=\"internal\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\">" +
-                "   <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:AuthorizableFolder</sv:value></sv:property>" +
-                "<sv:node sv:name=\"g1\"><sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:Group</sv:value></sv:property>" +
-                "   <sv:property sv:name=\"jcr:uuid\" sv:type=\"String\"><sv:value>" + g1Id + "</sv:value></sv:property>" +
-                "   <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>g1</sv:value></sv:property>" +
-                "   <sv:property sv:name=\"rep:members\" sv:type=\"WeakReference\"><sv:value>" +nonExistingId+ "</sv:value></sv:property>" +
-                "</sv:node>" +
-                "</sv:node>";
-
-        String xml2 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
-                "   <sv:node sv:name=\"g\" xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" xmlns:fn_old=\"http://www.w3.org/2004/10/xpath-functions\" xmlns:fn=\"http://www.w3.org/2005/xpath-functions\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" xmlns:rep=\"internal\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\">" +
-                "       <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:Group</sv:value></sv:property>" +
-                "       <sv:property sv:name=\"jcr:uuid\" sv:type=\"String\"><sv:value>" + nonExistingId + "</sv:value></sv:property>" +
-                "       <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>g</sv:value></sv:property>" +
-                "       <sv:property sv:name=\"rep:members\" sv:type=\"WeakReference\"><sv:value>" + g1Id + "</sv:value></sv:property>" +
-                "   </sv:node>";
-
-        // BESTEFFORT behavior -> must import non-existing members.
-        doImport(GROUPPATH, xml);
-
-        /*
-        now try to import the 'g' group that has a circular group
-        membership references.
-        expected:
-        - group is imported
-        - circular membership is ignored
-        - g is member of g1
-        - g1 isn't member of g
-        */
-        doImport(GROUPPATH + "/gFolder", xml2);
-
-        Authorizable g = userMgr.getAuthorizable("g");
-        assertNotNull(g);
-        if (g.isGroup()) {
-            assertNotDeclaredMember((Group) g, g1Id, adminSession);
-        } else {
-            fail("'g' was not imported as Group.");
-        }
+    @Override
+    protected String getTargetPath() {
+        return USERPATH;
     }
 
     @Test
@@ -195,10 +58,10 @@ public class UserImportBestEffortTest ex
                 "   <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>t</sv:value></sv:property>" +
                 "</sv:node>";
 
-        doImport(USERPATH, xml);
+        doImport(getTargetPath(), xml);
 
         // re-import should succeed if UUID-behavior is set accordingly
-        doImport(USERPATH, xml, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING);
+        doImport(getTargetPath(), xml, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING);
 
         // saving changes of the import -> must succeed. add mandatory
         // props should have been created.
@@ -219,11 +82,11 @@ public class UserImportBestEffortTest ex
                 "   <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>t</sv:value></sv:property>" +
                 "</sv:node>";
 
-        doImport(USERPATH, xml);
+        doImport(getTargetPath(), xml);
         adminSession.save();
 
         // re-import should succeed if UUID-behavior is set accordingly
-        doImport(USERPATH, xml, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING);
+        doImport(getTargetPath(), xml, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING);
 
         // saving changes of the import -> must succeed. add mandatory
         // props should have been created.
@@ -241,8 +104,8 @@ public class UserImportBestEffortTest ex
                 "</sv:node>";
 
         try {
-            doImport(USERPATH, xml);
-            doImport(USERPATH, xml, ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW);
+            doImport(getTargetPath(), xml);
+            doImport(getTargetPath(), xml, ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW);
             fail("UUID collision must be handled according to the uuid behavior.");
 
         } catch (ItemExistsException e) {
@@ -267,7 +130,7 @@ public class UserImportBestEffortTest ex
                 "   <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>g</sv:value></sv:property>" +
                 "</sv:node>" +
                 "</sv:node>";
-        doImport(USERPATH, xml);
+        doImport(getTargetPath(), xml);
 
         Authorizable newUser = userMgr.getAuthorizable("t");
         assertNotNull(newUser);
@@ -293,7 +156,7 @@ public class UserImportBestEffortTest ex
                 "   <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>t</sv:value></sv:property>" +
                 "   <sv:property sv:name=\"rep:impersonators\" sv:type=\"String\"><sv:value>" +principalName+ "</sv:value></sv:property>" +
                 "</sv:node>";
-        doImport(USERPATH, xml);
+        doImport(getTargetPath(), xml);
 
         Authorizable a = userMgr.getAuthorizable("t");
         assertFalse(a.isGroup());

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportIgnoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportIgnoreTest.java?rev=1507308&r1=1507307&r2=1507308&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportIgnoreTest.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportIgnoreTest.java Fri Jul 26 13:40:29 2013
@@ -18,19 +18,19 @@ package org.apache.jackrabbit.oak.jcr.se
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.UUID;
 import javax.security.auth.Subject;
 
-import com.google.common.collect.ImmutableList;
 import org.apache.jackrabbit.api.security.principal.PrincipalIterator;
 import org.apache.jackrabbit.api.security.user.Authorizable;
-import org.apache.jackrabbit.api.security.user.Group;
 import org.apache.jackrabbit.api.security.user.Impersonation;
 import org.apache.jackrabbit.api.security.user.User;
 import org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl;
 import org.apache.jackrabbit.oak.spi.xml.ImportBehavior;
 import org.junit.Test;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.fail;
+
 /**
  * Testing {@link ImportBehavior#IGNORE} for user/group import
  */
@@ -42,30 +42,8 @@ public class UserImportIgnoreTest extend
     }
 
     @Override
-    protected List<String> getPathsToRemove() {
-        return ImmutableList.of(GROUPPATH + "/gFolder", USERPATH + "/t");
-    }
-
-    @Test
-    public void testImportSelfAsGroupIgnore() throws Exception {
-        String invalidId = "0120a4f9-196a-3f9e-b9f5-23f31f914da7"; // uuid of the group itself
-        String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
-                "<sv:node sv:name=\"gFolder\" xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" xmlns:fn_old=\"http://www.w3.org/2004/10/xpath-functions\" xmlns:fn=\"http://www.w3.org/2005/xpath-functions\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" xmlns:rep=\"internal\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\">" +
-                "   <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:AuthorizableFolder</sv:value></sv:property>" +
-                "<sv:node sv:name=\"g1\"><sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:Group</sv:value></sv:property>" +
-                "   <sv:property sv:name=\"jcr:uuid\" sv:type=\"String\"><sv:value>"+invalidId+"</sv:value></sv:property>" +
-                "   <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>g1</sv:value></sv:property>" +
-                "   <sv:property sv:name=\"rep:members\" sv:type=\"WeakReference\"><sv:value>" +invalidId+ "</sv:value></sv:property>" +
-                "</sv:node>" +
-                "</sv:node>";
-        doImport(GROUPPATH, xml);
-        // no exception during import -> member must have been ignored though.
-        Authorizable a = userMgr.getAuthorizable("g1");
-        if (a.isGroup()) {
-            assertNotDeclaredMember((Group) a, invalidId, adminSession);
-        } else {
-            fail("'g1' was not imported as Group.");
-        }
+    protected String getTargetPath() {
+        return USERPATH;
     }
 
     @Test
@@ -83,11 +61,12 @@ public class UserImportIgnoreTest extend
                     "   <sv:property sv:name=\"rep:password\" sv:type=\"String\"><sv:value>{sha1}8efd86fb78a56a5145ed7739dcb00c78581c5375</sv:value></sv:property>" +
                     "   <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>t</sv:value></sv:property><sv:property sv:name=\"rep:impersonators\" sv:type=\"String\"><sv:value>" +principalName+ "</sv:value></sv:property>" +
                     "</sv:node>";
+
             Subject subj = new Subject();
             subj.getPrincipals().add(new PrincipalImpl(principalName));
 
             try {
-                doImport(USERPATH, xml);
+                doImport(getTargetPath(), xml);
                 // no exception during import: no impersonation must be granted
                 // for the invalid principal name
                 Authorizable a = userMgr.getAuthorizable("t");
@@ -107,36 +86,4 @@ public class UserImportIgnoreTest extend
             }
         }
     }
-
-    @Test
-    public void testImportNonExistingMemberIgnore() throws Exception {
-        List<String> invalid = new ArrayList<String>();
-        invalid.add(UUID.randomUUID().toString()); // random uuid
-        invalid.add(getExistingUUID()); // uuid of non-authorizable node
-
-        for (String id : invalid) {
-            String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
-                    "<sv:node sv:name=\"gFolder\" xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" xmlns:fn_old=\"http://www.w3.org/2004/10/xpath-functions\" xmlns:fn=\"http://www.w3.org/2005/xpath-functions\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" xmlns:rep=\"internal\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\">" +
-                    "   <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:AuthorizableFolder</sv:value></sv:property>" +
-                        "<sv:node sv:name=\"g1\"><sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:Group</sv:value></sv:property>" +
-                        "   <sv:property sv:name=\"jcr:uuid\" sv:type=\"String\"><sv:value>0120a4f9-196a-3f9e-b9f5-23f31f914da7</sv:value></sv:property>" +
-                        "   <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>g1</sv:value></sv:property>" +
-                        "   <sv:property sv:name=\"rep:members\" sv:type=\"WeakReference\"><sv:value>" +id+ "</sv:value></sv:property>" +
-                        "</sv:node>" +
-                    "</sv:node>";
-            try {
-                // there should be no exception during import,
-                // but invalid members must be ignored.
-                doImport(GROUPPATH, xml);
-                Authorizable a = userMgr.getAuthorizable("g1");
-                if (a.isGroup()) {
-                    assertNotDeclaredMember((Group) a, id, adminSession);
-                } else {
-                    fail("'g1' was not imported as Group.");
-                }
-            } finally {
-                adminSession.refresh(false);
-            }
-        }
-    }
 }

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportTest.java?rev=1507308&r1=1507307&r2=1507308&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportTest.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportTest.java Fri Jul 26 13:40:29 2013
@@ -18,47 +18,40 @@ package org.apache.jackrabbit.oak.jcr.se
 
 import java.security.Principal;
 import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedList;
 import java.util.List;
 import javax.jcr.ImportUUIDBehavior;
 import javax.jcr.ItemExistsException;
 import javax.jcr.Node;
-import javax.jcr.NodeIterator;
 import javax.jcr.RepositoryException;
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.security.auth.Subject;
 
-import com.google.common.collect.ImmutableList;
 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.AuthorizableExistsException;
-import org.apache.jackrabbit.api.security.user.Group;
 import org.apache.jackrabbit.api.security.user.Impersonation;
 import org.apache.jackrabbit.api.security.user.User;
 import org.apache.jackrabbit.oak.spi.security.user.UserConstants;
 import org.apache.jackrabbit.test.NotExecutableException;
 import org.junit.Test;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 /**
- * Testing user/group import with default {@link org.apache.jackrabbit.oak.spi.xml.ImportBehavior}
+ * Testing user import with default {@link org.apache.jackrabbit.oak.spi.xml.ImportBehavior}
  */
 public class UserImportTest extends AbstractImportTest {
 
     @Override
-    protected List<String> getPathsToRemove() {
-        return ImmutableList.of(
-                USERPATH + "/t",
-                USERPATH + "/r",
-                USERPATH + "/uFolder",
-                USERPATH + "/some",
-                USERPATH + "/g",
-                USERPATH + "/t_diff",
-                GROUPPATH + "/g",
-                GROUPPATH + "/s",
-                GROUPPATH + "/gFolder");
+    protected String getTargetPath() {
+        return USERPATH;
     }
 
     @Override
@@ -77,8 +70,8 @@ public class UserImportTest extends Abst
                 "   <sv:property sv:name=\"rep:disabled\" sv:type=\"String\"><sv:value>disabledUser</sv:value></sv:property>" +
                 "</sv:node>";
 
-        Node target = adminSession.getNode(USERPATH);
-        doImport(USERPATH, xml);
+        Node target = getTargetNode();
+        doImport(getTargetPath(), xml);
 
         assertTrue(target.isModified());
         assertTrue(adminSession.hasPendingChanges());
@@ -105,39 +98,6 @@ public class UserImportTest extends Abst
         adminSession.save();
     }
 
-    @Test
-    public void testImportGroup() throws Exception {
-        String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
-                "<sv:node sv:name=\"g\" xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" xmlns:fn_old=\"http://www.w3.org/2004/10/xpath-functions\" xmlns:fn=\"http://www.w3.org/2005/xpath-functions\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" xmlns:rep=\"internal\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\">" +
-                "   <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:Group</sv:value></sv:property>" +
-                "   <sv:property sv:name=\"jcr:uuid\" sv:type=\"String\"><sv:value>b2f5ff47-4366-31b6-a533-d8dc3614845d</sv:value></sv:property>" +
-                "   <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>g</sv:value></sv:property>" +
-                "</sv:node>";
-
-        Node target = adminSession.getNode(GROUPPATH);
-        doImport(GROUPPATH, xml);
-
-        assertTrue(target.isModified());
-        assertTrue(adminSession.hasPendingChanges());
-
-        Authorizable newGroup = userMgr.getAuthorizable("g");
-        assertNotNull(newGroup);
-        assertTrue(newGroup.isGroup());
-        assertEquals("g", newGroup.getPrincipal().getName());
-        assertEquals("g", newGroup.getID());
-
-        Node n = adminSession.getNode(newGroup.getPath());
-        assertTrue(n.isNew());
-        assertTrue(n.getParent().isSame(target));
-
-        assertEquals("g", n.getName());
-        assertEquals("g", n.getProperty(UserConstants.REP_PRINCIPAL_NAME).getString());
-
-        // saving changes of the import -> must succeed. add mandatory
-        // props should have been created.
-        adminSession.save();
-    }
-
     /**
      * @since OAK 1.0 : constraintviolation is no longer detected during import
      *        but only upon save.
@@ -159,8 +119,8 @@ public class UserImportTest extends Abst
          - saving changes must fail with ConstraintViolationEx.
          */
 
-        Node target = adminSession.getNode(USERPATH);
-        doImport(USERPATH, xml);
+        Node target = getTargetNode();
+        doImport(getTargetPath(), xml);
 
         assertTrue(target.isModified());
         assertTrue(adminSession.hasPendingChanges());
@@ -186,7 +146,6 @@ public class UserImportTest extends Abst
         // authorizable.
         //String calculatedUUID = "e358efa4-89f5-3062-b10d-d7316b65649e";
         String mismatchUUID = "a358efa4-89f5-3062-b10d-d7316b65649e";
-
         String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
                 "<sv:node sv:name=\"t\" xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" xmlns:fn_old=\"http://www.w3.org/2004/10/xpath-functions\" xmlns:fn=\"http://www.w3.org/2005/xpath-functions\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" xmlns:rep=\"internal\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\">" +
                 "   <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:User</sv:value></sv:property>" +
@@ -194,8 +153,8 @@ public class UserImportTest extends Abst
                 "   <sv:property sv:name=\"rep:password\" sv:type=\"String\"><sv:value>{sha1}8efd86fb78a56a5145ed7739dcb00c78581c5375</sv:value></sv:property>" +
                 "   <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>t</sv:value></sv:property></sv:node>";
 
-        Node target = adminSession.getNode(USERPATH);
-        doImport(USERPATH, xml);
+        Node target = getTargetNode();
+        doImport(getTargetPath(), xml);
 
         assertTrue(target.isModified());
         assertTrue(adminSession.hasPendingChanges());
@@ -235,36 +194,7 @@ public class UserImportTest extends Abst
                 "</sv:node>";
 
         try {
-            doImport(USERPATH, xml);
-            adminSession.save();
-
-            fail("Import must detect conflicting principals.");
-        } catch (RepositoryException e) {
-            // success
-        }
-    }
-
-    @Test
-    public void testConflictingPrincipalsWithinImport() throws Exception {
-        String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
-                "<sv:node sv:name=\"gFolder\" xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" xmlns:fn_old=\"http://www.w3.org/2004/10/xpath-functions\" xmlns:fn=\"http://www.w3.org/2005/xpath-functions\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" xmlns:rep=\"internal\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\">" +
-                "<sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\">" +
-                "   <sv:value>rep:AuthorizableFolder</sv:value>" +
-                "</sv:property>" +
-                "<sv:node sv:name=\"g\" xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" xmlns:fn_old=\"http://www.w3.org/2004/10/xpath-functions\" xmlns:fn=\"http://www.w3.org/2005/xpath-functions\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" xmlns:rep=\"internal\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\">" +
-                "   <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:Group</sv:value></sv:property>" +
-                "   <sv:property sv:name=\"jcr:uuid\" sv:type=\"String\"><sv:value>b2f5ff47-4366-31b6-a533-d8dc3614845d</sv:value></sv:property>" +
-                "   <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>g</sv:value></sv:property>" +
-                "</sv:node>" +
-                "<sv:node sv:name=\"g1\" xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" xmlns:fn_old=\"http://www.w3.org/2004/10/xpath-functions\" xmlns:fn=\"http://www.w3.org/2005/xpath-functions\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" xmlns:rep=\"internal\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\">" +
-                "   <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:Group</sv:value></sv:property>" +
-                "   <sv:property sv:name=\"jcr:uuid\" sv:type=\"String\"><sv:value>0120a4f9-196a-3f9e-b9f5-23f31f914da7</sv:value></sv:property>" +
-                "   <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>g</sv:value></sv:property>" +
-                "</sv:node>" +
-                "</sv:node>";
-
-        try {
-            doImport(GROUPPATH, xml);
+            doImport(getTargetPath(), xml);
             adminSession.save();
 
             fail("Import must detect conflicting principals.");
@@ -274,43 +204,6 @@ public class UserImportTest extends Abst
     }
 
     @Test
-    public void testMultiValuedPrincipalName() throws Exception {
-        String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
-                "<sv:node sv:name=\"g\" xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" xmlns:fn_old=\"http://www.w3.org/2004/10/xpath-functions\" xmlns:fn=\"http://www.w3.org/2005/xpath-functions\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" xmlns:rep=\"internal\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\">" +
-                "   <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:Group</sv:value></sv:property>" +
-                "   <sv:property sv:name=\"jcr:uuid\" sv:type=\"String\"><sv:value>b2f5ff47-4366-31b6-a533-d8dc3614845d</sv:value></sv:property>" +
-                "   <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>g</sv:value><sv:value>g2</sv:value><sv:value>g</sv:value></sv:property></sv:node>";
-
-        /*
-         importing a group with a multi-valued rep:principalName property
-         - nonProtected node rep:Group must be created.
-         - property rep:principalName must be created regularly without being protected
-         - saving changes must fail with ConstraintViolationEx. as the protected
-           mandatory property rep:principalName is missing
-         */
-        Node target = adminSession.getNode(GROUPPATH);
-        doImport(GROUPPATH, xml);
-
-        assertTrue(target.isModified());
-        assertTrue(adminSession.hasPendingChanges());
-
-        Authorizable newGroup = userMgr.getAuthorizable("g");
-        assertNotNull(newGroup);
-
-        assertTrue(target.hasNode("g"));
-        assertTrue(target.hasProperty("g/rep:principalName"));
-        assertFalse(target.getProperty("g/rep:principalName").getDefinition().isProtected());
-
-        // saving changes of the import -> must fail as mandatory prop is missing
-        try {
-            adminSession.save();
-            fail("Import must be incomplete. Saving changes must fail.");
-        } catch (ConstraintViolationException e) {
-            // success
-        }
-    }
-
-    @Test
     public void testPlainTextPassword() throws Exception {
         String plainPw = "myPassword";
         String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
@@ -321,8 +214,8 @@ public class UserImportTest extends Abst
                 "   <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>t</sv:value></sv:property>" +
                 "</sv:node>";
 
-        Node target = adminSession.getNode(USERPATH);
-        doImport(USERPATH, xml);
+        Node target = getTargetNode();
+        doImport(getTargetPath(), xml);
 
         assertTrue(target.isModified());
         assertTrue(adminSession.hasPendingChanges());
@@ -354,8 +247,8 @@ public class UserImportTest extends Abst
          - nonProtected node rep:User must be created.
          - property rep:password must be created regularly without being protected
          */
-        Node target = adminSession.getNode(USERPATH);
-        doImport(USERPATH, xml);
+        Node target = getTargetNode();
+        doImport(getTargetPath(), xml);
 
         assertTrue(target.isModified());
         assertTrue(adminSession.hasPendingChanges());
@@ -384,9 +277,9 @@ public class UserImportTest extends Abst
                 "</sv:node>");
 
         for (String xml : incompleteXml) {
-            Node target = adminSession.getNode(USERPATH);
+            Node target = adminSession.getNode(getTargetPath());
             try {
-                doImport(USERPATH, xml);
+                doImport(getTargetPath(), xml);
                 // saving changes of the import -> must fail as mandatory prop is missing
                 try {
                     adminSession.save();
@@ -416,7 +309,7 @@ public class UserImportTest extends Abst
                 "   <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>t</sv:value></sv:property>" +
                 "</sv:node>";
 
-        doImport(USERPATH, xml);
+        doImport(getTargetPath(), xml);
 
         Authorizable user = userMgr.getAuthorizable("t");
         assertNotNull(user);
@@ -425,28 +318,6 @@ public class UserImportTest extends Abst
     }
 
     @Test
-    public void testIncompleteGroup() throws Exception {
-        String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
-                "<sv:node sv:name=\"g\" xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" xmlns:fn_old=\"http://www.w3.org/2004/10/xpath-functions\" xmlns:fn=\"http://www.w3.org/2005/xpath-functions\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" xmlns:rep=\"internal\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\">" +
-                "   <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:Group</sv:value></sv:property>" +
-                "   <sv:property sv:name=\"jcr:uuid\" sv:type=\"String\"><sv:value>b2f5ff47-4366-31b6-a533-d8dc3614845d</sv:value></sv:property>" +
-                "</sv:node>";
-
-        /*
-         importing a group without rep:principalName property
-         - saving changes must fail with ConstraintViolationEx.
-         */
-        doImport(GROUPPATH, xml);
-        // saving changes of the import -> must fail as mandatory prop is missing
-        try {
-            adminSession.save();
-            fail("Import must be incomplete. Saving changes must fail.");
-        } catch (ConstraintViolationException e) {
-            // success
-        }
-    }
-
-    @Test
     public void testImportWithIntermediatePath() throws Exception {
         String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                 "<sv:node sv:name=\"some\" xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" xmlns:fn_old=\"http://www.w3.org/2004/10/xpath-functions\" xmlns:fn=\"http://www.w3.org/2005/xpath-functions\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" xmlns:rep=\"internal\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\">" +
@@ -468,8 +339,8 @@ public class UserImportTest extends Abst
                 "</sv:node>" +
                 "</sv:node>";
 
-        Node target = adminSession.getNode(USERPATH);
-        doImport(USERPATH, xml);
+        Node target = getTargetNode();
+        doImport(getTargetPath(), xml);
 
         assertTrue(target.isModified());
         assertTrue(adminSession.hasPendingChanges());
@@ -493,113 +364,6 @@ public class UserImportTest extends Abst
     }
 
     @Test
-    public void testImportNewMembers() throws Exception {
-        String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
-                "<sv:node sv:name=\"gFolder\" xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" xmlns:fn_old=\"http://www.w3.org/2004/10/xpath-functions\" xmlns:fn=\"http://www.w3.org/2005/xpath-functions\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" xmlns:rep=\"internal\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\">" +
-                "<sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\">" +
-                "   <sv:value>rep:AuthorizableFolder</sv:value>" +
-                "</sv:property>" +
-                "<sv:node sv:name=\"g\">" +
-                "   <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:Group</sv:value></sv:property>" +
-                "   <sv:property sv:name=\"jcr:uuid\" sv:type=\"String\"><sv:value>b2f5ff47-4366-31b6-a533-d8dc3614845d</sv:value></sv:property>" +
-                "   <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>g</sv:value></sv:property>" +
-                "</sv:node>" +
-                "<sv:node sv:name=\"g1\">" +
-                "   <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:Group</sv:value></sv:property>" +
-                "   <sv:property sv:name=\"jcr:uuid\" sv:type=\"String\"><sv:value>0120a4f9-196a-3f9e-b9f5-23f31f914da7</sv:value></sv:property>" +
-                "   <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>g1</sv:value></sv:property>" +
-                "   <sv:property sv:name=\"rep:members\" sv:type=\"WeakReference\"><sv:value>b2f5ff47-4366-31b6-a533-d8dc3614845d</sv:value></sv:property>" +
-                "</sv:node>" +
-                "</sv:node>";
-
-        doImport(GROUPPATH, xml);
-
-        Group g = (Group) userMgr.getAuthorizable("g");
-        assertNotNull(g);
-        Group g1 = (Group) userMgr.getAuthorizable("g1");
-        assertNotNull(g1);
-
-        Node n = adminSession.getNode(g1.getPath());
-        assertTrue(n.hasProperty(UserConstants.REP_MEMBERS) || n.hasNode(UserConstants.NT_REP_MEMBERS));
-
-        // getWeakReferences only works upon save.
-        adminSession.save();
-
-        assertTrue(g1.isMember(g));
-    }
-
-    @Test
-    public void testImportNewMembersReverseOrder() throws Exception {
-        // group is imported before the member
-        String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
-                "<sv:node sv:name=\"gFolder\" xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" xmlns:fn_old=\"http://www.w3.org/2004/10/xpath-functions\" xmlns:fn=\"http://www.w3.org/2005/xpath-functions\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" xmlns:rep=\"internal\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\">" +
-                "   <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:AuthorizableFolder</sv:value></sv:property>" +
-                "   <sv:node sv:name=\"g1\">" +
-                "       <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:Group</sv:value></sv:property>" +
-                "       <sv:property sv:name=\"jcr:uuid\" sv:type=\"String\"><sv:value>0120a4f9-196a-3f9e-b9f5-23f31f914da7</sv:value></sv:property>" +
-                "       <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>g1</sv:value></sv:property>" +
-                "       <sv:property sv:name=\"rep:members\" sv:type=\"WeakReference\"><sv:value>b2f5ff47-4366-31b6-a533-d8dc3614845d</sv:value></sv:property>" +
-                "   </sv:node>" +
-                "   <sv:node sv:name=\"g\">" +
-                "       <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:Group</sv:value></sv:property>" +
-                "       <sv:property sv:name=\"jcr:uuid\" sv:type=\"String\"><sv:value>b2f5ff47-4366-31b6-a533-d8dc3614845d</sv:value></sv:property>" +
-                "       <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>g</sv:value></sv:property>" +
-                "   </sv:node>" +
-                "</sv:node>";
-
-        doImport(GROUPPATH, xml);
-
-        Group g = (Group) userMgr.getAuthorizable("g");
-        assertNotNull(g);
-        Group g1 = (Group) userMgr.getAuthorizable("g1");
-        assertNotNull(g1);
-
-        Node n = adminSession.getNode(g1.getPath());
-        assertTrue(n.hasProperty(UserConstants.REP_MEMBERS) || n.hasNode(UserConstants.NT_REP_MEMBERS));
-
-        // getWeakReferences only works upon save.
-        adminSession.save();
-
-        assertTrue(g1.isMember(g));
-    }
-
-    @Test
-    public void testImportMembers() throws Exception {
-        Authorizable admin = userMgr.getAuthorizable("admin");
-        if (admin == null) {
-            throw new NotExecutableException();
-        }
-
-        String uuid = adminSession.getNode(admin.getPath()).getUUID();
-        String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
-                "<sv:node sv:name=\"gFolder\" xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" xmlns:fn_old=\"http://www.w3.org/2004/10/xpath-functions\" xmlns:fn=\"http://www.w3.org/2005/xpath-functions\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" xmlns:rep=\"internal\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\">" +
-                "   <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:AuthorizableFolder</sv:value></sv:property>" +
-                "   <sv:node sv:name=\"g1\">" +
-                "       <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:Group</sv:value></sv:property>" +
-                "       <sv:property sv:name=\"jcr:uuid\" sv:type=\"String\"><sv:value>0120a4f9-196a-3f9e-b9f5-23f31f914da7</sv:value></sv:property>" +
-                "       <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>g1</sv:value></sv:property>" +
-                "       <sv:property sv:name=\"rep:members\" sv:type=\"WeakReference\"><sv:value>" + uuid + "</sv:value></sv:property>" +
-                "   </sv:node>" +
-                "</sv:node>";
-
-        doImport(GROUPPATH, xml);
-
-        Group g1 = (Group) userMgr.getAuthorizable("g1");
-        assertNotNull(g1);
-
-        // getWeakReferences only works upon save.
-        adminSession.save();
-
-        assertTrue(g1.isMember(admin));
-
-        boolean found = false;
-        for (Iterator<Group> it = admin.declaredMemberOf(); it.hasNext() && !found; ) {
-            found = "g1".equals(it.next().getID());
-        }
-        assertTrue(found);
-    }
-
-    @Test
     public void testImportImpersonation() throws Exception {
         String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
                 "<sv:node sv:name=\"uFolder\" xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" xmlns:fn_old=\"http://www.w3.org/2004/10/xpath-functions\" xmlns:fn=\"http://www.w3.org/2005/xpath-functions\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" xmlns:rep=\"internal\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\">" +
@@ -617,7 +381,7 @@ public class UserImportTest extends Abst
                 "</sv:node>" +
                 "</sv:node>";
 
-        doImport(USERPATH, xml);
+        doImport(getTargetPath(), xml);
 
         Authorizable newUser = userMgr.getAuthorizable("t");
         assertNotNull(newUser);
@@ -642,10 +406,10 @@ public class UserImportTest extends Abst
                 "   <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>t</sv:value></sv:property>" +
                 "</sv:node>";
 
-        doImport(USERPATH, xml);
+        doImport(getTargetPath(), xml);
 
         // re-import should succeed if UUID-behavior is set accordingly
-        doImport(USERPATH, xml, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING);
+        doImport(getTargetPath(), xml, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING);
 
         // saving changes of the import -> must succeed. add mandatory
         // props should have been created.
@@ -667,11 +431,11 @@ public class UserImportTest extends Abst
                 "   <sv:property sv:name=\"rep:password\" sv:type=\"String\"><sv:value>{sha1}8efd86fb78a56a5145ed7739dcb00c78581c5375</sv:value></sv:property>" +
                 "   <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>t</sv:value></sv:property>" +
                 "</sv:node>";
-        doImport(USERPATH, xml);
+        doImport(getTargetPath(), xml);
         adminSession.save();
 
         // re-import should succeed if UUID-behavior is set accordingly
-        doImport(USERPATH, xml, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING);
+        doImport(getTargetPath(), xml, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING);
 
         // saving changes of the import -> must succeed. add mandatory
         // props should have been created.
@@ -689,8 +453,8 @@ public class UserImportTest extends Abst
                 "</sv:node>";
 
         try {
-            doImport(USERPATH, xml);
-            doImport(USERPATH, xml, ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW);
+            doImport(getTargetPath(), xml);
+            doImport(getTargetPath(), xml, ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW);
             fail("UUID collision must be handled according to the uuid behavior.");
 
         } catch (ItemExistsException e) {
@@ -698,93 +462,6 @@ public class UserImportTest extends Abst
         }
     }
 
-    @Test
-    public void testImportGroupMembersFromNodes() throws Exception {
-        String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
-                "<sv:node sv:name=\"s\" xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" xmlns:sling=\"http://sling.apache.org/jcr/sling/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" xmlns:fn_old=\"http://www.w3.org/2004/10/xpath-functions\" xmlns:fn=\"http://www.w3.org/2005/xpath-functions\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\" xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" xmlns:rep=\"internal\">" +
-                "  <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:AuthorizableFolder</sv:value></sv:property>" +
-                "  <sv:property sv:name=\"jcr:created\" sv:type=\"Date\"><sv:value>2010-08-17T18:22:20.086+02:00</sv:value></sv:property>" +
-                "  <sv:property sv:name=\"jcr:createdBy\" sv:type=\"String\"><sv:value>admin</sv:value></sv:property>" +
-                "  <sv:node sv:name=\"sh\">" +
-                "     <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:AuthorizableFolder</sv:value></sv:property>" +
-                "     <sv:property sv:name=\"jcr:created\" sv:type=\"Date\"><sv:value>2010-08-17T18:22:20.086+02:00</sv:value></sv:property>" +
-                "     <sv:property sv:name=\"jcr:createdBy\" sv:type=\"String\"><sv:value>admin</sv:value></sv:property>" +
-                "     <sv:node sv:name=\"shrimps\">" +
-                "        <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:Group</sv:value></sv:property>" +
-                "        <sv:property sv:name=\"jcr:uuid\" sv:type=\"String\"><sv:value>08429aec-6f09-30db-8c83-1a2a57fc760c</sv:value></sv:property>" +
-                "        <sv:property sv:name=\"jcr:created\" sv:type=\"Date\"><sv:value>2010-08-17T18:22:20.086+02:00</sv:value></sv:property>" +
-                "        <sv:property sv:name=\"jcr:createdBy\" sv:type=\"String\"><sv:value>admin</sv:value></sv:property>" +
-                "        <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>shrimps</sv:value></sv:property>" +
-                "        <sv:node sv:name=\"rep:members\">" +
-                "           <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:Members</sv:value></sv:property>" +
-                "           <sv:node sv:name=\"adi\">" +
-                "              <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:Members</sv:value></sv:property>" +
-                "              <sv:node sv:name=\"adi\">" +
-                "                 <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:Members</sv:value></sv:property>" +
-                "                 <sv:property sv:name=\"adi\" sv:type=\"WeakReference\"><sv:value>c46335eb-267e-3e1c-9e5b-017acb4cd799</sv:value></sv:property>" +
-                "                 <sv:property sv:name=\"admin\" sv:type=\"WeakReference\"><sv:value>21232f29-7a57-35a7-8389-4a0e4a801fc3</sv:value></sv:property>" +
-                "              </sv:node>" +
-                "              <sv:node sv:name=\"angi\"><sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:Members</sv:value></sv:property><sv:property sv:name=\"angi\" sv:type=\"WeakReference\"><sv:value>a468b64f-b1df-377c-b325-20d97aaa1ad9</sv:value></sv:property><sv:property sv:name=\"anonymous\" sv:type=\"WeakReference\"><sv:value>294de355-7d9d-30b3-92d8-a1e6aab028cf</sv:value></sv:property><sv:property sv:name=\"cati\" sv:type=\"WeakReference\"><sv:value>f08910b6-41c8-3cb9-a648-1dddd14b132d</sv:value></sv:property></sv:node></sv:node>" +
-                "              <sv:node sv:name=\"debbi\"><sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:Members</sv:value></sv:property><sv:node sv:name=\"debbi\"><sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:Members</sv:value></sv:property><sv:property sv:name=\"debbi\" sv:type=\"WeakReference\"><sv:value>d53bedf9-ebb8-3117-a8b8-162d32b4bee2</sv:value></sv:property><sv:property sv:name=\"eddi\" sv:type=\"WeakReference\"><sv:value>1795fa1a-3d20-3a64-996e-eaaeb520a01e</sv:value></sv:property><sv:property sv:name=\"gabi\" sv:type=\"WeakReference\"><sv:value>a0d499c7-5105-3663-8611-a32779a57104</sv:value></sv:property><sv:property sv:name=\"hansi\" sv:type=\"WeakReference\"><sv:value>9ea4d671-8ed1-399a-8401-59487a14d00a</sv:value></sv:property></sv:node><sv:node sv:name=\"hari\"><sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:Members</sv:value></sv:property><sv:property sv:name=\"hari\" sv:type=\"WeakReference\
 "><sv:value>a9bcf1e4-d7b9-3a22-a297-5c812d938889</sv:value></sv:property><sv:property sv:name=\"lisi\" sv:type=\"WeakReference\"><sv:value>dc3a8f16-70d6-3bea-a9b7-b65048a0ac40</sv:value></sv:property></sv:node><sv:node sv:name=\"luzi\"><sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:Members</sv:value></sv:property><sv:property sv:name=\"luzi\" sv:type=\"WeakReference\"><sv:value>9ec299fd-3461-3f1a-9749-92a76f2516eb</sv:value></sv:property><sv:property sv:name=\"pipi\" sv:type=" +
-                "\"WeakReference\"><sv:value>16d5d24f-5b09-3199-9bd4-e5f57bf11237</sv:value></sv:property><sv:property sv:name=\"susi\" sv:type=\"WeakReference\"><sv:value>536931d8-0dec-318c-b3db-9612bdd004d4</sv:value></sv:property>" +
-                "              </sv:node>" +
-                "           </sv:node>" +
-                "        </sv:node>" +
-                "     </sv:node>" +
-                "   </sv:node>" +
-                "</sv:node>";
-
-        List<String> createdUsers = new LinkedList<String>();
-        Node target = adminSession.getNode(GROUPPATH);
-        try {
-            String[] users = {"angi", "adi", "hansi", "lisi", "luzi", "susi", "pipi", "hari", "gabi", "eddi",
-                    "debbi", "cati", "admin", "anonymous"};
-
-            for (String user : users) {
-                if (userMgr.getAuthorizable(user) == null) {
-                    userMgr.createUser(user, user);
-                    createdUsers.add(user);
-                }
-            }
-            if (!userMgr.isAutoSave()) {
-                adminSession.save();
-            }
-
-            doImport(GROUPPATH, xml);
-            if (!userMgr.isAutoSave()) {
-                adminSession.save();
-            }
-
-            Authorizable aShrimps = userMgr.getAuthorizable("shrimps");
-            assertNotNull(aShrimps);
-            assertTrue(aShrimps.isGroup());
-
-            Group gShrimps = (Group) aShrimps;
-            for (String user : users) {
-                assertTrue(user + " should be member of " + gShrimps, gShrimps.isMember(userMgr.getAuthorizable(user)));
-            }
-
-
-        } finally {
-            adminSession.refresh(false);
-            for (String user : createdUsers) {
-                Authorizable a = userMgr.getAuthorizable(user);
-                if (a != null && !a.isGroup()) {
-                    a.remove();
-                }
-            }
-            if (!userMgr.isAutoSave()) {
-                adminSession.save();
-            }
-            for (NodeIterator it = target.getNodes(); it.hasNext(); ) {
-                it.nextNode().remove();
-            }
-            if (!userMgr.isAutoSave()) {
-                adminSession.save();
-            }
-        }
-    }
-
     /**
      * @since OAK 1.0 : Importing rep:authorizableId
      */
@@ -799,7 +476,7 @@ public class UserImportTest extends Abst
                 "   <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>t</sv:value></sv:property>" +
                 "</sv:node>";
 
-        doImport(USERPATH, xml);
+        doImport(getTargetPath(), xml);
 
         Authorizable newUser = userMgr.getAuthorizable("t");
         assertNotNull(newUser);
@@ -814,31 +491,6 @@ public class UserImportTest extends Abst
      * @since OAK 1.0 : Importing rep:authorizableId
      */
     @Test
-    public void testImportGroupWithAuthorizableId() throws Exception {
-        String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
-                "<sv:node sv:name=\"g\" xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" xmlns:fn_old=\"http://www.w3.org/2004/10/xpath-functions\" xmlns:fn=\"http://www.w3.org/2005/xpath-functions\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" xmlns:rep=\"internal\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\">" +
-                "   <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:Group</sv:value></sv:property>" +
-                "   <sv:property sv:name=\"jcr:uuid\" sv:type=\"String\"><sv:value>b2f5ff47-4366-31b6-a533-d8dc3614845d</sv:value></sv:property>" +
-                "   <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>g</sv:value></sv:property>" +
-                "   <sv:property sv:name=\"rep:authorizableId\" sv:type=\"String\"><sv:value>g</sv:value></sv:property>" +
-                "</sv:node>";
-
-        doImport(GROUPPATH, xml);
-
-        Authorizable newGroup = userMgr.getAuthorizable("g");
-        assertNotNull(newGroup);
-        assertTrue(newGroup.isGroup());
-        assertEquals("g", newGroup.getID());
-        assertTrue(adminSession.propertyExists(newGroup.getPath() + "/rep:authorizableId"));
-        assertEquals("g", adminSession.getProperty(newGroup.getPath() + "/rep:authorizableId").getString());
-
-        adminSession.save();
-    }
-
-    /**
-     * @since OAK 1.0 : Importing rep:authorizableId
-     */
-    @Test
     public void testImportUserWithIdDifferentFromNodeName() throws Exception {
         String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                 "<sv:node sv:name=\"t_diff\" xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" xmlns:fn_old=\"http://www.w3.org/2004/10/xpath-functions\" xmlns:fn=\"http://www.w3.org/2005/xpath-functions\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" xmlns:rep=\"internal\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\">" +
@@ -849,7 +501,7 @@ public class UserImportTest extends Abst
                 "   <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>t</sv:value></sv:property>" +
                 "</sv:node>";
 
-        doImport(USERPATH, xml);
+        doImport(getTargetPath(), xml);
 
         Authorizable newUser = userMgr.getAuthorizable("t");
 
@@ -877,7 +529,7 @@ public class UserImportTest extends Abst
                 "   <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>t</sv:value></sv:property>" +
                 "   <sv:property sv:name=\"rep:authorizableId\" sv:type=\"String\"><sv:value>t</sv:value></sv:property>" +
                 "</sv:node>";
-        doImport(USERPATH, xml);
+        doImport(getTargetPath(), xml);
 
         Authorizable newUser = userMgr.getAuthorizable("t");
 
@@ -904,7 +556,7 @@ public class UserImportTest extends Abst
                 "   <sv:property sv:name=\"rep:authorizableId\" sv:type=\"String\"><sv:value>" + existingId + "</sv:value></sv:property>" +
                 "</sv:node>";
         try {
-            doImport(USERPATH, xml);
+            doImport(getTargetPath(), xml);
             fail("Reuse of existing ID must be detected.");
         } catch (AuthorizableExistsException e) {
             // success
@@ -936,7 +588,7 @@ public class UserImportTest extends Abst
                 "</sv:node>" +
                 "</sv:node>";
         try {
-            doImport(USERPATH, xml);
+            doImport(getTargetPath(), xml);
             fail("Reuse of existing ID must be detected.");
         } catch (AuthorizableExistsException e) {
             // success



Mime
View raw message