jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r1545967 - in /jackrabbit/commons/filevault/trunk: parent/ vault-core/ vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/impl/ vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/
Date Wed, 27 Nov 2013 09:04:59 GMT
Author: tripod
Date: Wed Nov 27 09:04:59 2013
New Revision: 1545967

URL: http://svn.apache.org/r1545967
Log:
Fix failing tests with oak

Modified:
    jackrabbit/commons/filevault/trunk/parent/pom.xml
    jackrabbit/commons/filevault/trunk/vault-core/pom.xml
    jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/impl/AdminPermissionCheckerTest.java
    jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageManagerImplTest.java
    jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/DumpCoverageTests.java
    jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/IntegrationTestBase.java
    jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestGroupMergePackage.java

Modified: jackrabbit/commons/filevault/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/parent/pom.xml?rev=1545967&r1=1545966&r2=1545967&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/parent/pom.xml (original)
+++ jackrabbit/commons/filevault/trunk/parent/pom.xml Wed Nov 27 09:04:59 2013
@@ -304,6 +304,22 @@
     <!-- P R O F I L E S                                                        -->
     <!-- ====================================================================== -->
     <profiles>
+        <profile>
+            <id>oak</id>
+            <properties>
+                <jackrabbit.version>2.7.2</jackrabbit.version>
+                <oak.version>0.13-SNAPSHOT</oak.version>
+            </properties>
+            <dependencyManagement>
+                <dependencies>
+                    <dependency>
+                        <groupId>org.apache.jackrabbit</groupId>
+                        <artifactId>oak-run</artifactId>
+                        <version>${oak.version}</version>
+                    </dependency>
+                </dependencies>
+            </dependencyManagement>
+        </profile>
     </profiles>
 
 </project>

Modified: jackrabbit/commons/filevault/trunk/vault-core/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/pom.xml?rev=1545967&r1=1545966&r2=1545967&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/pom.xml (original)
+++ jackrabbit/commons/filevault/trunk/vault-core/pom.xml Wed Nov 27 09:04:59 2013
@@ -110,30 +110,7 @@
                     </instructions>
                 </configuration>
             </plugin>
-
-            <plugin>
-                <artifactId>maven-surefire-plugin</artifactId>
-                <executions>
-                    <!-- run tests 2 second time on jackrabbit oak -->
-                    <execution>
-                        <id>oak</id>
-                        <goals>
-                            <goal>test</goal>
-                        </goals>
-                        <configuration>
-                            <argLine>-Doak=true</argLine>
-                            <excludes>
-                                <exclude>**/TestGroupMergePackage.java</exclude>
-                                <exclude>**/TestACLAndMerge.java</exclude>
-                                <exclude>**/JcrPackageManagerImplTest.java</exclude>
-                                <exclude>**/AdminPermissionCheckerTest.java</exclude>
-                            </excludes>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
         </plugins>
-
     </build>
 
     <!-- ====================================================================== -->
@@ -221,11 +198,34 @@
             <scope>test</scope>
         </dependency>
 
-        <dependency>
-            <groupId>org.apache.jackrabbit</groupId>
-            <artifactId>oak-run</artifactId>
-            <version>0.13-SNAPSHOT</version>
-            <scope>test</scope>
-        </dependency>
     </dependencies>
+
+    <!-- ====================================================================== -->
+    <!-- P R O F I L E S                                                        -->
+    <!-- ====================================================================== -->
+    <profiles>
+        <profile>
+            <id>oak</id>
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.jackrabbit</groupId>
+                    <artifactId>oak-run</artifactId>
+                    <version>0.13-SNAPSHOT</version>
+                    <scope>test</scope>
+                </dependency>
+            </dependencies>
+
+            <build>
+                <plugins>
+                    <plugin>
+                        <artifactId>maven-surefire-plugin</artifactId>
+                        <configuration>
+                            <argLine>-Doak=true</argLine>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+
 </project>

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/impl/AdminPermissionCheckerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/impl/AdminPermissionCheckerTest.java?rev=1545967&r1=1545966&r2=1545967&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/impl/AdminPermissionCheckerTest.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/impl/AdminPermissionCheckerTest.java
Wed Nov 27 09:04:59 2013
@@ -17,12 +17,16 @@
 
 package org.apache.jackrabbit.vault.packaging.impl;
 
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
 import javax.jcr.SimpleCredentials;
 
 import org.apache.jackrabbit.api.JackrabbitSession;
 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.vault.packaging.integration.IntegrationTestBase;
+import org.junit.After;
 import org.junit.Test;
 
 import static org.junit.Assert.assertFalse;
@@ -33,24 +37,39 @@ import static org.junit.Assert.assertTru
  */
 public class AdminPermissionCheckerTest extends IntegrationTestBase {
 
+    private static final String TEST_USER = "testUser";
+
     @Test
     public void testAdminUser() throws Exception {
         assertTrue("user admin should have admin permissions", AdminPermissionChecker.hasAdministrativePermissions(admin));
     }
 
+    @After
+    public void after() throws RepositoryException {
+        JackrabbitSession jackrabbitSession = (JackrabbitSession) admin;
+        Authorizable vip = jackrabbitSession.getUserManager().getAuthorizable(TEST_USER);
+        if (vip != null) {
+            vip.remove();
+        }
+        jackrabbitSession.save();
+    }
+
     @Test
     public void testNotAdminUser() throws Exception {
         JackrabbitSession jackrabbitSession = (JackrabbitSession) admin;
-        Authorizable vip = jackrabbitSession.getUserManager().getAuthorizable("who");
+        Authorizable vip = jackrabbitSession.getUserManager().getAuthorizable(TEST_USER);
         if (vip == null) {
-            jackrabbitSession.getUserManager().createUser("who", "who");
+            jackrabbitSession.getUserManager().createUser(TEST_USER, TEST_USER);
         }
-        jackrabbitSession.save();
         admin.save();
-        admin.logout();
-        admin = repository.login(new SimpleCredentials("who", "who".toCharArray()));
-        assertFalse("\"who\" is not admin/system and doesn't belong to administrators thus
shouldn't have admin permissions",
-                AdminPermissionChecker.hasAdministrativePermissions(admin));
+        Session session = repository.login(new SimpleCredentials(TEST_USER, TEST_USER.toCharArray()));
+        try {
+            assertFalse(
+                    "\"" + TEST_USER + "\" is not admin/system and doesn't belong to administrators
thus shouldn't have admin permissions",
+                    AdminPermissionChecker.hasAdministrativePermissions(session));
+        } finally {
+            session.logout();
+        }
     }
 
     @Test
@@ -61,13 +80,20 @@ public class AdminPermissionCheckerTest 
             admins = jackrabbitSession.getUserManager().createGroup("administrators");
         }
         Group adminsGroup = (Group) admins;
-        adminsGroup.addMember(jackrabbitSession.getUserManager().getAuthorizable("anonymous"));
-        jackrabbitSession.save();
+        User testUser = (User) jackrabbitSession.getUserManager().getAuthorizable(TEST_USER);
+        if (testUser == null) {
+            testUser = jackrabbitSession.getUserManager().createUser(TEST_USER, TEST_USER);
+        }
+        adminsGroup.addMember(testUser);
         admin.save();
-        admin.logout();
-        admin = repository.login(new SimpleCredentials("anonymous", "anonymous".toCharArray()));
-        assertTrue("user \"anonymous\" has been added to administrators group thus should
have admin permissions",
-                AdminPermissionChecker.hasAdministrativePermissions(admin));
+        Session session = repository.login(new SimpleCredentials(TEST_USER, TEST_USER.toCharArray()));
+        try {
+            assertTrue(
+                    "user \"" + TEST_USER + "\" has been added to administrators group thus
should have admin permissions",
+                    AdminPermissionChecker.hasAdministrativePermissions(session));
+        } finally {
+            session.logout();
+        }
     }
 
 

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageManagerImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageManagerImplTest.java?rev=1545967&r1=1545966&r2=1545967&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageManagerImplTest.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageManagerImplTest.java
Wed Nov 27 09:04:59 2013
@@ -19,6 +19,7 @@ package org.apache.jackrabbit.vault.pack
 import java.util.LinkedList;
 import java.util.List;
 
+import javax.jcr.GuestCredentials;
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
 import javax.jcr.RepositoryException;
@@ -49,7 +50,7 @@ public class JcrPackageManagerImplTest e
         String path = "/etc/packages";
         try {
             jcrPackageManager.mkdir(path, true);
-            fail("this should've thrown RepositoryException as the session always tells nodes
don't exist");
+            fail("this should have thrown RepositoryException as the session always tells
nodes don't exist");
         }
         catch (RepositoryException e) {
             // everything it's ok
@@ -59,7 +60,7 @@ public class JcrPackageManagerImplTest e
 
     @Test
     public void testMkDirWithAnonymousSession() throws Exception {
-        Session session = repository.login(new SimpleCredentials("anonymous", "anonymous".toCharArray()));
+        Session session = repository.login(new GuestCredentials());
         JcrPackageManagerImpl jcrPackageManager = new JcrPackageManagerImpl(session);
         jcrPackageManager.mkdir("/something/that/is/not/going/to/be/found/anywhere/in/this/repository/even/if/searching/in/very/long/paths/like/this",
false);
         jcrPackageManager.mkdir("/something/that/is/not/going/to/be/found/anywhere/in/this/repository/even/if/searching/in/very/long/paths/like/this",
false);
@@ -83,6 +84,9 @@ public class JcrPackageManagerImplTest e
             NodeIterator nodes = currentNode.getNodes();
             while (nodes.hasNext()) {
                 Node node = nodes.nextNode();
+                if (node.getName().equals("jcr:system")) {
+                    continue;
+                }
                 String nodePath = node.getPath();
                 if (visitedPaths.contains(nodePath)) {
                     continue;

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/DumpCoverageTests.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/DumpCoverageTests.java?rev=1545967&r1=1545966&r2=1545967&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/DumpCoverageTests.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/DumpCoverageTests.java
Wed Nov 27 09:04:59 2013
@@ -18,6 +18,8 @@
 package org.apache.jackrabbit.vault.packaging.integration;
 
 import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
 
@@ -129,6 +131,8 @@ public class DumpCoverageTests extends I
     }
 
     public static void checkResults(String msg, String[] expected, List<String> result)
{
+        Arrays.sort(expected);
+        Collections.sort(result);
         String left = Text.implode(expected, "\n");
         String right = Text.implode(result.toArray(new String[result.size()]), "\n");
         assertEquals(msg, left, right);

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/IntegrationTestBase.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/IntegrationTestBase.java?rev=1545967&r1=1545966&r2=1545967&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/IntegrationTestBase.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/IntegrationTestBase.java
Wed Nov 27 09:04:59 2013
@@ -21,6 +21,7 @@ import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.Properties;
 
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
@@ -31,9 +32,19 @@ import javax.jcr.SimpleCredentials;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
+import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils;
 import org.apache.jackrabbit.core.RepositoryImpl;
 import org.apache.jackrabbit.core.config.RepositoryConfig;
+import org.apache.jackrabbit.core.security.principal.EveryonePrincipal;
 import org.apache.jackrabbit.oak.jcr.Jcr;
+import org.apache.jackrabbit.oak.security.SecurityProviderImpl;
+import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters;
+import org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeConstants;
+import org.apache.jackrabbit.oak.spi.security.user.UserConfiguration;
+import org.apache.jackrabbit.oak.spi.security.user.UserConstants;
+import org.apache.jackrabbit.oak.spi.security.user.action.AccessControlAction;
+import org.apache.jackrabbit.oak.spi.xml.ImportBehavior;
+import org.apache.jackrabbit.oak.spi.xml.ProtectedItemImporter;
 import org.apache.jackrabbit.vault.fs.api.ProgressTrackerListener;
 import org.apache.jackrabbit.vault.fs.io.ImportOptions;
 import org.apache.jackrabbit.vault.packaging.JcrPackageManager;
@@ -70,7 +81,23 @@ public class IntegrationTestBase  {
     @BeforeClass
     public static void initRepository() throws RepositoryException {
         if (Boolean.getBoolean("oak")) {
-            repository = new Jcr().createRepository();
+            Properties userProps = new Properties();
+            userProps.put(UserConstants.PARAM_USER_PATH, "/home/users");
+            userProps.put(UserConstants.PARAM_GROUP_PATH, "/home/groups");
+            userProps.put(AccessControlAction.USER_PRIVILEGE_NAMES, new String[] {PrivilegeConstants.JCR_ALL});
+            userProps.put(AccessControlAction.GROUP_PRIVILEGE_NAMES, new String[] {PrivilegeConstants.JCR_READ});
+            userProps.put(ProtectedItemImporter.PARAM_IMPORT_BEHAVIOR, ImportBehavior.NAME_BESTEFFORT);
+            Properties securityProps = new Properties();
+            securityProps.put(UserConfiguration.NAME, ConfigurationParameters.of(userProps));
+            repository = new Jcr()
+                    .with(new SecurityProviderImpl(ConfigurationParameters.of(securityProps)))
+                    .createRepository();
+
+            // setup default read ACL for everyone
+            Session admin = repository.login(new SimpleCredentials("admin", "admin".toCharArray()));
+            AccessControlUtils.addAccessControlEntry(admin, "/", EveryonePrincipal.getInstance(),
new String[]{"jcr:read"}, true);
+            admin.save();
+            admin.logout();
         } else {
             InputStream in = IntegrationTestBase.class.getResourceAsStream("repository.xml");
             RepositoryConfig cfg = RepositoryConfig.create(in, REPO_HOME);

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestGroupMergePackage.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestGroupMergePackage.java?rev=1545967&r1=1545966&r2=1545967&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestGroupMergePackage.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestGroupMergePackage.java
Wed Nov 27 09:04:59 2013
@@ -47,7 +47,7 @@ public class TestGroupMergePackage exten
         removeAuthorizable(mgr, "test-user-a");
         removeAuthorizable(mgr, "test-user-b");
         removeAuthorizable(mgr, "test-user-c");
-
+        admin.save();
         super.tearDown();
     }
 



Mime
View raw message