@Test
  public void testConstraintPasses() throws Exception {
    // create the table
    // it would be nice if this was also a method on the util
    TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(tableName);

    for (byte[] family : new byte[][] { dummy, test }) {
      builder.setColumnFamily(ColumnFamilyDescriptorBuilder.of(family));
    }
    // add a constraint
    Constraints.add(builder, CheckWasRunConstraint.class);

    util.getAdmin().createTable(builder.build());
    Table table = util.getConnection().getTable(tableName);
    try {
      // test that we don't fail on a valid put
      Put put = new Put(row1);
      byte[] value = Bytes.toBytes(Integer.toString(10));
      byte[] qualifier = new byte[0];
      put.addColumn(dummy, qualifier, value);
      table.put(put);
    } finally {
      table.close();
    }
    assertTrue(CheckWasRunConstraint.wasRun);
  }
Test that we run a passing constraint
hbase-server/src/test/java/org/apache/hadoop/hbase/constraint/TestConstraint.java