@Test
  public void testEnableDisableRemove() throws Exception {
    TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(name.getTableName());
    // check general enabling/disabling of constraints
    // first add a constraint
    Constraints.add(builder, AllPassConstraint.class);
    // make sure everything is enabled
    assertTrue(Constraints.enabled(builder.build(), AllPassConstraint.class));
    assertTrue(builder.hasCoprocessor(ConstraintProcessor.class.getName()));

    // check disabling
    Constraints.disable(builder);
    assertFalse(builder.hasCoprocessor(ConstraintProcessor.class.getName()));
    // make sure the added constraints are still present
    assertTrue(Constraints.enabled(builder.build(), AllPassConstraint.class));

    // check just removing the single constraint
    Constraints.remove(builder, AllPassConstraint.class);
    assertFalse(Constraints.has(builder.build(), AllPassConstraint.class));

    // Add back the single constraint
    Constraints.add(builder, AllPassConstraint.class);

    // and now check that when we remove constraints, all are gone
    Constraints.remove(builder);
    assertFalse(builder.hasCoprocessor(ConstraintProcessor.class.getName()));
    assertFalse(Constraints.has(builder.build(), AllPassConstraint.class));

  }
Test that Constraints are properly enabled, disabled, and removed
hbase-server/src/test/java/org/apache/hadoop/hbase/constraint/TestConstraints.java