jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1214282 - in /jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security: AccessControlDiscoveryTest.java AccessControlListTest.java AccessControlPolicyTest.java RSessionAccessControlDiscoveryTest.java
Date Wed, 14 Dec 2011 15:02:43 GMT
Author: reschke
Date: Wed Dec 14 15:02:43 2011
New Revision: 1214282

URL: http://svn.apache.org/viewvc?rev=1214282&view=rev
Log:
JCR-3177: Remove jdk 1.4 restriction for jcr-tests

Reduce warning noise on security tests

Modified:
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlDiscoveryTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlListTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlPolicyTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/RSessionAccessControlDiscoveryTest.java

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlDiscoveryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlDiscoveryTest.java?rev=1214282&r1=1214281&r2=1214282&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlDiscoveryTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlDiscoveryTest.java
Wed Dec 14 15:02:43 2011
@@ -45,7 +45,7 @@ public class AccessControlDiscoveryTest 
 
         // Quote from spec:
         // "A repository must support the following standard privileges."
-        List names = new ArrayList(privileges.length);
+        List<String> names = new ArrayList<String>(privileges.length);
         for (int i = 0; i < privileges.length; i++) {
             names.add(privileges[i].getName());
         }
@@ -73,7 +73,7 @@ public class AccessControlDiscoveryTest 
     }
 
     public void testMandatoryPrivilegeFromName() throws RepositoryException {
-        List l = new ArrayList();
+        List<String> l = new ArrayList<String>();
         l.add(getJCRName(Privilege.JCR_READ, superuser));
         l.add(getJCRName(Privilege.JCR_ADD_CHILD_NODES, superuser));
         l.add(getJCRName(Privilege.JCR_REMOVE_CHILD_NODES, superuser));
@@ -84,8 +84,8 @@ public class AccessControlDiscoveryTest 
         l.add(getJCRName(Privilege.JCR_WRITE, superuser));
         l.add(getJCRName(Privilege.JCR_ALL, superuser));
 
-        for (Iterator it = l.iterator(); it.hasNext();) {
-            String privName = it.next().toString();
+        for (Iterator<String> it = l.iterator(); it.hasNext();) {
+            String privName = it.next();
             Privilege p = acMgr.privilegeFromName(privName);
             assertEquals("Expected equal privilege name.", privName, p.getName());
         }
@@ -105,14 +105,14 @@ public class AccessControlDiscoveryTest 
         Privilege[] supported = acMgr.getSupportedPrivileges(testRootNode.getPath());
 
         Privilege all = acMgr.privilegeFromName(Privilege.JCR_ALL);
-        Set allSet = new HashSet();
+        Set<Privilege> allSet = new HashSet<Privilege>();
         allSet.addAll(Arrays.asList(all.getAggregatePrivileges()));
 
         String msg = "The all privilege must also contain ";
         for (int i=0; i < supported.length; i++) {
             Privilege sp = supported[i];
             if (sp.isAggregate()) {
-                Collection col = Arrays.asList(sp.getAggregatePrivileges());
+                Collection<Privilege> col = Arrays.asList(sp.getAggregatePrivileges());
                 assertTrue(msg + sp.getName(), allSet.containsAll(col));
             } else {
                 assertTrue(msg + sp.getName(), allSet.contains(sp));
@@ -153,12 +153,12 @@ public class AccessControlDiscoveryTest 
      * @throws RepositoryException
      */
     public void testAggregregatePrivileges() throws RepositoryException {
-        List l = new ArrayList();
+        List<String> l = new ArrayList<String>();
         l.add(getJCRName(Privilege.JCR_WRITE, superuser));
         l.add(getJCRName(Privilege.JCR_ALL, superuser));
 
-        for (Iterator it = l.iterator(); it.hasNext();) {
-            String privName = it.next().toString();
+        for (Iterator<String> it = l.iterator(); it.hasNext();) {
+            String privName = it.next();
             Privilege p = acMgr.privilegeFromName(privName);
 
             assertTrue("write and all must always be aggregate privileges.", p.isAggregate());
@@ -188,12 +188,12 @@ public class AccessControlDiscoveryTest 
             String remappedPrefix = "_jcr";
             superuser.setNamespacePrefix(remappedPrefix, "http://www.jcp.org/jcr/1.0");
 
-            List l = new ArrayList();
+            List<Privilege> l = new ArrayList<Privilege>();
             l.add(acMgr.privilegeFromName(Privilege.JCR_ALL));
             l.add(acMgr.privilegeFromName(remappedPrefix + ":all"));
 
-            for (Iterator it = l.iterator(); it.hasNext();) {
-                Privilege p = (Privilege) it.next();
+            for (Iterator<Privilege> it = l.iterator(); it.hasNext();) {
+                Privilege p = it.next();
 
                 assertEquals("The privilege name must reflect the modified namespace prefix.",remappedPrefix
+ ":all", p.getName());
                 assertEquals("jcr:all privileges must be equal.",allPriv, p);
@@ -279,7 +279,7 @@ public class AccessControlDiscoveryTest 
         Privilege all = acMgr.privilegeFromName(Privilege.JCR_ALL);
 
         // remove all privileges that are granted.
-        Set notGranted = new HashSet(Arrays.asList(all.getAggregatePrivileges()));
+        Set<Privilege> notGranted = new HashSet<Privilege>(Arrays.asList(all.getAggregatePrivileges()));
         for (int i = 0; i < privs.length; i++) {
             if (privs[i].isAggregate()) {
                 notGranted.removeAll(Arrays.asList(privs[i].getAggregatePrivileges()));
@@ -292,7 +292,7 @@ public class AccessControlDiscoveryTest 
         if (notGranted.isEmpty()) {
             assertTrue(acMgr.hasPrivileges(testRootNode.getPath(), new Privilege[] {all}));
         } else {
-            Privilege[] toTest = (Privilege[]) notGranted.toArray(new Privilege[notGranted.size()]);
+            Privilege[] toTest = notGranted.toArray(new Privilege[notGranted.size()]);
             assertTrue(!acMgr.hasPrivileges(testRootNode.getPath(), toTest));
         }
     }

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlListTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlListTest.java?rev=1214282&r1=1214281&r2=1214282&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlListTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlListTest.java
Wed Dec 14 15:02:43 2011
@@ -50,7 +50,7 @@ public class AccessControlListTest exten
     private Privilege[] privs;
     private Principal testPrincipal;
 
-    private List privilegesToRestore = new ArrayList();
+    private List<Privilege> privilegesToRestore = new ArrayList<Privilege>();
 
     protected void setUp() throws Exception {
         checkSupportedOption(Repository.OPTION_ACCESS_CONTROL_SUPPORTED);
@@ -121,8 +121,8 @@ public class AccessControlListTest exten
         throw new NotExecutableException("No AccessControlList at " + path);
     }
 
-    private static List currentPrivileges(AccessControlList acl, Principal principal) throws
RepositoryException {
-        List privileges = new ArrayList();
+    private static List<Privilege> currentPrivileges(AccessControlList acl, Principal
principal) throws RepositoryException {
+        List<Privilege> privileges = new ArrayList<Privilege>();
         AccessControlEntry[] entries = acl.getAccessControlEntries();
         for (int i = 0; i < entries.length; i++) {
             AccessControlEntry ace = entries[i];
@@ -189,7 +189,7 @@ public class AccessControlListTest exten
         acl.addAccessControlEntry(testPrincipal, new Privilege[] {aggregate});
 
         // make sure all privileges are present now
-        List privs = currentPrivileges(acl, testPrincipal);
+        List<Privilege> privs = currentPrivileges(acl, testPrincipal);
         assertTrue("Privileges added through 'addAccessControlEntry' must be " +
                 "reflected upon getAccessControlEntries",
                 privs.contains(aggregate) || privs.containsAll(Arrays.asList(aggregate.getAggregatePrivileges())));
@@ -249,7 +249,7 @@ public class AccessControlListTest exten
         AccessControlList acl = getList(acMgr, path);
         acl.addAccessControlEntry(testPrincipal, privs);
 
-        Set assignedPrivs = new HashSet();
+        Set<Privilege> assignedPrivs = new HashSet<Privilege>();
         AccessControlEntry[] entries = acl.getAccessControlEntries();
         for (int i = 0; i < entries.length; i++) {
             if (entries[i].getPrincipal().equals(testPrincipal)) {
@@ -264,7 +264,7 @@ public class AccessControlListTest exten
             }
         }
 
-        Set expected = new HashSet();
+        Set<Privilege> expected = new HashSet<Privilege>();
         for (int i = 0; i < privs.length; i++) {
             if (privs[i].isAggregate()) {
                 expected.addAll(Arrays.asList(privs[i].getAggregatePrivileges()));
@@ -279,7 +279,7 @@ public class AccessControlListTest exten
         checkCanModifyAc(path);
 
         AccessControlList acl = getList(acMgr, path);
-        List originalAces = Arrays.asList(acl.getAccessControlEntries());
+        List<AccessControlEntry> originalAces = Arrays.asList(acl.getAccessControlEntries());
 
         if (!acl.addAccessControlEntry(testPrincipal, privs)) {
             throw new NotExecutableException();
@@ -297,7 +297,7 @@ public class AccessControlListTest exten
         checkCanModifyAc(path);
 
         AccessControlList acl = getList(acMgr, path);
-        List originalAces = Arrays.asList(acl.getAccessControlEntries());
+        List<AccessControlEntry> originalAces = Arrays.asList(acl.getAccessControlEntries());
 
         if (!acl.addAccessControlEntry(testPrincipal, privs)) {
             throw new NotExecutableException();
@@ -380,7 +380,7 @@ public class AccessControlListTest exten
             acl.removeAccessControlEntry(ace);
 
             // retrieve entries again:
-            List remainingEntries = Arrays.asList(acl.getAccessControlEntries());
+            List<AccessControlEntry> remainingEntries = Arrays.asList(acl.getAccessControlEntries());
             assertFalse("AccessControlList.getAccessControlEntries still returns a removed
ACE.", remainingEntries.contains(ace));
         }
     }
@@ -449,7 +449,7 @@ public class AccessControlListTest exten
 
         // revert changes -> removed entry must be present again.
         superuser.refresh(false);
-        List entries = Arrays.asList(getList(acMgr, path).getAccessControlEntries());
+        List<AccessControlEntry> entries = Arrays.asList(getList(acMgr, path).getAccessControlEntries());
         assertTrue("After reverting any changes the removed ACE should be present again.",
entries.contains(ace));
     }
 
@@ -498,7 +498,7 @@ public class AccessControlListTest exten
     public void testExtendPrivileges() throws NotExecutableException, RepositoryException
{
         checkCanModifyAc(path);
         // search 2 non-aggregated privileges
-        List twoPrivs = new ArrayList(2);
+        List<Privilege> twoPrivs = new ArrayList<Privilege>(2);
         for (int i = 0; i < privs.length && twoPrivs.size() < 2; i++) {
             if (!privs[i].isAggregate()) {
                 twoPrivs.add(privs[i]);
@@ -509,16 +509,16 @@ public class AccessControlListTest exten
         }
 
         AccessControlList acl = getList(acMgr, path);
-        Privilege privilege = (Privilege) twoPrivs.get(0);
+        Privilege privilege = twoPrivs.get(0);
         // add first privilege:
         acl.addAccessControlEntry(testPrincipal, new Privilege[] {privilege});
 
         // add a second privilege (but not specifying the privilege added before)
         // -> the first privilege must not be removed.
-        Privilege privilege2 = (Privilege) twoPrivs.get(1);
+        Privilege privilege2 = twoPrivs.get(1);
         acl.addAccessControlEntry(testPrincipal, new Privilege[] {privilege2});
 
-        List currentPrivileges = currentPrivileges(acl, testPrincipal);
+        List<Privilege> currentPrivileges = currentPrivileges(acl, testPrincipal);
         assertTrue("'AccessControlList.addAccessControlEntry' must not remove privileges
added before", currentPrivileges.containsAll(twoPrivs));
     }
 }

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlPolicyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlPolicyTest.java?rev=1214282&r1=1214281&r2=1214282&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlPolicyTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlPolicyTest.java
Wed Dec 14 15:02:43 2011
@@ -48,7 +48,7 @@ public class AccessControlPolicyTest ext
     private static Logger log = LoggerFactory.getLogger(AccessControlPolicyTest.class);
 
     private String path;
-    private Map addedPolicies = new HashMap();
+    private Map<String, AccessControlPolicy> addedPolicies = new HashMap<String,
AccessControlPolicy>();
 
     protected void setUp() throws Exception {
         super.setUp();
@@ -62,9 +62,9 @@ public class AccessControlPolicyTest ext
 
     protected void tearDown() throws Exception {
         try {
-            for (Iterator it = addedPolicies.keySet().iterator(); it.hasNext();) {
-                String path = it.next().toString();
-                AccessControlPolicy policy = (AccessControlPolicy) addedPolicies.get(path);
+            for (Iterator<String> it = addedPolicies.keySet().iterator(); it.hasNext();)
{
+                String path = it.next();
+                AccessControlPolicy policy = addedPolicies.get(path);
                 acMgr.removePolicy(path, policy);
             }
             superuser.save();
@@ -130,7 +130,7 @@ public class AccessControlPolicyTest ext
         checkCanReadAc(path);
         // call must succeed without exception
         AccessControlPolicyIterator it = acMgr.getApplicablePolicies(path);
-        Set acps = new HashSet();
+        Set<AccessControlPolicy> acps = new HashSet<AccessControlPolicy>();
 
         while (it.hasNext()) {
             AccessControlPolicy policy = it.nextAccessControlPolicy();
@@ -144,7 +144,7 @@ public class AccessControlPolicyTest ext
         checkCanReadAc(path);
         // call must succeed without exception
         AccessControlPolicyIterator it = acMgr.getApplicablePolicies(path);
-        Set acps = new HashSet();
+        Set<AccessControlPolicy> acps = new HashSet<AccessControlPolicy>();
         while (it.hasNext()) {
             acps.add(it.nextAccessControlPolicy());
         }
@@ -236,7 +236,7 @@ public class AccessControlPolicyTest ext
     public void testSetPolicyIsTransient() throws RepositoryException, AccessDeniedException,
NotExecutableException {
         checkCanModifyAc(path);
 
-        List currentPolicies = Arrays.asList(acMgr.getPolicies(path));
+        List<AccessControlPolicy> currentPolicies = Arrays.asList(acMgr.getPolicies(path));
         AccessControlPolicyIterator it = acMgr.getApplicablePolicies(path);
         if (it.hasNext()) {
             AccessControlPolicy policy = it.nextAccessControlPolicy();
@@ -274,7 +274,7 @@ public class AccessControlPolicyTest ext
         Session s2 = null;
         try {
             s2 = getHelper().getSuperuserSession();
-            List plcs = Arrays.asList(getAccessControlManager(s2).getPolicies(path));
+            List<AccessControlPolicy> plcs = Arrays.asList(getAccessControlManager(s2).getPolicies(path));
             // TODO: check again if policies can be compared with equals!
             assertTrue("Policy must be visible to another superuser session.", plcs.contains(policy));
         } finally {

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/RSessionAccessControlDiscoveryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/RSessionAccessControlDiscoveryTest.java?rev=1214282&r1=1214281&r2=1214282&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/RSessionAccessControlDiscoveryTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/RSessionAccessControlDiscoveryTest.java
Wed Dec 14 15:02:43 2011
@@ -59,7 +59,7 @@ public class RSessionAccessControlDiscov
     }
 
     public void testGetPrivileges() throws RepositoryException {
-        List privs = Arrays.asList(testAcMgr.getPrivileges(testPath));
+        List<Privilege> privs = Arrays.asList(testAcMgr.getPrivileges(testPath));
         Privilege readPrivilege = testAcMgr.privilegeFromName(Privilege.JCR_READ);
         assertTrue("A read-only session must have READ access to the test node.",
                 privs.contains(readPrivilege));



Mime
View raw message