Class BigtableEmulatorRule (2.31.0)

public class BigtableEmulatorRule extends ExternalResource

The BigtableEmulatorRule manages the lifecycle of the Bigtable Emulator. 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
 }

}

Inheritance

java.lang.Object > org.junit.rules.ExternalResource > BigtableEmulatorRule

Static Methods

create()

public static BigtableEmulatorRule create()
Returns
TypeDescription
BigtableEmulatorRule

Methods

after()

protected void after()

Stops the Bigtable emulator after a test finishes.

Overrides
org.junit.rules.ExternalResource.after()

before()

protected void before()

Initializes the Bigtable emulator before a test runs.

Overrides
org.junit.rules.ExternalResource.before()
Exceptions
TypeDescription
Throwable

getAdminChannel()

public ManagedChannel getAdminChannel()

Gets a ManagedChannel connected to the Emulator. This channel should be used for admin operations.

Returns
TypeDescription
io.grpc.ManagedChannel

getDataChannel()

public ManagedChannel getDataChannel()

Gets a ManagedChannel connected to the Emulator. The channel is configured for data operations.

Returns
TypeDescription
io.grpc.ManagedChannel

getPort()

public int getPort()

Gets the port of the emulator, allowing the caller to create their own ManagedChannel.

Returns
TypeDescription
int