edu.rice.cs.util.classloader
Class StickyClassLoaderTest

java.lang.Object
  |
  +--junit.framework.Assert
        |
        +--junit.framework.TestCase
              |
              +--edu.rice.cs.util.classloader.StickyClassLoaderTest
All Implemented Interfaces:
Test

public class StickyClassLoaderTest
extends TestCase

Test cases for StickyClassLoader.

Version:
$Id: StickyClassLoaderTest.java,v 1.4 2002/02/21 04:56:25 brianstoler Exp $

Inner Class Summary
static class StickyClassLoaderTest.A
           
static interface StickyClassLoaderTest.BMaker
           
static class StickyClassLoaderTest.One
           
static class StickyClassLoaderTest.Two
           
 
Field Summary
private  ClassLoader myLoader
           
private  String myName
           
 
Fields inherited from class junit.framework.TestCase
fName
 
Constructor Summary
StickyClassLoaderTest(String name)
          Constructor.
 
Method Summary
static Test suite()
          Creates a test suite for JUnit to run.
 void testDoesntLoadSameClassTwice()
          Makes sure that a class that was loaded once before (implicitly) is not loaded a second time.
 void testLoaderRespectsOldList()
          Make sure getClass().getClassLoader() does not stick if the class was on the useOldLoader list.
 void testLoaderSticks()
          Make sure getClass().getClassLoader() sticks, regardless of where the class data came from.
 void testLoaderSticksTransitively()
          Make sure that if we load A through sticky loader, and A requires B to be loaded, B is also loaded through sticky loader.
 void testLoaderUsesSystemForJavaClasses()
          Make sure it works even for java.* classes.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, name, run, run, runBare, runTest, setName, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assert, assert, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertNotNull, assertNotNull, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

myName

private final String myName

myLoader

private final ClassLoader myLoader
Constructor Detail

StickyClassLoaderTest

public StickyClassLoaderTest(String name)
Constructor.
Parameters:
String - name
Method Detail

suite

public static Test suite()
Creates a test suite for JUnit to run.
Returns:
a test suite based on the methods in this class

testLoaderSticks

public void testLoaderSticks()
                      throws Throwable
Make sure getClass().getClassLoader() sticks, regardless of where the class data came from.

testLoaderUsesSystemForJavaClasses

public void testLoaderUsesSystemForJavaClasses()
                                        throws Throwable
Make sure it works even for java.* classes.

testLoaderRespectsOldList

public void testLoaderRespectsOldList()
                               throws Throwable
Make sure getClass().getClassLoader() does not stick if the class was on the useOldLoader list.

testLoaderSticksTransitively

public void testLoaderSticksTransitively()
                                  throws Throwable
Make sure that if we load A through sticky loader, and A requires B to be loaded, B is also loaded through sticky loader. We load the BMaker interface through the old loader so we can cast to that interface.

testDoesntLoadSameClassTwice

public void testDoesntLoadSameClassTwice()
                                  throws Throwable
Makes sure that a class that was loaded once before (implicitly) is not loaded a second time. This test corresponds to bug #520519. As of util-20020219-2255, this test case causes a LinkageError to be thrown, since One is loaded twice. This problem was caused by the StickyClassLoader not checking whether the class was already loaded before loading it!