package reflection;

import junit.UnitTestRunner;
import org.junit.Test;
import static org.junit.Assert.*;

public class ClassLoaderTest {
    
    public static void main(String[] args) {
        UnitTestRunner.run(ClassLoaderTest.class);
        

//        System.out.println(appCl.getParent());
//        System.out.println(appCl.getParent().getParent());
        
//        ClassLoader bootCl = Object.class.getClassLoader();
//        System.out.println("bootCl:"+bootCl);
//        ClassLoader appCl = ClassLoaderTest.class.getClassLoader();
//        System.out.println("appCl:"+appCl);
//        ClassLoader sysCl = ClassLoader.getSystemClassLoader();
//        System.out.println("sysCl:"+sysCl);
//        
//        System.out.println(Test.class.getClassLoader());
    }
    
    @Test
    public void sysClassLoader() {
        ClassLoader sysCl = ClassLoader.getSystemClassLoader();
        assertEquals("sun.misc.Launcher$AppClassLoader", sysCl.getClass().getName());
        ClassLoader extCl = sysCl.getParent();
        assertEquals("sun.misc.Launcher$ExtClassLoader", extCl.getClass().getName());
        ClassLoader bootCl = extCl.getParent();
        assertNull(bootCl);
    }
    
    //@Test
    public void test() {
        ClassLoader bootCl = Object.class.getClassLoader();
        ClassLoader appCl = ClassLoaderTest.class.getClassLoader();
        ClassLoader sysCl = ClassLoader.getSystemClassLoader();
        ClassLoader extCl = appCl.getParent();
        
        assertNull(bootCl);
        assertNotNull(appCl);
        assertNotNull(extCl);
        assertSame(appCl, sysCl);
    }
    
}

@@ -237,551 +237,14 @@
 s);%0A
-        %0A%0A//        System.out.println(appCl.getParent());%0A//        System.out.println(appCl.getParent().getParent());%0A        %0A//        ClassLoader bootCl = Object.class.getClassLoader();%0A//        System.out.println(%22bootCl:%22+bootCl);%0A//        ClassLoader appCl = ClassLoaderTest.class.getClassLoader();%0A//        System.out.println(%22appCl:%22+appCl);%0A//        ClassLoader sysCl = ClassLoader.getSystemClassLoader();%0A//        System.out.println(%22sysCl:%22+sysCl);%0A//        %0A//        System.out.println(Test.class.getClassLoader());%0A
     %7D%0A
+
     
@@ -431,32 +431,41 @@
 s().getName());%0A
+        %0A
         ClassLoa
@@ -573,32 +573,41 @@
 s().getName());%0A
+        %0A
         ClassLoa
@@ -685,10 +685,8 @@
     
-//
 @Tes
@@ -707,12 +707,22 @@
 oid 
-test
+getClassLoader
 () %7B
@@ -774,32 +774,69 @@
 tClassLoader();%0A
+        assertNull(bootCl);%0A        %0A
         ClassLoa
@@ -963,173 +963,29 @@
     
-ClassLoader extCl = appCl.getParent();%0A        %0A        assertNull(bootCl);%0A        assertNotNull(appCl);%0A        assertNotNull(extCl);%0A        assertSame(appCl, sys
+assertSame(sysCl, app
 Cl);

test ClassLoader