[jboss-cvs] JBossAS SVN: r59964 - projects/test/trunk/test/src/main/org/jboss/test.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jan 24 05:53:34 EST 2007
Author: alesj
Date: 2007-01-24 05:53:34 -0500 (Wed, 24 Jan 2007)
New Revision: 59964
Modified:
projects/test/trunk/test/src/main/org/jboss/test/AbstractTestCaseWithSetup.java
Log:
Added suspend/resume SecurityManager.
Modified: projects/test/trunk/test/src/main/org/jboss/test/AbstractTestCaseWithSetup.java
===================================================================
--- projects/test/trunk/test/src/main/org/jboss/test/AbstractTestCaseWithSetup.java 2007-01-24 09:41:46 UTC (rev 59963)
+++ projects/test/trunk/test/src/main/org/jboss/test/AbstractTestCaseWithSetup.java 2007-01-24 10:53:34 UTC (rev 59964)
@@ -21,6 +21,9 @@
*/
package org.jboss.test;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -34,16 +37,18 @@
* all conforming unit test methods run, a single class wide
* AbstractTestDelegate is created by either the fist call to the setUp
* method, or the suite AbstractTestSetup wrapper created by suite(Class).
- *
+ *
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @author Scott.Stark at jboss.org
* @version $Revision$
*/
public class AbstractTestCaseWithSetup extends AbstractTestCase
{
- /** Single run setup */
+ /**
+ * Single run setup
+ */
private AbstractTestSetup setup;
-
+
/**
* Create a new test case
*
@@ -64,16 +69,17 @@
/**
* Enable trace logging for the given category name.
+ *
* @param name - the logging category to enable trace level logging for.
*/
protected void enableTrace(String name)
{
getDelegate().enableTrace(name);
}
-
+
/**
* Get the delegate
- *
+ *
* @return the delegate
*/
protected AbstractTestDelegate getDelegate()
@@ -85,7 +91,7 @@
* Create a AbstractTestSetup wrapper for this class/instance to initialize
* the AbstractTestDelegate if the AbstractTestSetup.delegate singleton
* has not been initialized.
- *
+ *
* @throws Exception
*/
protected void setUp() throws Exception
@@ -110,7 +116,7 @@
* Bootstrap the test for the case of running all tests in clazz.
* This creates an AbstractTestSetup wrapper around TestSuite(clazz) to
* initialize the AbstractTestDelegate once for the suite.
- *
+ *
* @param clazz the test class
* @return the bootstrap wrapper test
*/
@@ -119,4 +125,33 @@
TestSuite suite = new TestSuite(clazz);
return new AbstractTestSetup(clazz, suite);
}
+
+ /**
+ * Suspend security manager.
+ *
+ * @return current security manager instance
+ */
+ protected SecurityManager suspendSecurity()
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<SecurityManager>()
+ {
+ public SecurityManager run()
+ {
+ SecurityManager result = System.getSecurityManager();
+ System.setSecurityManager(null);
+ return result;
+ }
+ });
+ }
+
+ /**
+ * Resume / set security manager.
+ *
+ * @param securityManager security manager to set
+ */
+ protected void resumeSecurity(SecurityManager securityManager)
+ {
+ System.setSecurityManager(securityManager);
+ }
+
}
More information about the jboss-cvs-commits
mailing list