Package com.google.cloud.spanner.testing
Class RemoteSpannerHelper
java.lang.Object
com.google.cloud.spanner.testing.RemoteSpannerHelper
Utility that provides access to a Cloud Spanner instance to use for tests, and allows uniquely
named test databases to be created within that instance.
-
Constructor Summary
ModifierConstructorDescriptionprotected
RemoteSpannerHelper
(SpannerOptions options, InstanceId instanceId, Spanner client) -
Method Summary
Modifier and TypeMethodDescriptionvoid
cleanUp()
Deletes all the databases created viacreateTestDatabase
.static RemoteSpannerHelper
create
(InstanceId instanceId) Creates aRemoteSpannerHelper
bound to the given instance ID.static RemoteSpannerHelper
create
(SpannerOptions options, InstanceId instanceId) Creates aRemoteSpannerHelper
for the given option and bound to the given instance ID.createTestDatabase
(Dialect dialect, Iterable<String> statements) Creates a test database defined bystatements
in the test instance.createTestDatabase
(Iterable<String> statements) createTestDatabase
(String... statements) Creates a test database defined bystatements
.Returns a backup id which is guaranteed to be unique within the context of this environment.Returns a database id which is guaranteed to be unique within the context of this environment.Returns a database role name which is guaranteed to be unique within the context of this environment.boolean
Deprecated.
-
Constructor Details
-
RemoteSpannerHelper
-
-
Method Details
-
getOptions
-
isEmulator
Deprecated.useEmulatorSpannerHelper.isUsingEmulator()
instead.Checks whether the emulator is being used.- Returns:
- true if the emulator is being used. Returns false otherwise.
-
getClient
-
getDatabaseClient
-
getBatchClient
-
getInstanceId
-
createTestDatabase
Creates a test database defined bystatements
. ACREATE DATABASE ...
statement should not be included; an appropriate name will be chosen and the statement generated accordingly.- Throws:
SpannerException
-
getUniqueDatabaseId
Returns a database id which is guaranteed to be unique within the context of this environment. -
getUniqueDatabaseRole
Returns a database role name which is guaranteed to be unique within the context of this environment. -
getUniqueBackupId
Returns a backup id which is guaranteed to be unique within the context of this environment. -
createTestDatabase
public Database createTestDatabase(Dialect dialect, Iterable<String> statements) throws SpannerException Creates a test database defined bystatements
in the test instance. ACREATE DATABASE ...
statement should not be included; an appropriate name will be chosen and the statement generated accordingly.- Throws:
SpannerException
-
createTestDatabase
- Throws:
SpannerException
-
cleanUp
public void cleanUp()Deletes all the databases created viacreateTestDatabase
. Shuts down the client. -
create
Creates aRemoteSpannerHelper
bound to the given instance ID. All databases created using this will be created in the given instance. -
create
Creates aRemoteSpannerHelper
for the given option and bound to the given instance ID. All databases created using this will be created in the given instance.
-
EmulatorSpannerHelper.isUsingEmulator()
instead.