@Test
  public void testAddJarDataNucleusUnCaching() throws Exception {
    Path jarFilePath = getHiveContribJarPath();
    // We need a new connection object as we'll check the cache size after connection close
    Connection conn =
        getConnection(miniHS2.getJdbcURL(testDbName), System.getProperty("user.name"), "password");
    Statement stmt = conn.createStatement();
    int mapSizeAfterClose;
    // Add the jar file
    stmt.execute("ADD JAR " + jarFilePath.toString());
    // Create a temporary function using the jar
    stmt.execute("CREATE TEMPORARY FUNCTION add_func AS '" + testUdfClassName + "'");
    ResultSet res = stmt.executeQuery("DESCRIBE FUNCTION add_func");
    checkForNotExist(res);
    // Execute the UDF
    stmt.execute("SELECT add_func(int_col, 1) from " + tableName + " limit 1");
    // Close the connection
    conn.close();
    mapSizeAfterClose = getNucleusClassLoaderResolverMapSize();
    System.out.println("classLoaderResolverMap size after connection close: " + mapSizeAfterClose);
    // Cache size should be 0 now
    Assert.assertTrue("Failed; NucleusContext classLoaderResolverMap size: " + mapSizeAfterClose,
        mapSizeAfterClose == 0);
  }
Tests that DataNucleus' NucleusContext.classLoaderResolverMap clears cached class objects
(& hence doesn't leak classloaders) on closing any session

@throws Exception
itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcWithMiniHS2.java