[exo-jcr-commits] exo-jcr SVN: r2571 - kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/utils/secure.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Jun 14 07:40:29 EDT 2010


Author: natasha.vakulenko
Date: 2010-06-14 07:40:29 -0400 (Mon, 14 Jun 2010)
New Revision: 2571

Modified:
   kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/utils/secure/AbstractSecureCollectionsTest.java
   kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/utils/secure/TestSecureList.java
   kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/utils/secure/TestSecureSet.java
Log:
EXOJCR-770: Was added comments and names of exceptions.

Modified: kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/utils/secure/AbstractSecureCollectionsTest.java
===================================================================
--- kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/utils/secure/AbstractSecureCollectionsTest.java	2010-06-14 10:52:13 UTC (rev 2570)
+++ kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/utils/secure/AbstractSecureCollectionsTest.java	2010-06-14 11:40:29 UTC (rev 2571)
@@ -23,6 +23,7 @@
 import java.net.URL;
 import java.security.AccessControlContext;
 import java.security.AccessController;
+import java.security.PrivilegedActionException;
 import java.security.CodeSource;
 import java.security.Permission;
 import java.security.Permissions;
@@ -31,7 +32,7 @@
 
 /**
  * @author <a href="mailto:nikolazius at gmail.com">Nikolay Zamosenchuk</a>
- * @version $Id: TestSecureSet.java 34360 2009-07-22 23:58:59Z nzamosenchuk $
+ * @version $Id$
  */
 
 public abstract class AbstractSecureCollectionsTest extends TestCase
@@ -43,7 +44,7 @@
     * Run privileged action with given privileges.
     */
    protected <T> T doActionWithPermissions(PrivilegedExceptionAction<T> action, Permission... permissions)
-      throws Exception
+      throws PrivilegedActionException
    {
       Permissions allPermissions = new Permissions();
       for (Permission permission : permissions)


Property changes on: kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/utils/secure/AbstractSecureCollectionsTest.java
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/utils/secure/TestSecureList.java
===================================================================
--- kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/utils/secure/TestSecureList.java	2010-06-14 10:52:13 UTC (rev 2570)
+++ kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/utils/secure/TestSecureList.java	2010-06-14 11:40:29 UTC (rev 2571)
@@ -16,8 +16,9 @@
  */
 package org.exoplatform.commons.utils.secure;
 
-import java.security.Permission;
+import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
+import java.security.AccessControlException;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -33,7 +34,7 @@
    private List<String> list;
 
    @Override
-   protected void setUp()
+   protected void setUp() throws PrivilegedActionException
    {
       // establishment of protected set prior to each test 
       list = SecureCollections.secureList(new ArrayList<String>(), MODIFY_PERMISSION);
@@ -42,7 +43,7 @@
          // giving MODIFY_PERMISSION
          doActionWithPermissions(new PrivilegedExceptionAction<Object>()
          {
-            public Object run() throws Exception
+            public Object run() throws AccessControlException
             {
                list.add("firstString");
                list.add("secondString");
@@ -50,13 +51,14 @@
             }
          }, MODIFY_PERMISSION);
       }
-      catch (Exception e)
+      catch (AccessControlException e)
       {
+         // ok
       }
    }
 
    @Override
-   protected void tearDown()
+   protected void tearDown() throws PrivilegedActionException
    {
       // cleaning protected list after each test
       try
@@ -64,26 +66,27 @@
          // giving MODIFY_PERMISSION
          doActionWithPermissions(new PrivilegedExceptionAction<Object>()
          {
-            public Object run() throws Exception
+            public Object run() throws AccessControlException
             {
                list.clear();
                return null;
             }
          }, MODIFY_PERMISSION);
       }
-      catch (Exception e)
+      catch (AccessControlException e)
       {
+         // ok
       }
    }
 
-   public void testSecureListAddDenied()
+   public void testSecureListAddDenied() throws PrivilegedActionException
    {
       try
       {
          // giving no permissions
          doActionWithPermissions(new PrivilegedExceptionAction<Object>()
          {
-            public Object run() throws Exception
+            public Object run() throws AccessControlException
             {
                list.add("string");
                return null;
@@ -91,39 +94,40 @@
          });
          fail("Modification should be denied.");
       }
-      catch (Exception e)
+      catch (AccessControlException e)
       {
+         // ok
       }
    }
 
-   public void testSecureListAddPermitted()
+   public void testSecureListAddPermitted() throws PrivilegedActionException
    {
       try
       {
          // giving MODIFY_PERMISSION
          doActionWithPermissions(new PrivilegedExceptionAction<Object>()
          {
-            public Object run() throws Exception
+            public Object run() throws AccessControlException
             {
                list.add(0, "string");
                return null;
             }
          }, MODIFY_PERMISSION);
       }
-      catch (Exception e)
+      catch (AccessControlException e)
       {
          fail("Modification should be permitted.");
       }
    }
 
-   public void testSecureListClearDenied()
+   public void testSecureListClearDenied() throws PrivilegedActionException
    {
       try
       {
          // giving no permissions
          doActionWithPermissions(new PrivilegedExceptionAction<Object>()
          {
-            public Object run() throws Exception
+            public Object run() throws AccessControlException
             {
                list.clear();
                return null;
@@ -131,19 +135,20 @@
          });
          fail("Modification should be denied.");
       }
-      catch (Exception e)
+      catch (AccessControlException e)
       {
+         // ok
       }
    }
 
-   public void testSecureListIteratorRemovePermitted()
+   public void testSecureListIteratorRemovePermitted() throws PrivilegedActionException
    {
       try
       {
          // giving MODIFY_PERMISSION
          doActionWithPermissions(new PrivilegedExceptionAction<Object>()
          {
-            public Object run() throws Exception
+            public Object run() throws AccessControlException
             {
                ListIterator<String> iterator = list.listIterator();
                iterator.next();
@@ -152,20 +157,20 @@
             }
          }, MODIFY_PERMISSION);
       }
-      catch (Exception e)
+      catch (AccessControlException e)
       {
          fail("Modification should be permitted.");
       }
    }
 
-   public void testSecureListRemoveDenied()
+   public void testSecureListRemoveDenied() throws PrivilegedActionException
    {
       try
       {
          // giving no permissions
          doActionWithPermissions(new PrivilegedExceptionAction<Object>()
          {
-            public Object run() throws Exception
+            public Object run() throws AccessControlException
             {
                list.remove(0);
                return null;
@@ -173,26 +178,27 @@
          });
          fail("Modification should be denied.");
       }
-      catch (Exception e)
+      catch (AccessControlException e)
       {
+         // ok
       }
    }
 
-   public void testSecureIteratorPermitted()
+   public void testSecureIteratorPermitted() throws PrivilegedActionException
    {
       try
       {
          // giving MODIFY_PERMISSION
          doActionWithPermissions(new PrivilegedExceptionAction<Object>()
          {
-            public Object run() throws Exception
+            public Object run() throws AccessControlException
             {
                Iterator<String> it = list.iterator();
                return null;
             }
          }, MODIFY_PERMISSION);
       }
-      catch (Exception e)
+      catch (AccessControlException e)
       {
          fail("Modification should be permitted.");
       }


Property changes on: kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/utils/secure/TestSecureList.java
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/utils/secure/TestSecureSet.java
===================================================================
--- kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/utils/secure/TestSecureSet.java	2010-06-14 10:52:13 UTC (rev 2570)
+++ kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/utils/secure/TestSecureSet.java	2010-06-14 11:40:29 UTC (rev 2571)
@@ -16,8 +16,9 @@
  */
 package org.exoplatform.commons.utils.secure;
 
-import java.security.Permissions;
 import java.security.PrivilegedExceptionAction;
+import java.security.PrivilegedActionException;
+import java.security.AccessControlException;
 import java.util.HashSet;
 import java.util.Set;
 import java.util.Iterator;
@@ -32,7 +33,7 @@
    private Set<String> set;
 
    @Override
-   protected void setUp()
+   protected void setUp() throws PrivilegedActionException
    {
       // establishment of protected set prior to each test 
       set = SecureCollections.secureSet(new HashSet<String>(), MODIFY_PERMISSION);
@@ -41,7 +42,7 @@
          // giving MODIFY_PERMISSION
          doActionWithPermissions(new PrivilegedExceptionAction<Object>()
          {
-            public Object run() throws Exception
+            public Object run() throws AccessControlException
             {
                set.add("firstString");
                set.add("secondString");
@@ -49,13 +50,14 @@
             }
          }, MODIFY_PERMISSION);
       }
-      catch (Exception e)
+      catch (AccessControlException e)
       {
+         // ok         
       }
    }
 
    @Override
-   protected void tearDown()
+   protected void tearDown() throws PrivilegedActionException
    {
       // cleaning protected set after each test
       try
@@ -63,46 +65,47 @@
          // giving MODIFY_PERMISSION
          doActionWithPermissions(new PrivilegedExceptionAction<Object>()
          {
-            public Object run() throws Exception
+            public Object run() throws AccessControlException
             {
                set.clear();
                return null;
             }
          }, MODIFY_PERMISSION);
       }
-      catch (Exception e)
+      catch (AccessControlException e)
       {
+         // ok         
       }
    }
 
-   public void testSecureSetAddPermitted()
+   public void testSecureSetAddPermitted() throws PrivilegedActionException
    {
       try
       {
          // giving MODIFY_PERMISSION
          doActionWithPermissions(new PrivilegedExceptionAction<Object>()
          {
-            public Object run() throws Exception
+            public Object run() throws AccessControlException
             {
                set.add("string");
                return null;
             }
          }, MODIFY_PERMISSION);
       }
-      catch (Exception e)
+      catch (AccessControlException e)
       {
          fail("Modification should be permitted.");
       }
    }
 
-   public void testSecureSetAddDenied()
+   public void testSecureSetAddDenied() throws PrivilegedActionException
    {
       try
       {
          // giving no permissions
          doActionWithPermissions(new PrivilegedExceptionAction<Object>()
          {
-            public Object run() throws Exception
+            public Object run() throws AccessControlException
             {
                set.add("string");
                return null;
@@ -110,19 +113,20 @@
          });
          fail("Modification should be denied.");
       }
-      catch (Exception e)
+      catch (AccessControlException e)
       {
+         // ok
       }
    }
 
-   public void testSecureSetRemoveDenied()
+   public void testSecureSetRemoveDenied() throws PrivilegedActionException
    {
       try
       {
          // giving no permissions
          doActionWithPermissions(new PrivilegedExceptionAction<Object>()
          {
-            public Object run() throws Exception
+            public Object run() throws AccessControlException
             {
                set.remove(0);
                return null;
@@ -130,59 +134,60 @@
          });
          fail("Modification should be denied.");
       }
-      catch (Exception e)
+      catch (AccessControlException e)
       {
+         // ok
       }
    }
 
-   public void testSecureSetRemovePermitted()
+   public void testSecureSetRemovePermitted() throws PrivilegedActionException
    {
       try
       {
          // giving MODIFY_PERMISSION
          doActionWithPermissions(new PrivilegedExceptionAction<Object>()
          {
-            public Object run() throws Exception
+            public Object run() throws AccessControlException
             {
                set.remove(0);
                return null;
             }
          }, MODIFY_PERMISSION);
       }
-      catch (Exception e)
+      catch (AccessControlException e)
       {
          fail("Modification should be permitted.");
       }
    }
 
-   public void testSecureSetIteratorPermitted()
+   public void testSecureSetIteratorPermitted() throws PrivilegedActionException
    {
       try
       {
          // giving MODIFY_PERMISSION
          doActionWithPermissions(new PrivilegedExceptionAction<Object>()
          {
-            public Object run() throws Exception
+            public Object run() throws AccessControlException
             {
                Iterator<String> iterator = set.iterator();
                return null;
             }
          }, MODIFY_PERMISSION);
       }
-      catch (Exception e)
+      catch (AccessControlException e)
       {
          fail("Modification should be permitted.");
       }
    }
 
-   public void testSecureSetIteratorRemovePermitted()
+   public void testSecureSetIteratorRemovePermitted() throws PrivilegedActionException
    {
       try
       {
          // giving MODIFY_PERMISSION
          doActionWithPermissions(new PrivilegedExceptionAction<Object>()
          {
-            public Object run() throws Exception
+            public Object run() throws AccessControlException
             {
                Iterator<String> iterator = set.iterator();
                iterator.next();
@@ -191,20 +196,20 @@
             }
          }, MODIFY_PERMISSION);
       }
-      catch (Exception e)
+      catch (AccessControlException e)
       {
          fail("Modification should be permitted.");
       }
    }
 
-   public void testSecureSetClearDenied()
+   public void testSecureSetClearDenied() throws PrivilegedActionException
    {
       try
       {
          // giving no permissions
          doActionWithPermissions(new PrivilegedExceptionAction<Object>()
          {
-            public Object run() throws Exception
+            public Object run() throws AccessControlException
             {
                set.clear();
                return null;
@@ -212,8 +217,9 @@
          });
          fail("Modification should be denied.");
       }
-      catch (Exception e)
+      catch (AccessControlException e)
       {
+         // ok
       }
    }
 }


Property changes on: kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/utils/secure/TestSecureSet.java
___________________________________________________________________
Name: svn:keywords
   + Id



More information about the exo-jcr-commits mailing list