guluo2016 commented on code in PR #7848:
URL: https://github.com/apache/hbase/pull/7848#discussion_r2882914471
##########
hbase-server/src/test/java/org/apache/hadoop/hbase/client/SnapshotWithAclTestBase.java:
##########
@@ -314,4 +323,39 @@ public void testDeleteSnapshot() throws Exception {
TEST_UTIL.getAdmin().listSnapshots(Pattern.compile(testSnapshotName));
assertEquals(0, snapshotsAfterDelete.size());
}
+
+ @Test
+ public void testCreateSnapshotWithNonExistingTable() throws Exception {
+ final TableName tableName = name.getTableName();
+ String snapshotName = tableName.getNameAsString() + "snap1";
+
+ try {
+ try {
+ // Create snapshot without creating table
+ TEST_UTIL.getAdmin().snapshot(snapshotName, tableName);
+ fail("Snapshot operation should fail, table doesn't exist");
+ } catch (Exception e) {
+ assertTrue(e instanceof SnapshotCreationException);
+ }
Review Comment:
This code can be simplified as follows:
```java
// Create snapshot without creating table
assertThrows("Snapshot operation should fail, table doesn't exist",
SnapshotCreationException.class, () ->
TEST_UTIL.getAdmin().snapshot(snapshotName, tableName));
```
And I noticed other test cases in this file also use `assertThrows`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]