@Test(expected = TableNotFoundException.class)
public void testRenameExistingTableNoAutoFlush() throws Exception {
String originalName = "OriginalName";
String newName = "NewName";
TableSchema origSchema = TABLE_SCHEMA_GEN.next();
// Configure the table to disable auto flush
HTableInterface hTableSpy = PowerMockito.spy(MockHTable.create());
Mockito.when(hTableSpy.isAutoFlush()).thenReturn(false);
hbaseMetadata.createTable(originalName, origSchema);
long origId = hbaseMetadata.getTableId(originalName);
hbaseMetadata.renameExistingTable(originalName, newName);
long newId = hbaseMetadata.getTableId(newName);
assertEquals(origId, newId);
Collection<ColumnSchema> origSchemaColumns = origSchema.getColumns();
TableSchema newSchema = hbaseMetadata.getSchema(newId);
for (ColumnSchema columnSchema : newSchema.getColumns()) {
assertTrue(origSchemaColumns.contains(columnSchema));
}
// Trying to access the id of the old table name will result in an exception
hbaseMetadata.getTableId(originalName);