public final class MiniClusterRule extends org.junit.rules.ExternalResource
TestRule
that manages an instance of the MiniHBaseCluster
. Can be used in
either the Rule
or ClassRule
positions. Built on top of an instance of
HBaseTestingUtility
, so be weary of intermixing direct use of that class with this Rule.
Use in combination with ConnectionRule
, for example:
{ @code public class TestMyClass { @ClassRule public static final MiniClusterRule miniClusterRule = MiniClusterRule.newBuilder().build(); @Rule public final ConnectionRule connectionRule = ConnectionRule.createAsyncConnectionRule(miniClusterRule::createAsyncConnection); } }
Modifier and Type | Class and Description |
---|---|
static class |
MiniClusterRule.Builder
A builder for fluent composition of a new
MiniClusterRule . |
Modifier and Type | Field and Description |
---|---|
private MiniHBaseCluster |
miniCluster |
private StartMiniClusterOption |
miniClusterOptions |
private HBaseTestingUtility |
testingUtility |
Modifier | Constructor and Description |
---|---|
private |
MiniClusterRule(org.apache.hadoop.conf.Configuration conf,
StartMiniClusterOption miniClusterOptions) |
Modifier and Type | Method and Description |
---|---|
protected void |
after() |
protected void |
before() |
CompletableFuture<org.apache.hadoop.hbase.client.AsyncConnection> |
createAsyncConnection()
Create a
AsyncConnection to the managed MiniHBaseCluster . |
org.apache.hadoop.hbase.client.Connection |
createConnection()
Create a
Connection to the managed MiniHBaseCluster . |
HBaseTestingUtility |
getTestingUtility()
Returns the underlying instance of
HBaseTestingUtility |
static MiniClusterRule.Builder |
newBuilder() |
private final HBaseTestingUtility testingUtility
private final StartMiniClusterOption miniClusterOptions
private MiniHBaseCluster miniCluster
private MiniClusterRule(org.apache.hadoop.conf.Configuration conf, StartMiniClusterOption miniClusterOptions)
public static MiniClusterRule.Builder newBuilder()
public HBaseTestingUtility getTestingUtility()
HBaseTestingUtility
public org.apache.hadoop.hbase.client.Connection createConnection()
Connection
to the managed MiniHBaseCluster
. It's up to the caller to
close()
the connection when finished.public CompletableFuture<org.apache.hadoop.hbase.client.AsyncConnection> createAsyncConnection()
AsyncConnection
to the managed MiniHBaseCluster
. It's up to the caller
to close()
the connection when finished.protected void before() throws Throwable
before
in class org.junit.rules.ExternalResource
Throwable
protected void after()
after
in class org.junit.rules.ExternalResource
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.