@Test
  public void testGetFields() throws Exception {
    dbName1 = "db_test_get_fields_1";
    dbName2 = "db_test_get_fields_2";
    creatEnv(conf);

    // enable throwing exception, so we can check pre-envent listener is called
    TestHmsServerAuthorization.DummyAuthorizationListenerImpl.throwExceptionAtCall = true;

    try {
      List<FieldSchema> tableSchema = client.getFields(dbName1, TAB1);
      fail("getFields() should fail with throw exception mode at server side");
    } catch (MetaException ex) {
      boolean isMessageAuthorization = ex.getMessage().contains("Authorization fails");
      assertEquals(true, isMessageAuthorization);
    }
  }
Test the pre-event listener is called in function get_fields at HMS server.
@throws Exception
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHmsServerAuthorization.java