@Test
  public void testPostDeleteTable() throws IOException {
    final Admin admin = UTIL.getAdmin();
    final TableName tn = TableName.valueOf("postdeletetable");
    final TableDescriptor td = TableDescriptorBuilder.newBuilder(tn)
      .setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes("f1")).build())
      .build();

    HMaster master = UTIL.getMiniHBaseCluster().getMaster();
    MasterObserverForTest observer =
      master.getMasterCoprocessorHost().findCoprocessor(MasterObserverForTest.class);

    // Create the table and disable it
    admin.createTable(td);
    admin.disableTable(td.getTableName());

    // Validate that the post hook is called
    int preCount = observer.postHookCalls.get();
    admin.deleteTable(td.getTableName());
    int postCount = observer.postHookCalls.get();
    assertEquals("Expected 1 invocation of postDeleteTable", preCount + 1, postCount);

    // Then, validate that it's not called when the call fails
    preCount = observer.postHookCalls.get();
    try {
      admin.deleteTable(TableName.valueOf("missing"));
      fail("Deleting a missing table should fail");
    } catch (IOException e) {
      // Pass
    }
    postCount = observer.postHookCalls.get();
    assertEquals("Expected no invocations of postDeleteTable when the operation fails", preCount,
      postCount);
  }
Tests class that validates that "post" observer hook methods are only invoked when the operation
was successful.
hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestMasterObserverPostCalls.java