@Test
  public void testClassLoading() throws IOException {

    ClassLoader systemLoader = Thread.currentThread().getContextClassLoader();

    // test with system classloader
    String configName = "type.class.property";
    String configNameDefault = ConfigUtils.class.getName();

    ConfigDef configDef = new ConfigDef();
    configDef.define(configName, Type.CLASS, configNameDefault,
        ConfigDef.Importance.MEDIUM, "system class");

    AbstractConfig config = new AbstractConfig(configDef, new HashMap<>());

    Class<?> systemKlass = config.getClass(configName);
    assertEquals(systemLoader, systemKlass.getClassLoader());

    // test with custom, child-first, classloader
    Set<String> allowedKlasses = Collections.singleton(configNameDefault);
    List<URL> pluginUrls = Collections.singletonList(Paths.get("target/classes/").toUri().toURL());
    URLClassLoader pluginLoader = new PluginClassLoader(pluginUrls.toArray(new URL[0]), systemLoader, allowedKlasses);

    try {
      Thread.currentThread().setContextClassLoader(pluginLoader);

      configDef = new ConfigDef();
      configDef.define(configName, Type.CLASS, configNameDefault, ConfigDef.Importance.MEDIUM, "plugin class");

      config = new AbstractConfig(configDef, new HashMap<>());

      Class<?> pluginKlass = config.getClass(configName);
      assertEquals(pluginLoader, pluginKlass.getClassLoader());
      assertNotEquals(pluginKlass, systemKlass);
      assertEquals(pluginKlass.getName(), systemKlass.getName());
    } finally {
      Thread.currentThread().setContextClassLoader(systemLoader);
    }
}