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
Modifier and TypeFieldDescriptionprivate org.apache.hadoop.hbase.client.AsyncConnection
private final Supplier<CompletableFuture<org.apache.hadoop.hbase.client.AsyncConnection>>
private org.apache.hadoop.hbase.client.Connection
private final Supplier<org.apache.hadoop.hbase.client.Connection>
-
Constructor Summary
ModifierConstructorDescriptionprivate
ConnectionRule
(Supplier<org.apache.hadoop.hbase.client.Connection> connectionSupplier, Supplier<CompletableFuture<org.apache.hadoop.hbase.client.AsyncConnection>> asyncConnectionSupplier) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
after()
protected void
before()
static ConnectionRule
createAsyncConnectionRule
(Supplier<CompletableFuture<org.apache.hadoop.hbase.client.AsyncConnection>> asyncConnectionSupplier) static ConnectionRule
createConnectionRule
(Supplier<org.apache.hadoop.hbase.client.Connection> connectionSupplier) static ConnectionRule
createConnectionRule
(Supplier<org.apache.hadoop.hbase.client.Connection> connectionSupplier, Supplier<CompletableFuture<org.apache.hadoop.hbase.client.AsyncConnection>> asyncConnectionSupplier) org.apache.hadoop.hbase.client.AsyncConnection
org.apache.hadoop.hbase.client.Connection
Methods 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:
before
in classorg.junit.rules.ExternalResource
- Throws:
Throwable
-
after
- Overrides:
after
in classorg.junit.rules.ExternalResource
-