Class ClearUserNamespacesAndTablesRule

java.lang.Object
org.junit.rules.ExternalResource
org.apache.hadoop.hbase.ClearUserNamespacesAndTablesRule
All Implemented Interfaces:
org.junit.rules.TestRule

public class ClearUserNamespacesAndTablesRule extends org.junit.rules.ExternalResource
A TestRule that clears all user namespaces and tables before the test executes. Can be used in either the Rule or ClassRule positions. Lazily realizes the provided AsyncConnection so as to avoid initialization races with other Rules. Does not close() provided connection instance when finished.

Use in combination with MiniClusterRule and ConnectionRule, for example:
 {
   @code
   public class TestMyClass {
     @ClassRule
     public static final MiniClusterRule miniClusterRule = MiniClusterRule.newBuilder().build();

     private final ConnectionRule connectionRule =
       new ConnectionRule(miniClusterRule::createConnection);
     private final ClearUserNamespacesAndTablesRule clearUserNamespacesAndTablesRule =
       new ClearUserNamespacesAndTablesRule(connectionRule::getConnection);

     @Rule
     public TestRule rule =
       RuleChain.outerRule(connectionRule).around(clearUserNamespacesAndTablesRule);
   }
 }