@Test
  public void testValidateTableCols() throws Throwable {

    try {
      String dbName = "compdb";
      String tblName = "comptbl";

      client.dropTable(dbName, tblName);
      silentDropDatabase(dbName);
      new DatabaseBuilder()
          .setName(dbName)
          .setDescription("Validate Table Columns test")
          .create(client, conf);

      Table tbl = new TableBuilder()
          .setDbName(dbName)
          .setTableName(tblName)
          .addCol("name", ColumnType.STRING_TYPE_NAME)
          .addCol("income", ColumnType.INT_TYPE_NAME)
          .create(client, conf);

      if (isThriftClient) {
        tbl = client.getTable(dbName, tblName);
      }

      List<String> expectedCols = Lists.newArrayList();
      expectedCols.add("name");
      ObjectStore objStore = new ObjectStore();
      try {
        objStore.validateTableCols(tbl, expectedCols);
      } catch (MetaException ex) {
        throw new RuntimeException(ex);
      }

      expectedCols.add("doesntExist");
      boolean exceptionFound = false;
      try {
        objStore.validateTableCols(tbl, expectedCols);
      } catch (MetaException ex) {
        assertEquals(ex.getMessage(),
            "Column doesntExist doesn't exist in table comptbl in database compdb");
        exceptionFound = true;
      }
      assertTrue(exceptionFound);

    } catch (Exception e) {
      System.err.println(StringUtils.stringifyException(e));
      System.err.println("testValidateTableCols() failed.");
      throw e;
    }
  }
This method checks if persistence manager cache is cleaned up properly under some circumstances.
There is a chance that cleanup process removes elements created not only by this test, so we don't check
exact equality, instead check that no new elements can be seen in the cache (so newSet.removeAll(oldSet) should be empty).
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java