@Test
  public void testQuotaScope() throws Exception {
    Admin admin = TEST_UTIL.getAdmin();
    String user = "user1";
    String namespace = "testQuotaScope_ns";
    TableName tableName = TableName.valueOf("testQuotaScope");
    QuotaFilter filter = new QuotaFilter();

    // set CLUSTER quota scope for namespace
    admin.setQuota(QuotaSettingsFactory.throttleNamespace(namespace, ThrottleType.REQUEST_NUMBER,
      10, TimeUnit.MINUTES, QuotaScope.CLUSTER));
    assertNumResults(1, filter);
    verifyRecordPresentInQuotaTable(ThrottleType.REQUEST_NUMBER, 10, TimeUnit.MINUTES,
      QuotaScope.CLUSTER);
    admin.setQuota(QuotaSettingsFactory.throttleNamespace(namespace, ThrottleType.REQUEST_NUMBER,
      10, TimeUnit.MINUTES, QuotaScope.MACHINE));
    assertNumResults(1, filter);
    verifyRecordPresentInQuotaTable(ThrottleType.REQUEST_NUMBER, 10, TimeUnit.MINUTES,
      QuotaScope.MACHINE);
    admin.setQuota(QuotaSettingsFactory.unthrottleNamespace(namespace));
    assertNumResults(0, filter);

    // set CLUSTER quota scope for table
    admin.setQuota(QuotaSettingsFactory.throttleTable(tableName, ThrottleType.REQUEST_NUMBER, 10,
      TimeUnit.MINUTES, QuotaScope.CLUSTER));
    verifyRecordPresentInQuotaTable(ThrottleType.REQUEST_NUMBER, 10, TimeUnit.MINUTES,
      QuotaScope.CLUSTER);
    admin.setQuota(QuotaSettingsFactory.unthrottleTable(tableName));

    // set CLUSTER quota scope for user
    admin.setQuota(QuotaSettingsFactory.throttleUser(user, ThrottleType.REQUEST_NUMBER, 10,
      TimeUnit.MINUTES, QuotaScope.CLUSTER));
    verifyRecordPresentInQuotaTable(ThrottleType.REQUEST_NUMBER, 10, TimeUnit.MINUTES,
      QuotaScope.CLUSTER);
    admin.setQuota(QuotaSettingsFactory.unthrottleUser(user));

    // set CLUSTER quota scope for user and table
    admin.setQuota(QuotaSettingsFactory.throttleUser(user, tableName, ThrottleType.REQUEST_NUMBER,
      10, TimeUnit.MINUTES, QuotaScope.CLUSTER));
    verifyRecordPresentInQuotaTable(ThrottleType.REQUEST_NUMBER, 10, TimeUnit.MINUTES,
      QuotaScope.CLUSTER);
    admin.setQuota(QuotaSettingsFactory.unthrottleUser(user));

    // set CLUSTER quota scope for user and namespace
    admin.setQuota(QuotaSettingsFactory.throttleUser(user, namespace, ThrottleType.REQUEST_NUMBER,
      10, TimeUnit.MINUTES, QuotaScope.CLUSTER));
    verifyRecordPresentInQuotaTable(ThrottleType.REQUEST_NUMBER, 10, TimeUnit.MINUTES,
      QuotaScope.CLUSTER);
    admin.setQuota(QuotaSettingsFactory.unthrottleUser(user));
  }
minicluster tests that validate that quota entries are properly set in the quota table
hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaAdmin.java