public final class MiniClusterRule extends org.junit.rules.ExternalResource
TestRule
that manages an instance of the SingleProcessHBaseCluster
. Can be used
in either the Rule
or ClassRule
positions. Built on top of an instance of
HBaseTestingUtil
, 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 SingleProcessHBaseCluster |
miniCluster |
private StartTestingClusterOption |
miniClusterOptions |
private HBaseTestingUtil |
testingUtility |
Modifier | Constructor and Description |
---|---|
private |
MiniClusterRule(org.apache.hadoop.conf.Configuration conf,
StartTestingClusterOption 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 SingleProcessHBaseCluster . |
org.apache.hadoop.hbase.client.Connection |
createConnection()
Create a
Connection to the managed SingleProcessHBaseCluster . |
HBaseTestingUtil |
getTestingUtility()
Returns the underlying instance of
HBaseTestingUtil |
static MiniClusterRule.Builder |
newBuilder() |
private final HBaseTestingUtil testingUtility
private final StartTestingClusterOption miniClusterOptions
private SingleProcessHBaseCluster miniCluster
private MiniClusterRule(org.apache.hadoop.conf.Configuration conf, StartTestingClusterOption miniClusterOptions)
public static MiniClusterRule.Builder newBuilder()
public HBaseTestingUtil getTestingUtility()
HBaseTestingUtil
public org.apache.hadoop.hbase.client.Connection createConnection()
Connection
to the managed SingleProcessHBaseCluster
. 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 SingleProcessHBaseCluster
. 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.