org.apache.commons.logging.security
Class SecurityForbiddenTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.apache.commons.logging.security.SecurityForbiddenTestCase
All Implemented Interfaces:
junit.framework.Test

public class SecurityForbiddenTestCase
extends junit.framework.TestCase

Tests for logging with a security policy that forbids JCL access to anything.

Performing tests with security permissions disabled is tricky, as building error messages on failure requires certain security permissions. If the security manager blocks these, then the test can fail without the error messages being output.

This class has only one unit test, as we are (in part) checking behaviour in the static block of the LogFactory class. As that class cannot be unloaded after being loaded into a classloader, the only workaround is to use the PathableClassLoader approach to ensure each test is run in its own classloader, and use a separate testcase class for each test.


Nested Class Summary
static class SecurityForbiddenTestCase.CustomHashtable
           
 
Constructor Summary
SecurityForbiddenTestCase()
           
 
Method Summary
 void setUp()
           
static junit.framework.Test suite()
          Return the tests included in this test suite.
 void tearDown()
           
 void testAllForbidden()
          Test what happens when JCL is run with absolutely no security priveleges at all, including reading system properties.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SecurityForbiddenTestCase

public SecurityForbiddenTestCase()
Method Detail

suite

public static junit.framework.Test suite()
                                  throws Exception
Return the tests included in this test suite.

Throws:
Exception

setUp

public void setUp()
Overrides:
setUp in class junit.framework.TestCase

tearDown

public void tearDown()
Overrides:
tearDown in class junit.framework.TestCase

testAllForbidden

public void testAllForbidden()
Test what happens when JCL is run with absolutely no security priveleges at all, including reading system properties. Everything should fall back to the built-in defaults.



Copyright © 2001-2009 Apache Software Foundation. All Rights Reserved.