From do-not-reply at jboss.org Mon Jun 14 07:40:29 2010 Content-Type: multipart/mixed; boundary="===============1037871666859599002==" MIME-Version: 1.0 From: do-not-reply at jboss.org To: exo-jcr-commits at lists.jboss.org Subject: [exo-jcr-commits] exo-jcr SVN: r2571 - kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/utils/secure. Date: Mon, 14 Jun 2010 07:40:29 -0400 Message-ID: <201006141140.o5EBeTtk011434@svn01.web.mwc.hst.phx2.redhat.com> --===============1037871666859599002== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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/ut= ils/secure/AbstractSecureCollectionsTest.java kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/ut= ils/secure/TestSecureList.java kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/ut= ils/secure/TestSecureSet.java Log: EXOJCR-770: Was added comments and names of exceptions. Modified: kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/com= mons/utils/secure/AbstractSecureCollectionsTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/u= tils/secure/AbstractSecureCollectionsTest.java 2010-06-14 10:52:13 UTC (rev= 2570) +++ kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/u= tils/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 Nikolay Zamosenchuk - * @version $Id: TestSecureSet.java 34360 2009-07-22 23:58:59Z nzamosenchu= k $ + * @version $Id$ */ = public abstract class AbstractSecureCollectionsTest extends TestCase @@ -43,7 +44,7 @@ * Run privileged action with given privileges. */ protected T doActionWithPermissions(PrivilegedExceptionAction ac= tion, Permission... permissions) - throws Exception + throws PrivilegedActionException { Permissions allPermissions =3D new Permissions(); for (Permission permission : permissions) Property changes on: kernel/trunk/exo.kernel.commons/src/test/java/org/exop= latform/commons/utils/secure/AbstractSecureCollectionsTest.java ___________________________________________________________________ Name: svn:keywords + Id Modified: kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/com= mons/utils/secure/TestSecureList.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/u= tils/secure/TestSecureList.java 2010-06-14 10:52:13 UTC (rev 2570) +++ kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/u= tils/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 list; = @Override - protected void setUp() + protected void setUp() throws PrivilegedActionException { // establishment of protected set prior to each test = list =3D SecureCollections.secureList(new ArrayList(), MODIF= Y_PERMISSION); @@ -42,7 +43,7 @@ // giving MODIFY_PERMISSION doActionWithPermissions(new PrivilegedExceptionAction() { - 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() { - 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() { - 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 PrivilegedActionExcepti= on { try { // giving MODIFY_PERMISSION doActionWithPermissions(new PrivilegedExceptionAction() { - 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() { - 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 PrivilegedAc= tionException { try { // giving MODIFY_PERMISSION doActionWithPermissions(new PrivilegedExceptionAction() { - public Object run() throws Exception + public Object run() throws AccessControlException { ListIterator iterator =3D 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 PrivilegedActionExcepti= on { try { // giving no permissions doActionWithPermissions(new PrivilegedExceptionAction() { - 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 PrivilegedActionExcept= ion { try { // giving MODIFY_PERMISSION doActionWithPermissions(new PrivilegedExceptionAction() { - public Object run() throws Exception + public Object run() throws AccessControlException { Iterator it =3D 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/exop= latform/commons/utils/secure/TestSecureList.java ___________________________________________________________________ Name: svn:keywords + Id Modified: kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/com= mons/utils/secure/TestSecureSet.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/u= tils/secure/TestSecureSet.java 2010-06-14 10:52:13 UTC (rev 2570) +++ kernel/trunk/exo.kernel.commons/src/test/java/org/exoplatform/commons/u= tils/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 set; = @Override - protected void setUp() + protected void setUp() throws PrivilegedActionException { // establishment of protected set prior to each test = set =3D SecureCollections.secureSet(new HashSet(), MODIFY_PE= RMISSION); @@ -41,7 +42,7 @@ // giving MODIFY_PERMISSION doActionWithPermissions(new PrivilegedExceptionAction() { - 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() { - 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() { - 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() { - 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() { - 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 PrivilegedActionExcep= tion { try { // giving MODIFY_PERMISSION doActionWithPermissions(new PrivilegedExceptionAction() { - 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 PrivilegedActionExc= eption { try { // giving MODIFY_PERMISSION doActionWithPermissions(new PrivilegedExceptionAction() { - public Object run() throws Exception + public Object run() throws AccessControlException { Iterator iterator =3D set.iterator(); return null; } }, MODIFY_PERMISSION); } - catch (Exception e) + catch (AccessControlException e) { fail("Modification should be permitted."); } } = - public void testSecureSetIteratorRemovePermitted() + public void testSecureSetIteratorRemovePermitted() throws PrivilegedAct= ionException { try { // giving MODIFY_PERMISSION doActionWithPermissions(new PrivilegedExceptionAction() { - public Object run() throws Exception + public Object run() throws AccessControlException { Iterator iterator =3D 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() { - 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/exop= latform/commons/utils/secure/TestSecureSet.java ___________________________________________________________________ Name: svn:keywords + Id --===============1037871666859599002==--