### Question:
ClassLoaderUtils { static ClassLoader getContextClassLoader() { final SecurityManager sm = System.getSecurityManager(); if (sm != null) { return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() { public ClassLoader run() { ClassLoader loader = Thread.currentThread().getContextClassLoader(); return loader != null ? loader : ClassLoader.getSystemClassLoader(); } }); } ClassLoader loader = Thread.currentThread().getContextClassLoader(); return loader != null ? loader : ClassLoader.getSystemClassLoader(); } private  ClassLoaderUtils(); static ClassLoaderHolder setThreadContextClassloader(final ClassLoader newLoader); static ClassLoader getURLClassLoader(
        final URL[] urls, final ClassLoader parent
    ); static ClassLoader getURLClassLoader(
        final List<URL> urlList, final ClassLoader parent
    ); static URL getResource(String resourceName, Class<?> callingClass); static List<URL> getResources(String resourceName, Class<?> callingClass); static InputStream getResourceAsStream(String resourceName, Class<?> callingClass); static Class<?> loadClass(String className, Class<?> callingClass); static Class<? extends T> loadClass(String className, Class<?> callingClass, Class<T> type); static String getClassLoaderName(Class<?> type); static Class<?> loadClassFromContextLoader(String className);  }### Answer:
@Test public void getContextClassLoader() throws MalformedURLException { final ClassLoader nullLoader = null; final ClassLoader jvmAppLoader = ClassLoader.getSystemClassLoader(); final ClassLoader jvmExtLoader = jvmAppLoader.getParent(); final ClassLoader testClassLoader = ClassLoaderUtilsTest.class.getClassLoader(); final ClassLoader clildLoader = new URLClassLoader(new URL[]{new URL("file:/.")}); final ClassLoader previousTCCL = Thread.currentThread().getContextClassLoader(); try { setTCCL(nullLoader); assertEquals("TCCL == null; wrong loader returned; expected JVM App loader", jvmAppLoader, ClassLoaderUtils.getContextClassLoader()); setTCCL(jvmAppLoader); assertEquals("TCCL == JVM App loader; wrong loader returned; expected JVM App loader", jvmAppLoader, ClassLoaderUtils.getContextClassLoader()); setTCCL(jvmExtLoader); assertEquals("TCCL == JVM Ext loader; wrong loader returned; expected JVM Ext loader", jvmExtLoader, ClassLoaderUtils.getContextClassLoader()); setTCCL(testClassLoader); assertEquals("TCCL == this test laoder; wrong loader returned; expected JVM App loader", testClassLoader, ClassLoaderUtils.getContextClassLoader()); setTCCL(clildLoader); assertEquals("TCCL == random child loader, wrong loader returned; expected child of test class loader", clildLoader, ClassLoaderUtils.getContextClassLoader()); } finally { setTCCL(previousTCCL); } }