### Question:
HCatClient { public abstract void renameTable(String dbName, String oldName, String newName) throws HCatException;  static HCatClient create(Configuration conf); abstract List<String> listDatabaseNamesByPattern(String pattern); abstract HCatDatabase getDatabase(String dbName); abstract void createDatabase(HCatCreateDBDesc dbInfo); abstract void dropDatabase(String dbName, boolean ifExists,
                                      DropDBMode mode); abstract List<String> listTableNamesByPattern(String dbName, String tablePattern); abstract HCatTable getTable(String dbName, String tableName); abstract void createTable(HCatCreateTableDesc createTableDesc); abstract void updateTableSchema(String dbName, String tableName, List<HCatFieldSchema> columnSchema); abstract void createTableLike(String dbName, String existingTblName,
                                         String newTableName, boolean ifNotExists, boolean isExternal,
                                         String location); abstract void dropTable(String dbName, String tableName,
                                   boolean ifExists); abstract void renameTable(String dbName, String oldName,
                                     String newName); abstract List<HCatPartition> getPartitions(String dbName, String tblName); abstract List<HCatPartition> getPartitions(String dbName, String tblName, Map<String, String> partitionSpec); abstract HCatPartition getPartition(String dbName, String tableName,
                                               Map<String, String> partitionSpec); abstract void addPartition(HCatAddPartitionDesc partInfo); abstract int addPartitions(List<HCatAddPartitionDesc> partInfoList); abstract void dropPartitions(String dbName, String tableName,
                                        Map<String, String> partitionSpec, boolean ifExists); abstract List<HCatPartition> listPartitionsByFilter(String dbName, String tblName,
                                                               String filter); abstract void markPartitionForEvent(String dbName, String tblName,
                                               Map<String, String> partKVs, PartitionEventType eventType); abstract boolean isPartitionMarkedForEvent(String dbName, String tblName,
                                                      Map<String, String> partKVs, PartitionEventType eventType); abstract String getDelegationToken(String owner,
                                              String renewerKerberosPrincipalName); abstract long renewDelegationToken(String tokenStrForm); abstract void cancelDelegationToken(String tokenStrForm); abstract String getMessageBusTopicName(String dbName, String tableName); abstract void close(); static final String HCAT_CLIENT_IMPL_CLASS; }### Answer:
@Test public void testRenameTable() throws Exception { HCatClient client = HCatClient.create(new Configuration(hcatConf)); String tableName = "temptable"; String newName = "mytable"; client.dropTable(null, tableName, true); client.dropTable(null, newName, true); ArrayList<HCatFieldSchema> cols = new ArrayList<HCatFieldSchema>(); cols.add(new HCatFieldSchema("id", Type.INT, "id columns")); cols.add(new HCatFieldSchema("value", Type.STRING, "id columns")); HCatCreateTableDesc tableDesc = HCatCreateTableDesc .create(null, tableName, cols).fileFormat("rcfile").build(); client.createTable(tableDesc); client.renameTable(null, tableName, newName); try { client.getTable(null, tableName); } catch (HCatException exp) { assertTrue("Unexpected exception message: " + exp.getMessage(), exp.getMessage().contains("NoSuchObjectException while fetching table")); } HCatTable newTable = client.getTable(null, newName); assertTrue(newTable != null); assertTrue(newTable.getTableName().equals(newName)); client.close(); }