incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1538577 - in /sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager: AbstractAccessManagerTest.java GetAclTest.java ModifyAceTest.java
Date Mon, 04 Nov 2013 12:25:11 GMT
Author: bdelacretaz
Date: Mon Nov  4 12:25:11 2013
New Revision: 1538577

URL: http://svn.apache.org/r1538577
Log:
SLING-3225 -  more info in failure messages

Modified:
    sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/AbstractAccessManagerTest.java
    sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/GetAclTest.java
    sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/ModifyAceTest.java

Modified: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/AbstractAccessManagerTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/AbstractAccessManagerTest.java?rev=1538577&r1=1538576&r2=1538577&view=diff
==============================================================================
--- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/AbstractAccessManagerTest.java
(original)
+++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/AbstractAccessManagerTest.java
Mon Nov  4 12:25:11 2013
@@ -17,6 +17,7 @@
 package org.apache.sling.launchpad.webapp.integrationtest.accessManager;
 
 import java.io.IOException;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Random;
@@ -75,4 +76,12 @@ public abstract class AbstractAccessMana
         
         return location;
 	}
+	
+    protected void assertPrivilege(Collection<String> privileges, boolean expected,
String privilegeName) {
+        if(expected != privileges.contains(privilegeName)) {
+            fail("Expected privilege " + privilegeName + " to be " 
+                    + (expected ? "included" : "NOT INCLUDED")
+                    + " in supplied list: " + privileges + ")");
+        }
+    }
 }

Modified: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/GetAclTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/GetAclTest.java?rev=1538577&r1=1538576&r2=1538577&view=diff
==============================================================================
--- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/GetAclTest.java
(original)
+++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/GetAclTest.java
Mon Nov  4 12:25:11 2013
@@ -18,7 +18,6 @@ package org.apache.sling.launchpad.webap
 
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -40,14 +39,6 @@ public class GetAclTest extends Abstract
 	String testUserId = null;
 	String testUserId2 = null;
 	
-	private void assertPrivilege(Collection<String> privileges, boolean expected, String
privilegeName) {
-	    if(expected != privileges.contains(privilegeName)) {
-	        fail("Expected privilege " + privilegeName + " to be " 
-	                + (expected ? "included" : "NOT INCLUDED")
-	                + " in supplied list: " + privileges + ")");
-	    }
-	}
-	
 	@Override
 	protected void tearDown() throws Exception {
 		super.tearDown();

Modified: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/ModifyAceTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/ModifyAceTest.java?rev=1538577&r1=1538576&r2=1538577&view=diff
==============================================================================
--- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/ModifyAceTest.java
(original)
+++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/ModifyAceTest.java
Mon Nov  4 12:25:11 2013
@@ -209,9 +209,9 @@ public class ModifyAceTest extends Abstr
 		for (int i=0; i < grantedArray.length(); i++) {
 			grantedPrivilegeNames.add(grantedArray.getString(i));
 		}
-		assertTrue(grantedPrivilegeNames.contains("jcr:read"));
-		assertTrue(grantedPrivilegeNames.contains("jcr:readAccessControl"));
-		assertTrue(grantedPrivilegeNames.contains("jcr:addChildNodes"));
+		assertPrivilege(grantedPrivilegeNames, true, "jcr:read");
+		assertPrivilege(grantedPrivilegeNames, true, "jcr:readAccessControl");
+		assertPrivilege(grantedPrivilegeNames, true, "jcr:addChildNodes");
 
 		JSONArray deniedArray = aceObject.optJSONArray("denied");
 		assertNotNull(deniedArray);
@@ -220,8 +220,8 @@ public class ModifyAceTest extends Abstr
 		for (int i=0; i < deniedArray.length(); i++) {
 			deniedPrivilegeNames.add(deniedArray.getString(i));
 		}
-		assertTrue(deniedPrivilegeNames.contains("jcr:modifyAccessControl"));
-		assertTrue(deniedPrivilegeNames.contains("jcr:removeChildNodes"));
+		assertPrivilege(deniedPrivilegeNames, true, "jcr:modifyAccessControl");
+		assertPrivilege(deniedPrivilegeNames, true, "jcr:removeChildNodes");
 		
 		
 		
@@ -258,9 +258,9 @@ public class ModifyAceTest extends Abstr
 		for (int i=0; i < grantedArray2.length(); i++) {
 			grantedPrivilegeNames2.add(grantedArray2.getString(i));
 		}
-		assertTrue(grantedPrivilegeNames2.contains("jcr:read"));
-		assertTrue(grantedPrivilegeNames2.contains("jcr:addChildNodes"));
-		assertTrue(grantedPrivilegeNames2.contains("jcr:modifyProperties"));
+		assertPrivilege(grantedPrivilegeNames2, true, "jcr:read");
+		assertPrivilege(grantedPrivilegeNames2, true, "jcr:addChildNodes");
+		assertPrivilege(grantedPrivilegeNames2, true, "jcr:modifyProperties");
 
 		JSONArray deniedArray2 = aceObject2.optJSONArray("denied");
 		assertNotNull(deniedArray2);
@@ -269,8 +269,8 @@ public class ModifyAceTest extends Abstr
 		for (int i=0; i < deniedArray2.length(); i++) {
 			deniedPrivilegeNames2.add(deniedArray2.getString(i));
 		}
-		assertTrue(deniedPrivilegeNames2.contains("jcr:modifyAccessControl"));
-		assertTrue(deniedPrivilegeNames2.contains("jcr:removeNode"));
+		assertPrivilege(deniedPrivilegeNames2, true, "jcr:modifyAccessControl");
+		assertPrivilege(deniedPrivilegeNames2, true, "jcr:removeNode");
 	}
 
 	
@@ -314,7 +314,7 @@ public class ModifyAceTest extends Abstr
 		for (int i=0; i < grantedArray.length(); i++) {
 			grantedPrivilegeNames.add(grantedArray.getString(i));
 		}
-		assertTrue(grantedPrivilegeNames.contains("jcr:read"));
+		assertPrivilege(grantedPrivilegeNames, true, "jcr:read");
 
 		JSONArray deniedArray = aceObject.optJSONArray("denied");
 		assertNotNull(deniedArray);
@@ -323,7 +323,7 @@ public class ModifyAceTest extends Abstr
 		for (int i=0; i < deniedArray.length(); i++) {
 			deniedPrivilegeNames.add(deniedArray.getString(i));
 		}
-		assertTrue(deniedPrivilegeNames.contains("jcr:write"));
+		assertPrivilege(deniedPrivilegeNames, true, "jcr:write");
 		
 		
 		
@@ -357,8 +357,8 @@ public class ModifyAceTest extends Abstr
 		for (int i=0; i < grantedArray2.length(); i++) {
 			grantedPrivilegeNames2.add(grantedArray2.getString(i));
 		}
-		assertTrue(grantedPrivilegeNames2.contains("jcr:read"));
-		assertTrue(grantedPrivilegeNames2.contains("jcr:modifyProperties"));
+		assertPrivilege(grantedPrivilegeNames2, true, "jcr:read");
+		assertPrivilege(grantedPrivilegeNames2, true, "jcr:modifyProperties");
 
 		JSONArray deniedArray2 = aceObject2.optJSONArray("denied");
 		assertNotNull(deniedArray2);
@@ -367,11 +367,11 @@ public class ModifyAceTest extends Abstr
 		for (int i=0; i < deniedArray2.length(); i++) {
 			deniedPrivilegeNames2.add(deniedArray2.getString(i));
 		}
-		assertFalse(deniedPrivilegeNames2.contains("jcr:write"));
+		assertPrivilege(deniedPrivilegeNames2, false, "jcr:write");
 		//only the remaining privileges from the disaggregated jcr:write collection should remain.
-		assertTrue(deniedPrivilegeNames2.contains("jcr:addChildNodes"));
-		assertTrue(deniedPrivilegeNames2.contains("jcr:removeNode"));
-		assertTrue(deniedPrivilegeNames2.contains("jcr:removeChildNodes"));
+		assertPrivilege(deniedPrivilegeNames2, true, "jcr:addChildNodes");
+		assertPrivilege(deniedPrivilegeNames2, true, "jcr:removeNode");
+		assertPrivilege(deniedPrivilegeNames2, true, "jcr:removeChildNodes");
 	}
 
 	/**
@@ -414,7 +414,7 @@ public class ModifyAceTest extends Abstr
 		for (int i=0; i < grantedArray.length(); i++) {
 			grantedPrivilegeNames.add(grantedArray.getString(i));
 		}
-		assertTrue(grantedPrivilegeNames.contains("jcr:read"));
+		assertPrivilege(grantedPrivilegeNames, true, "jcr:read");
 
 		JSONArray deniedArray = aceObject.getJSONArray("denied");
 		assertNotNull(deniedArray);
@@ -423,7 +423,7 @@ public class ModifyAceTest extends Abstr
 		for (int i=0; i < deniedArray.length(); i++) {
 			deniedPrivilegeNames.add(deniedArray.getString(i));
 		}
-		assertTrue(deniedPrivilegeNames.contains("jcr:removeNode"));
+		assertPrivilege(deniedPrivilegeNames, true, "jcr:removeNode");
 		
 		
 		
@@ -458,7 +458,7 @@ public class ModifyAceTest extends Abstr
 		for (int i=0; i < grantedArray2.length(); i++) {
 			grantedPrivilegeNames2.add(grantedArray2.getString(i));
 		}
-		assertTrue(grantedPrivilegeNames2.contains("jcr:read"));
+		assertPrivilege(grantedPrivilegeNames2, true, "jcr:read");
 
 		JSONArray deniedArray2 = aceObject2.optJSONArray("denied");
 		assertNotNull(deniedArray2);
@@ -467,7 +467,7 @@ public class ModifyAceTest extends Abstr
 		for (int i=0; i < deniedArray2.length(); i++) {
 			deniedPrivilegeNames2.add(deniedArray2.getString(i));
 		}
-		assertTrue(deniedPrivilegeNames2.contains("jcr:write"));
+		assertPrivilege(deniedPrivilegeNames2, true, "jcr:write");
 	}
 
 	
@@ -510,7 +510,7 @@ public class ModifyAceTest extends Abstr
 		for (int i=0; i < grantedArray.length(); i++) {
 			grantedPrivilegeNames.add(grantedArray.getString(i));
 		}
-		assertTrue(grantedPrivilegeNames.contains("jcr:write"));
+		assertPrivilege(grantedPrivilegeNames, true, "jcr:write");
 
 		assertFalse(aceObject.has("denied"));
 		
@@ -546,7 +546,7 @@ public class ModifyAceTest extends Abstr
 		for (int i=0; i < grantedArray2.length(); i++) {
 			grantedPrivilegeNames2.add(grantedArray2.getString(i));
 		}
-		assertTrue(grantedPrivilegeNames2.contains("jcr:write"));
+		assertPrivilege(grantedPrivilegeNames2, true, "jcr:write");
 
 		JSONArray deniedArray2 = aceObject2.optJSONArray("denied");
 		assertNotNull(deniedArray2);
@@ -555,7 +555,7 @@ public class ModifyAceTest extends Abstr
 		for (int i=0; i < deniedArray2.length(); i++) {
 			deniedPrivilegeNames2.add(deniedArray2.getString(i));
 		}
-		assertTrue(deniedPrivilegeNames2.contains("jcr:nodeTypeManagement"));
+		assertPrivilege(deniedPrivilegeNames2, true, "jcr:nodeTypeManagement");
 	}
 
 
@@ -911,10 +911,10 @@ public class ModifyAceTest extends Abstr
 		for (int i=0; i < grantedArray.length(); i++) {
 			grantedPrivilegeNames.add(grantedArray.getString(i));
 		}
-		assertTrue(grantedPrivilegeNames.contains("jcr:versionManagement"));
-		assertTrue(grantedPrivilegeNames.contains("jcr:read"));
-		assertTrue(grantedPrivilegeNames.contains("jcr:modifyAccessControl"));
-		assertTrue(grantedPrivilegeNames.contains("jcr:write"));
+		assertPrivilege(grantedPrivilegeNames, true, "jcr:versionManagement");
+		assertPrivilege(grantedPrivilegeNames, true, "jcr:read");
+		assertPrivilege(grantedPrivilegeNames, true, "jcr:modifyAccessControl");
+		assertPrivilege(grantedPrivilegeNames, true, "jcr:write");
 
 		JSONArray deniedArray = aceObject.getJSONArray("denied");
 		assertNotNull(deniedArray);
@@ -924,7 +924,7 @@ public class ModifyAceTest extends Abstr
 			deniedPrivilegeNames.add(deniedArray.getString(i));
 		}
 		//the leftovers from the denied rep:write that were not granted with jcr:write
-		assertTrue(deniedPrivilegeNames.contains("jcr:nodeTypeManagement")); 
+		assertPrivilege(deniedPrivilegeNames, true, "jcr:nodeTypeManagement"); 
 	}
 
 	/**
@@ -976,15 +976,15 @@ public class ModifyAceTest extends Abstr
 		
 		JSONArray grantedArray = aceObject.getJSONArray("granted");
 		assertNotNull(grantedArray);
-		assertEquals(4, grantedArray.length());
 		Set<String> grantedPrivilegeNames = new HashSet<String>();
 		for (int i=0; i < grantedArray.length(); i++) {
 			grantedPrivilegeNames.add(grantedArray.getString(i));
 		}
-		assertTrue(grantedPrivilegeNames.contains("jcr:versionManagement"));
-		assertTrue(grantedPrivilegeNames.contains("jcr:read"));
-		assertTrue(grantedPrivilegeNames.contains("jcr:modifyAccessControl"));
-		assertTrue(grantedPrivilegeNames.contains("rep:write")); //jcr:nodeTypeManagement + jcr:write
+		assertPrivilege(grantedPrivilegeNames, true, "jcr:versionManagement");
+		assertPrivilege(grantedPrivilegeNames, true, "jcr:read");
+		assertPrivilege(grantedPrivilegeNames, true, "jcr:modifyAccessControl");
+		assertPrivilege(grantedPrivilegeNames, true, "rep:write"); //jcr:nodeTypeManagement + jcr:write
+        assertEquals("Expecting the correct number of privileges in " + grantedPrivilegeNames,
4, grantedPrivilegeNames.size());
 
 		//should be nothing left in the denied set.
 		JSONArray deniedArray = aceObject.optJSONArray("denied");



Mime
View raw message