@Test
  public void testListTables() throws Exception {
    int numTables = admin.listTableDescriptors().get().size();
    final TableName tableName1 = TableName.valueOf(tableName.getNameAsString() + "1");
    final TableName tableName2 = TableName.valueOf(tableName.getNameAsString() + "2");
    final TableName tableName3 = TableName.valueOf(tableName.getNameAsString() + "3");
    TableName[] tables = new TableName[] { tableName1, tableName2, tableName3 };
    for (int i = 0; i < tables.length; i++) {
      createTableWithDefaultConf(tables[i]);
    }

    List<TableDescriptor> tableDescs = admin.listTableDescriptors().get();
    int size = tableDescs.size();
    assertTrue(size >= tables.length);
    for (int i = 0; i < tables.length && i < size; i++) {
      boolean found = false;
      for (int j = 0; j < size; j++) {
        if (tableDescs.get(j).getTableName().equals(tables[i])) {
          found = true;
          break;
        }
      }
      assertTrue("Not found: " + tables[i], found);
    }

    List<TableName> tableNames = admin.listTableNames().get();
    size = tableNames.size();
    assertTrue(size == (numTables + tables.length));
    for (int i = 0; i < tables.length && i < size; i++) {
      boolean found = false;
      for (int j = 0; j < size; j++) {
        if (tableNames.get(j).equals(tables[i])) {
          found = true;
          break;
        }
      }
      assertTrue("Not found: " + tables[i], found);
    }

    tableNames = new ArrayList<TableName>(tables.length + 1);
    tableDescs = admin.listTableDescriptors(tableNames).get();
    size = tableDescs.size();
    assertEquals(0, size);

    Collections.addAll(tableNames, tables);
    tableNames.add(TableName.META_TABLE_NAME);
    tableDescs = admin.listTableDescriptors(tableNames).get();
    size = tableDescs.size();
    assertEquals(tables.length + 1, size);
    for (int i = 0, j = 0; i < tables.length && j < size; i++, j++) {
      assertTrue("tableName should be equal in order",
        tableDescs.get(j).getTableName().equals(tables[i]));
    }
    assertTrue(tableDescs.get(size - 1).getTableName().equals(TableName.META_TABLE_NAME));

    for (int i = 0; i < tables.length; i++) {
      admin.disableTable(tables[i]).join();
      admin.deleteTable(tables[i]).join();
    }

    tableDescs = admin.listTableDescriptors(true).get();
    assertTrue("Not found system tables", tableDescs.size() > 0);
    tableNames = admin.listTableNames(true).get();
    assertTrue("Not found system tables", tableNames.size() > 0);
  }
Class to test asynchronous table admin operations.
@see TestAsyncTableAdminApi2 This test and it used to be joined it was taking longer than our ten
     minute timeout so they were split.
hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableAdminApi3.java