@Test
  public void testEventListenerException() throws Throwable {

    System.setProperty("hive.metastore.init.hooks", "");
    System.setProperty("hive.metastore.event.listeners", ErrorEventListener.class.getName());
    Configuration conf = MetastoreConf.newMetastoreConf();
    MetaStoreTestUtils.setConfForStandloneMode(conf);
    int port = MetaStoreTestUtils.findFreePort();
    try {
      HiveMetaStore.startMetaStore(port, HadoopThriftAuthBridge.getBridge(), conf);
      Assert.fail();
    } catch (Throwable throwable) {
      Assert.assertEquals(MetaException.class, throwable.getClass());
      Assert.assertEquals(
          "Failed to instantiate listener named: " +
              "org.apache.hadoop.hive.metastore.TestMetaStoreListenersError$ErrorEventListener, " +
              "reason: java.lang.IllegalArgumentException: exception on constructor",
          throwable.getMessage());
    }
  }
Test for unwrapping InvocationTargetException, which is thrown from
constructor of listener class
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreListenersError.java