@Test
public void testAddFKConstraint() throws Exception {

  String tableName = getFreeTableName();
  createMyTable(tableName);
  DBAccessorImpl dbAccessor = injector.getInstance(DBAccessorImpl.class);
  List<DBColumnInfo> columns = new ArrayList<DBColumnInfo>();
  columns.add(new DBColumnInfo("fid", Long.class, null, null, false));
  columns.add(new DBColumnInfo("fname", String.class, null, null, false));
  String foreignTableName = getFreeTableName();
  dbAccessor.createTable(foreignTableName, columns, "fid");
  dbAccessor.addFKConstraint(foreignTableName, "MYFKCONSTRAINT", "fid",
    tableName, "id", false);
  Statement statement = dbAccessor.getConnection().createStatement();
  statement.execute("insert into " + tableName + "(id, name) values(1,'hello')");
  statement.execute("insert into " + foreignTableName + "(fid, fname) values(1,'howdy')");
  ResultSet resultSet = statement.executeQuery("select * from " + foreignTableName);
  int count = 0;
  while (resultSet.next()) {
    assertEquals(resultSet.getString("fname"), "howdy");
    count++;
  }
  resultSet.close();
  assertEquals(count, 1);
  exception.expect(SQLException.class);
  exception.expectMessage(containsString("MYFKCONSTRAINT"));
  dbAccessor.executeQuery("DELETE FROM " + tableName);
}