@Test
public void test() throws Exception {

    final ClassLoader tempCL = new TempClassLoader(this.getClass().getClassLoader());
    Class<?> clazz;
    // normal classes should be loaded by the temp class loader
    clazz = tempCL.loadClass(TempClassLoaderTest.class.getName());
    assertSame(tempCL, clazz.getClassLoader());
    // classes in java.* should not be loaded by the temp class loader
    clazz = tempCL.loadClass(javax.persistence.EntityManager.class.getName());
    assertNotSame(tempCL, clazz.getClassLoader());
    // classes in javax.* should not be loaded by the temp class loader
    clazz = tempCL.loadClass(java.lang.String.class.getName());
    assertNotSame(tempCL, clazz.getClassLoader());
    // annotations should not be loaded by the temp class loader
    clazz = tempCL.loadClass(SampleAnnotation.class.getName());
    assertSame(tempCL, clazz.getClassLoader());
}