incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From i..@apache.org
Subject svn commit: r947613 - in /sling/trunk: bundles/jcr/jackrabbit-accessmanager/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/ launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/
Date Mon, 24 May 2010 11:52:03 GMT
Author: ieb
Date: Mon May 24 11:52:02 2010
New Revision: 947613

URL: http://svn.apache.org/viewvc?rev=947613&view=rev
Log:
SLING-1528 Fixed, reverting to original format, and fixing the reverting the integration tests
(keeping the additional integration tests to cover this area)

Modified:
    sling/trunk/bundles/jcr/jackrabbit-accessmanager/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetAclServlet.java
    sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/ModifyAceTest.java
    sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/RemoveAcesTest.java

Modified: sling/trunk/bundles/jcr/jackrabbit-accessmanager/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetAclServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-accessmanager/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetAclServlet.java?rev=947613&r1=947612&r2=947613&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-accessmanager/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetAclServlet.java
(original)
+++ sling/trunk/bundles/jcr/jackrabbit-accessmanager/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetAclServlet.java
Mon May 24 11:52:02 2010
@@ -132,7 +132,8 @@ public class GetAclServlet extends Sling
 	/* (non-Javadoc)
 	 * @see org.apache.sling.api.servlets.SlingSafeMethodsServlet#doGet(org.apache.sling.api.SlingHttpServletRequest,
org.apache.sling.api.SlingHttpServletResponse)
 	 */
-	@Override
+	@SuppressWarnings("unchecked")
+    @Override
 	protected void doGet(SlingHttpServletRequest request,
 			SlingHttpServletResponse response) throws ServletException,
 			IOException {
@@ -157,18 +158,20 @@ public class GetAclServlet extends Sling
         	}
 
         	AccessControlEntry[] declaredAccessControlEntries = getDeclaredAccessControlEntries(session,
resourcePath);
-        	Map<String, Map<String, Set<String>>> aclMap = new LinkedHashMap<String,
Map<String,Set<String>>>();
+        	Map<String, Map<String, Object>> aclMap = new LinkedHashMap<String,
Map<String,Object>>();
+                int sequence = 0;
         	for (AccessControlEntry ace : declaredAccessControlEntries) {
     			Principal principal = ace.getPrincipal();
-    			Map<String, Set<String>> map = aclMap.get(principal.getName());
+    			Map<String, Object> map = aclMap.get(principal.getName());
     			if (map == null) {
-    				map = new LinkedHashMap<String, Set<String>>();
+    				map = new LinkedHashMap<String, Object>();
     				aclMap.put(principal.getName(), map);
+    				map.put("order", sequence++);
     			}
 
     			boolean allow = AccessControlUtil.isAllow(ace);
     			if (allow) {
-    				Set<String> grantedSet = map.get("granted");
+    				Set<String> grantedSet = (Set<String>) map.get("granted");
     				if (grantedSet == null) {
     					grantedSet = new LinkedHashSet<String>();
     					map.put("granted", grantedSet);
@@ -178,7 +181,7 @@ public class GetAclServlet extends Sling
     					grantedSet.add(privilege.getName());
     				}
     			} else {
-    				Set<String> deniedSet = map.get("denied");
+    				Set<String> deniedSet = (Set<String>) map.get("denied");
     				if (deniedSet == null) {
     					deniedSet = new LinkedHashSet<String>();
     					map.put("denied", deniedSet);
@@ -195,30 +198,32 @@ public class GetAclServlet extends Sling
         	response.setCharacterEncoding("UTF-8");
 
         	List<JSONObject> aclList = new ArrayList<JSONObject>();
-        	Set<Entry<String, Map<String, Set<String>>>> entrySet =
aclMap.entrySet();
-        	for (Entry<String, Map<String, Set<String>>> entry : entrySet)
{
+        	Set<Entry<String, Map<String, Object>>> entrySet = aclMap.entrySet();
+        	for (Entry<String, Map<String, Object>> entry : entrySet) {
         		String principalName = entry.getKey();
-        		Map<String, Set<String>> value = entry.getValue();
+        		Map<String, Object> value = entry.getValue();
 
             	JSONObject aceObject = new JSONObject();
             	aceObject.put("principal", principalName);
 
-        		Set<String> grantedSet = value.get("granted");
+        		Set<String> grantedSet = (Set<String>) value.get("granted");
         		if (grantedSet != null) {
             		aceObject.put("granted", grantedSet);
         		}
         		
-        		Set<String> deniedSet = value.get("denied");
+        		Set<String> deniedSet = (Set<String>) value.get("denied");
         		if (deniedSet != null) {
         			aceObject.put("denied", deniedSet);
         		}
-
+        		aceObject.put("order", value.get("order"));
         		aclList.add(aceObject);
 			}
-        	JSONArray jsonAclArray = new JSONArray(aclList);
-
+                JSONObject jsonAclMap = new JSONObject(aclMap);
+                for ( JSONObject jsonObj : aclList) {
+                   jsonAclMap.put(jsonObj.getString("principal"), jsonObj);
+                }
+                jsonAclMap.write(response.getWriter());
             // do the dump
-        	jsonAclArray.write(response.getWriter());
         } catch (AccessDeniedException ade) {
         	response.sendError(HttpServletResponse.SC_NOT_FOUND);
         } catch (ResourceNotFoundException rnfe) {

Modified: sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/ModifyAceTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/ModifyAceTest.java?rev=947613&r1=947612&r2=947613&view=diff
==============================================================================
--- sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/ModifyAceTest.java
(original)
+++ sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/ModifyAceTest.java
Mon May 24 11:52:02 2010
@@ -96,15 +96,18 @@ public class ModifyAceTest extends Abstr
 
 		String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
 		assertNotNull(json);
-		JSONArray jsonArray = new JSONArray(json);
-		assertEquals(1, jsonArray.length());
+		JSONObject jsonObject = new JSONObject(json);
+		assertEquals(1, jsonObject.length());
 		
-		JSONObject aceObject = jsonArray.optJSONObject(0);
+		JSONObject aceObject = jsonObject.optJSONObject(testUserId);
 		assertNotNull(aceObject);
 		
 		String principalString = aceObject.optString("principal");
 		assertEquals(testUserId, principalString);
-		
+
+	        int order = aceObject.optInt("order");
+	        assertEquals(0, order);
+
 		JSONArray grantedArray = aceObject.optJSONArray("granted");
 		assertNotNull(grantedArray);
 		assertEquals(1, grantedArray.length());
@@ -138,12 +141,15 @@ public class ModifyAceTest extends Abstr
 
 		String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
 		assertNotNull(json);
-		JSONArray jsonArray = new JSONArray(json);
-		assertEquals(1, jsonArray.length());
+		JSONObject jsonObject = new JSONObject(json);
+		assertEquals(1, jsonObject.length());
 		
-		JSONObject aceObject = jsonArray.optJSONObject(0);
+		JSONObject aceObject = jsonObject.optJSONObject(testGroupId);
 		assertNotNull(aceObject);
 
+	        int order = aceObject.optInt("order");
+	        assertEquals(0, order);
+
 		String principalString = aceObject.optString("principal");
 		assertEquals(testGroupId, principalString);
 		
@@ -184,15 +190,18 @@ public class ModifyAceTest extends Abstr
 
 		String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
 		assertNotNull(json);
-		JSONArray jsonArray = new JSONArray(json);
-		assertEquals(1, jsonArray.length());
+		JSONObject jsonObject = new JSONObject(json);
+		assertEquals(1, jsonObject.length());
 		
-		JSONObject aceObject = jsonArray.optJSONObject(0);
+		JSONObject aceObject = jsonObject.optJSONObject(testUserId);
 		assertNotNull(aceObject);
 
 		String principalString = aceObject.optString("principal");
 		assertEquals(testUserId, principalString);
 		
+	        int order = aceObject.optInt("order");
+	        assertEquals(0, order);
+
 		JSONArray grantedArray = aceObject.optJSONArray("granted");
 		assertNotNull(grantedArray);
 		assertEquals(3, grantedArray.length());
@@ -233,10 +242,10 @@ public class ModifyAceTest extends Abstr
 		//fetch the JSON for the acl to verify the settings.
 		String json2 = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
 		assertNotNull(json2);
-		JSONArray jsonArray2 = new JSONArray(json2);
-		assertEquals(1, jsonArray2.length());
+		JSONObject jsonObject2 = new JSONObject(json2);
+		assertEquals(1, jsonObject2.length());
 		
-		JSONObject aceObject2 = jsonArray2.optJSONObject(0);
+		JSONObject aceObject2 = jsonObject2.optJSONObject(testUserId);
 		assertNotNull(aceObject2);
 
 		String principalString2 = aceObject2.optString("principal");
@@ -290,10 +299,10 @@ public class ModifyAceTest extends Abstr
 		String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
 		assertNotNull(json);
 		
-		JSONArray jsonArray = new JSONArray(json);
-		assertEquals(1, jsonArray.length());
+		JSONObject jsonObject = new JSONObject(json);
+		assertEquals(1, jsonObject.length());
 		
-		JSONObject aceObject = jsonArray.optJSONObject(0); 
+		JSONObject aceObject = jsonObject.optJSONObject(testUserId);
 		assertNotNull(aceObject);
 		
 		assertEquals(testUserId, aceObject.optString("principal"));
@@ -333,10 +342,10 @@ public class ModifyAceTest extends Abstr
 		String json2 = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
 		assertNotNull(json2);
 		
-		JSONArray jsonArray2 = new JSONArray(json2);
-		assertEquals(1, jsonArray2.length());
+		JSONObject jsonObject2 = new JSONObject(json2);
+		assertEquals(1, jsonObject2.length());
 		
-		JSONObject aceObject2 = jsonArray2.optJSONObject(0); 
+		JSONObject aceObject2 = jsonObject2.optJSONObject(testUserId);
 		assertNotNull(aceObject2);
 		
 		assertEquals(testUserId, aceObject2.optString("principal"));
@@ -390,10 +399,10 @@ public class ModifyAceTest extends Abstr
 		String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
 		assertNotNull(json);
 		
-		JSONArray jsonArray = new JSONArray(json);
-		assertEquals(1, jsonArray.length());
+		JSONObject jsonObject = new JSONObject(json);
+		assertEquals(1, jsonObject.length());
 		
-		JSONObject aceObject = jsonArray.optJSONObject(0); 
+		JSONObject aceObject = jsonObject.optJSONObject(testUserId);
 		assertNotNull(aceObject);
 		
 		assertEquals(testUserId, aceObject.optString("principal"));
@@ -434,10 +443,10 @@ public class ModifyAceTest extends Abstr
 		String json2 = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
 		assertNotNull(json2);
 		
-		JSONArray jsonArray2 = new JSONArray(json2);
-		assertEquals(1, jsonArray2.length());
+		JSONObject jsonObject2 = new JSONObject(json2);
+		assertEquals(1, jsonObject2.length());
 		
-		JSONObject aceObject2 = jsonArray2.optJSONObject(0); 
+		JSONObject aceObject2 = jsonObject2.optJSONObject(testUserId);
 		assertNotNull(aceObject2);
 		
 		assertEquals(testUserId, aceObject.optString("principal"));
@@ -486,10 +495,10 @@ public class ModifyAceTest extends Abstr
 		String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
 		assertNotNull(json);
 		
-		JSONArray jsonArray = new JSONArray(json);
-		assertEquals(1, jsonArray.length());
-		
-		JSONObject aceObject = jsonArray.optJSONObject(0); 
+		JSONObject jsonObject = new JSONObject(json);
+		assertEquals(1, jsonObject.length());
+
+		JSONObject aceObject = jsonObject.optJSONObject(testUserId);
 		assertNotNull(aceObject);
 		
 		assertEquals(testUserId, aceObject.optString("principal"));
@@ -522,10 +531,10 @@ public class ModifyAceTest extends Abstr
 		String json2 = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
 		assertNotNull(json2);
 
-		JSONArray jsonArray2 = new JSONArray(json2);
-		assertEquals(1, jsonArray2.length());
+		JSONObject jsonObject2 = new JSONObject(json2);
+		assertEquals(1, jsonObject2.length());
 		
-		JSONObject aceObject2 = jsonArray2.optJSONObject(0); 
+		JSONObject aceObject2 = jsonObject2.optJSONObject(testUserId);
 		assertNotNull(aceObject2);
 		
 		assertEquals(testUserId, aceObject2.optString("principal"));
@@ -569,11 +578,17 @@ public class ModifyAceTest extends Abstr
 		String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
 		assertNotNull(json);
 
-		JSONArray jsonArray = new JSONArray(json);
-		assertEquals(2, jsonArray.length());
-		
-		assertEquals(testGroupId, jsonArray.getJSONObject(0).getString("principal"));
-		assertEquals(testUserId, jsonArray.getJSONObject(1).getString("principal"));
+		JSONObject jsonObject = new JSONObject(json);
+		assertEquals(2, jsonObject.length());
+
+		JSONObject group = jsonObject.getJSONObject(testGroupId);
+		assertNotNull(group);
+		assertEquals(testGroupId, group.getString("principal"));
+                assertEquals(0, group.getInt("order"));
+		JSONObject user =  jsonObject.getJSONObject(testUserId);
+                assertNotNull(user);
+                assertEquals(testUserId, user.getString("principal"));
+                assertEquals(1, user.getInt("order"));
 	}	
 
 	/**
@@ -594,11 +609,18 @@ public class ModifyAceTest extends Abstr
 		String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
 		assertNotNull(json);
 
-		JSONArray jsonArray = new JSONArray(json);
-		assertEquals(2, jsonArray.length());
+		JSONObject jsonObject = new JSONObject(json);
+		assertEquals(2, jsonObject.length());
 		
-		assertEquals(testUserId, jsonArray.getJSONObject(0).getString("principal"));
-		assertEquals(testGroupId, jsonArray.getJSONObject(1).getString("principal"));
+                JSONObject user =  jsonObject.getJSONObject(testUserId);
+                assertNotNull(user);
+                assertEquals(testUserId, user.getString("principal"));
+                assertEquals(0, user.getInt("order"));
+                JSONObject group = jsonObject.getJSONObject(testGroupId);
+                assertNotNull(group);
+                assertEquals(testGroupId, group.getString("principal"));
+                assertEquals(1, group.getInt("order"));
+
 	}	
 
 	/**
@@ -619,11 +641,20 @@ public class ModifyAceTest extends Abstr
 		String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
 		assertNotNull(json);
 
-		JSONArray jsonArray = new JSONArray(json);
-		assertEquals(2, jsonArray.length());
 		
-		assertEquals(testGroupId, jsonArray.getJSONObject(0).getString("principal"));
-		assertEquals(testUserId, jsonArray.getJSONObject(1).getString("principal"));
+                JSONObject jsonObject = new JSONObject(json);
+                assertEquals(2, jsonObject.length());
+
+
+                JSONObject group = jsonObject.getJSONObject(testGroupId);
+                assertNotNull(group);
+                assertEquals(testGroupId, group.getString("principal"));
+                assertEquals(0, group.getInt("order"));
+                JSONObject user =  jsonObject.getJSONObject(testUserId);
+                assertNotNull(user);
+                assertEquals(testUserId, user.getString("principal"));
+                assertEquals(1, user.getInt("order"));
+
 	}	
 
 	/**
@@ -644,11 +675,18 @@ public class ModifyAceTest extends Abstr
 		String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
 		assertNotNull(json);
 
-		JSONArray jsonArray = new JSONArray(json);
-		assertEquals(2, jsonArray.length());
-		
-		assertEquals(testUserId, jsonArray.getJSONObject(0).getString("principal"));
-		assertEquals(testGroupId, jsonArray.getJSONObject(1).getString("principal"));
+                JSONObject jsonObject = new JSONObject(json);
+                assertEquals(2, jsonObject.length());
+
+                JSONObject user =  jsonObject.getJSONObject(testUserId);
+                assertNotNull(user);
+                assertEquals(testUserId, user.getString("principal"));
+                assertEquals(0, user.getInt("order"));
+                JSONObject group = jsonObject.getJSONObject(testGroupId);
+                assertNotNull(group);
+                assertEquals(testGroupId, group.getString("principal"));
+                assertEquals(1, group.getInt("order"));
+
 	}	
 
 	/**
@@ -668,12 +706,22 @@ public class ModifyAceTest extends Abstr
 		String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
 		assertNotNull(json);
 
-		JSONArray jsonArray = new JSONArray(json);
-		assertEquals(2, jsonArray.length());
-		
-		assertEquals(testGroupId, jsonArray.getJSONObject(0).getString("principal"));
-		assertEquals(testUserId, jsonArray.getJSONObject(1).getString("principal"));
 		
+                JSONObject jsonObject = new JSONObject(json);
+                assertEquals(2, jsonObject.length());
+
+                JSONObject group = jsonObject.getJSONObject(testGroupId);
+                assertNotNull(group);
+                assertEquals(testGroupId, group.getString("principal"));
+                assertEquals(0, group.getInt("order"));
+
+                JSONObject user =  jsonObject.getJSONObject(testUserId);
+                assertNotNull(user);
+                assertEquals(testUserId, user.getString("principal"));
+                assertEquals(1, user.getInt("order"));
+
+
+
 		//add another principal between the testGroupId and testUserId
 		testUserId2 = createTestUser();
 		addOrUpdateAce(testFolderUrl, testUserId2, true, "1");
@@ -681,12 +729,24 @@ public class ModifyAceTest extends Abstr
 		String json2 = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
 		assertNotNull(json2);
 
-		JSONArray jsonArray2 = new JSONArray(json2);
-		assertEquals(3, jsonArray2.length());
-		
-		assertEquals(testGroupId, jsonArray2.getJSONObject(0).getString("principal"));
-		assertEquals(testUserId2, jsonArray2.getJSONObject(1).getString("principal"));		
-		assertEquals(testUserId, jsonArray2.getJSONObject(2).getString("principal"));		
+                JSONObject jsonObject2 = new JSONObject(json2);
+                assertEquals(3, jsonObject2.length());
+
+                JSONObject group2 = jsonObject2.getJSONObject(testGroupId);
+                assertNotNull(group2);
+                assertEquals(testGroupId, group2.getString("principal"));
+                assertEquals(0, group2.getInt("order"));
+
+                JSONObject user3 =  jsonObject2.getJSONObject(testUserId2);
+                assertNotNull(user3);
+                assertEquals(testUserId2, user3.getString("principal"));
+                assertEquals(1, user3.getInt("order"));
+
+                JSONObject user2 =  jsonObject2.getJSONObject(testUserId);
+                assertNotNull(user2);
+                assertEquals(testUserId, user2.getString("principal"));
+                assertEquals(2, user2.getInt("order"));
+
 	}	
 
 	/**
@@ -711,11 +771,18 @@ public class ModifyAceTest extends Abstr
 		String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
 		assertNotNull(json);
 		
-		JSONArray jsonArray = new JSONArray(json);
-		assertEquals(2, jsonArray.length());
-		
-		assertEquals(testGroupId, jsonArray.getJSONObject(0).getString("principal"));
-		assertEquals(testUserId, jsonArray.getJSONObject(1).getString("principal"));
+                JSONObject jsonObject = new JSONObject(json);
+                assertEquals(2, jsonObject.length());
+
+                JSONObject group = jsonObject.getJSONObject(testGroupId);
+                assertNotNull(group);
+                assertEquals(testGroupId, group.getString("principal"));
+                assertEquals(0, group.getInt("order"));
+                JSONObject user =  jsonObject.getJSONObject(testUserId);
+                assertNotNull(user);
+                assertEquals(testUserId, user.getString("principal"));
+                assertEquals(1, user.getInt("order"));
+
 	}	
 
 	
@@ -735,10 +802,15 @@ public class ModifyAceTest extends Abstr
 		Credentials creds = new UsernamePasswordCredentials("admin", "admin");
 		String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
 		assertNotNull(json);
-		JSONArray jsonArray = new JSONArray(json);
-		assertEquals(1, jsonArray.length());
 		
-		assertEquals(testUserId, jsonArray.getJSONObject(0).getString("principal"));
+                JSONObject jsonObject = new JSONObject(json);
+                assertEquals(1, jsonObject.length());
+
+                JSONObject user = jsonObject.getJSONObject(testUserId);
+                assertNotNull(user);
+                assertEquals(testUserId, user.getString("principal"));
+                assertEquals(0, user.getInt("order"));
+
 	}
 	
 	/**

Modified: sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/RemoveAcesTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/RemoveAcesTest.java?rev=947613&r1=947612&r2=947613&view=diff
==============================================================================
--- sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/RemoveAcesTest.java
(original)
+++ sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/RemoveAcesTest.java
Mon May 24 11:52:02 2010
@@ -95,17 +95,19 @@ public class RemoveAcesTest extends Abst
 		String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
 		assertNotNull(json);
 		
-		JSONArray jsonArray = new JSONArray(json);
+		JSONObject jsonObject = new JSONObject(json);
 		
 		if (addGroupAce) {
-			assertEquals(2, jsonArray.length());
+			assertEquals(2, jsonObject.length());
 		} else {
-			assertEquals(1, jsonArray.length());
+			assertEquals(1, jsonObject.length());
 		}
 		
-		JSONObject aceObject = jsonArray.optJSONObject(0);
+		JSONObject aceObject = jsonObject.optJSONObject(testUserId);
 		assertNotNull(aceObject);
 		
+		assertEquals(0, aceObject.getInt("order"));
+
 		String principalString = aceObject.optString("principal");
 		assertEquals(testUserId, principalString);
 		
@@ -118,12 +120,14 @@ public class RemoveAcesTest extends Abst
 		assertEquals("jcr:write", deniedArray.getString(0));
 
 		if (addGroupAce) {
-			aceObject = jsonArray.optJSONObject(1);
+			aceObject = jsonObject.optJSONObject(testGroupId);
 			assertNotNull(aceObject);
 			
 			principalString = aceObject.optString("principal");
 			assertEquals(testGroupId, principalString);
 
+		        assertEquals(1, aceObject.getInt("order"));
+
 			grantedArray = aceObject.optJSONArray("granted");
 			assertNotNull(grantedArray);
 			assertEquals("jcr:read", grantedArray.getString(0));
@@ -149,9 +153,9 @@ public class RemoveAcesTest extends Abst
 		String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
 		assertNotNull(json);
 
-		JSONArray jsonArray = new JSONArray(json);
-		assertNotNull(jsonArray);
-		assertEquals(0, jsonArray.length());
+		JSONObject jsonObject = new JSONObject(json);
+		assertNotNull(jsonObject);
+		assertEquals(0, jsonObject.length());
 	}
 
 	//test removing multiple aces
@@ -172,8 +176,8 @@ public class RemoveAcesTest extends Abst
 		String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
 		assertNotNull(json);
 
-		JSONArray jsonArray = new JSONArray(json);
-		assertNotNull(jsonArray);
-		assertEquals(0, jsonArray.length());
+		JSONObject jsonObject = new JSONObject(json);
+		assertNotNull(jsonObject);
+		assertEquals(0, jsonObject.length());
 	}
 }



Mime
View raw message