ClassLoaderPool { public static void register(String contextName, ClassLoader classLoader) { _classLoaders.put(contextName, classLoader); _contextNames.put(classLoader, contextName); Map.Entry<String, Version> entry = _parseContextName(contextName); if (entry == null) { return; } _fallbackClassLoaders.compute( entry.getKey(), (key, classLoaders) -> { if (classLoaders == null) { classLoaders = new ConcurrentSkipListMap<>(); } classLoaders.put(entry.getValue(), classLoader); return classLoaders; }); }  static ClassLoader getClassLoader(String contextName); static String getContextName(ClassLoader classLoader); static void register(String contextName, ClassLoader classLoader); static void unregister(ClassLoader classLoader); static void unregister(String contextName);  }
@Test public void testRegisterWithNullClassLoader() { try { ClassLoaderPool.register("null", null); Assert.fail("null classLoader will cause NullPointerException"); } catch (NullPointerException nullPointerException) { Assert.assertEquals( NullPointerException.class, nullPointerException.getClass()); } }
@Test public void testRegisterWithNullContextName() { try { ClassLoaderPool.register(null, null); Assert.fail("null contextName will cause NullPointerException"); } catch (NullPointerException nullPointerException) { Assert.assertEquals( NullPointerException.class, nullPointerException.getClass()); } }