Package org.apache.hadoop.hbase
Class ConnectionRule
java.lang.Object
org.junit.rules.ExternalResource
org.apache.hadoop.hbase.ConnectionRule
- All Implemented Interfaces:
org.junit.rules.TestRule
A
Rule that manages the lifecycle of an instance of AsyncConnection. Can be used
in either the Rule or ClassRule positions.
Use in combination with MiniClusterRule, for example:
{
@code
public class TestMyClass {
private static final MiniClusterRule miniClusterRule = MiniClusterRule.newBuilder().build();
private static final ConnectionRule connectionRule =
ConnectionRule.createAsyncConnectionRule(miniClusterRule::createConnection);
@ClassRule
public static final TestRule rule =
RuleChain.outerRule(miniClusterRule).around(connectionRule);
}
}
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.apache.hadoop.hbase.client.AsyncConnectionprivate final Supplier<CompletableFuture<org.apache.hadoop.hbase.client.AsyncConnection>>private org.apache.hadoop.hbase.client.Connectionprivate final Supplier<org.apache.hadoop.hbase.client.Connection> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateConnectionRule(Supplier<org.apache.hadoop.hbase.client.Connection> connectionSupplier, Supplier<CompletableFuture<org.apache.hadoop.hbase.client.AsyncConnection>> asyncConnectionSupplier) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidafter()protected voidbefore()static ConnectionRulecreateAsyncConnectionRule(Supplier<CompletableFuture<org.apache.hadoop.hbase.client.AsyncConnection>> asyncConnectionSupplier) static ConnectionRulecreateConnectionRule(Supplier<org.apache.hadoop.hbase.client.Connection> connectionSupplier) static ConnectionRulecreateConnectionRule(Supplier<org.apache.hadoop.hbase.client.Connection> connectionSupplier, Supplier<CompletableFuture<org.apache.hadoop.hbase.client.AsyncConnection>> asyncConnectionSupplier) org.apache.hadoop.hbase.client.AsyncConnectionorg.apache.hadoop.hbase.client.ConnectionMethods inherited from class org.junit.rules.ExternalResource
apply
-
Field Details
-
connectionSupplier
-
asyncConnectionSupplier
private final Supplier<CompletableFuture<org.apache.hadoop.hbase.client.AsyncConnection>> asyncConnectionSupplier -
connection
-
asyncConnection
-
-
Constructor Details
-
ConnectionRule
private ConnectionRule(Supplier<org.apache.hadoop.hbase.client.Connection> connectionSupplier, Supplier<CompletableFuture<org.apache.hadoop.hbase.client.AsyncConnection>> asyncConnectionSupplier)
-
-
Method Details
-
createConnectionRule
public static ConnectionRule createConnectionRule(Supplier<org.apache.hadoop.hbase.client.Connection> connectionSupplier) -
createAsyncConnectionRule
public static ConnectionRule createAsyncConnectionRule(Supplier<CompletableFuture<org.apache.hadoop.hbase.client.AsyncConnection>> asyncConnectionSupplier) -
createConnectionRule
public static ConnectionRule createConnectionRule(Supplier<org.apache.hadoop.hbase.client.Connection> connectionSupplier, Supplier<CompletableFuture<org.apache.hadoop.hbase.client.AsyncConnection>> asyncConnectionSupplier) -
getConnection
-
getAsyncConnection
-
before
- Overrides:
beforein classorg.junit.rules.ExternalResource- Throws:
Throwable
-
after
- Overrides:
afterin classorg.junit.rules.ExternalResource
-