org.apache.commons.logging
Class AltHashtableTestCase

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

public class AltHashtableTestCase
extends junit.framework.TestCase

Test the ability to force the LogFactory class to use some arbitrary Hashtable implementation to store its mapping from context-classloader -> LogFactory object.

This is done by


Constructor Summary
AltHashtableTestCase()
           
 
Method Summary
 void setUp()
          Set up before each test.
static junit.framework.Test suite()
           
 void testPutCalled()
          Verify that when LogFactory sees a context-classloader for the first time that it creates a new entry in the LogFactory.factories hashmap.
 void testType()
          Verify that initialising the LogFactory class will cause it to instantiate an object of type specified in system property "org.apache.commons.logging.LogFactory.HashtableImpl".
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, tearDown, 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

AltHashtableTestCase

public AltHashtableTestCase()
Method Detail

suite

public static junit.framework.Test suite()
                                  throws Exception
Throws:
Exception

setUp

public void setUp()
Set up before each test.

This method ensures that the appropriate system property is defined to force the LogFactory class to use the AltHashtable class as its Hashtable implementation for storing factories in.

This does make the assumption that whatever JVM we are running in doesn't initialise classes until they are actually referenced (ie the LogFactory class hasn't been initialised before this method is called). This is true of all JVMs I know of; and if it isn't then this test will fail and someone will tell us.

Overrides:
setUp in class junit.framework.TestCase

testType

public void testType()
Verify that initialising the LogFactory class will cause it to instantiate an object of type specified in system property "org.apache.commons.logging.LogFactory.HashtableImpl".


testPutCalled

public void testPutCalled()
                   throws Exception
Verify that when LogFactory sees a context-classloader for the first time that it creates a new entry in the LogFactory.factories hashmap. In particular, this checks that this process works ok when a system property has been used to specify an alternative Hashtable implementation for LogFactory to use.

Throws:
Exception


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