Class BigtableEmulatorRule
- java.lang.Object
-
- org.junit.rules.ExternalResource
-
- com.google.cloud.bigtable.emulator.v2.BigtableEmulatorRule
-
- All Implemented Interfaces:
org.junit.rules.TestRule
@BetaApi("Surface for Bigtable emulator is not yet stable") public class BigtableEmulatorRule extends org.junit.rules.ExternalResourceThe BigtableEmulatorRule manages the lifecycle of the BigtableEmulator. Before the start of a test, the emulator will be started on a random port and will be shutdown after the test finishes.Example usage:
{@literal @RunWith(JUnit4.class)} public class MyTest { {@literal @Rule} public final BigtableEmulatorRule bigtableEmulator = BigtableEmulatorRule.create(); {@literal @Test} public void testUsingEmulator() { ManagedChannel adminChannel = bigtableEmulator.getAdminChannel(); // Do something with channel } }
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidafter()Stops the Bigtable emulator after a test finishes.protected voidbefore()Initializes the Bigtable emulator before a test runs.static BigtableEmulatorRulecreate()io.grpc.ManagedChannelgetAdminChannel()Gets aManagedChannelconnected to the Emulator.io.grpc.ManagedChannelgetDataChannel()Gets aManagedChannelconnected to the Emulator.intgetPort()Gets the port of the emulator, allowing the caller to create their ownManagedChannel.
-
-
-
Method Detail
-
create
public static BigtableEmulatorRule create()
-
before
protected void before() throws ThrowableInitializes the Bigtable emulator before a test runs.- Overrides:
beforein classorg.junit.rules.ExternalResource- Throws:
Throwable
-
after
protected void after()
Stops the Bigtable emulator after a test finishes.- Overrides:
afterin classorg.junit.rules.ExternalResource
-
getDataChannel
public io.grpc.ManagedChannel getDataChannel()
Gets aManagedChannelconnected to the Emulator. The channel is configured for data operations.
-
getAdminChannel
public io.grpc.ManagedChannel getAdminChannel()
Gets aManagedChannelconnected to the Emulator. This channel should be used for admin operations.
-
getPort
public int getPort()
Gets the port of the emulator, allowing the caller to create their ownManagedChannel.
-
-