@Test
  public void testSimpleReadWrite() throws Exception {
    TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(name.getTableName());
    Constraints.add(builder, WorksConstraint.class);

    List<? extends Constraint> constraints =
      Constraints.getConstraints(builder.build(), this.getClass().getClassLoader());
    assertEquals(1, constraints.size());

    assertEquals(WorksConstraint.class, constraints.get(0).getClass());

    // Check that we can add more than 1 constraint and that ordering is
    // preserved
    Constraints.add(builder, AlsoWorks.class, NameConstraint.class);
    constraints = Constraints.getConstraints(builder.build(), this.getClass().getClassLoader());
    assertEquals(3, constraints.size());

    assertEquals(WorksConstraint.class, constraints.get(0).getClass());
    assertEquals(AlsoWorks.class, constraints.get(1).getClass());
    assertEquals(NameConstraint.class, constraints.get(2).getClass());

  }
Test reading/writing the constraints into the {@link TableDescriptorBuilder}.
hbase-server/src/test/java/org/apache/hadoop/hbase/constraint/TestConstraints.java