Class RemoteSpannerHelper (6.62.0)

public class 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.

Inheritance

java.lang.Object > RemoteSpannerHelper

Static Methods

create(InstanceId instanceId)

public static RemoteSpannerHelper create(InstanceId instanceId)

Creates a RemoteSpannerHelper bound to the given instance ID. All databases created using this will be created in the given instance.

Parameter
NameDescription
instanceIdInstanceId
Returns
TypeDescription
RemoteSpannerHelper

create(SpannerOptions options, InstanceId instanceId)

public static RemoteSpannerHelper create(SpannerOptions options, InstanceId instanceId)

Creates a RemoteSpannerHelper for the given option and bound to the given instance ID. All databases created using this will be created in the given instance.

Parameters
NameDescription
optionsSpannerOptions
instanceIdInstanceId
Returns
TypeDescription
RemoteSpannerHelper

Constructors

RemoteSpannerHelper(SpannerOptions options, InstanceId instanceId, Spanner client)

protected RemoteSpannerHelper(SpannerOptions options, InstanceId instanceId, Spanner client)
Parameters
NameDescription
optionsSpannerOptions
instanceIdInstanceId
clientSpanner

Methods

cleanUp()

public void cleanUp()

Deletes all the databases created via createTestDatabase. Shuts down the client.

createTestDatabase(Dialect dialect, Iterable<String> statements)

public Database createTestDatabase(Dialect dialect, Iterable<String> statements)

Creates a test database defined by statements in the test instance. A CREATE DATABASE ... statement should not be included; an appropriate name will be chosen and the statement generated accordingly.

Parameters
NameDescription
dialectDialect
statementsIterable<String>
Returns
TypeDescription
Database
Exceptions
TypeDescription
SpannerException

createTestDatabase(Iterable<String> statements)

public Database createTestDatabase(Iterable<String> statements)
Parameter
NameDescription
statementsIterable<String>
Returns
TypeDescription
Database
Exceptions
TypeDescription
SpannerException

createTestDatabase(String[] statements)

public Database createTestDatabase(String[] statements)

Creates a test database defined by statements. A CREATE DATABASE ... statement should not be included; an appropriate name will be chosen and the statement generated accordingly.

Parameter
NameDescription
statementsString[]
Returns
TypeDescription
Database
Exceptions
TypeDescription
SpannerException

getBatchClient(Database db)

public BatchClient getBatchClient(Database db)
Parameter
NameDescription
dbDatabase
Returns
TypeDescription
BatchClient

getClient()

public Spanner getClient()
Returns
TypeDescription
Spanner

getDatabaseClient(Database db)

public DatabaseClient getDatabaseClient(Database db)
Parameter
NameDescription
dbDatabase
Returns
TypeDescription
DatabaseClient

getInstanceId()

public InstanceId getInstanceId()
Returns
TypeDescription
InstanceId

getOptions()

public SpannerOptions getOptions()
Returns
TypeDescription
SpannerOptions

getUniqueBackupId()

public String getUniqueBackupId()

Returns a backup id which is guaranteed to be unique within the context of this environment.

Returns
TypeDescription
String

getUniqueDatabaseId()

public String getUniqueDatabaseId()

Returns a database id which is guaranteed to be unique within the context of this environment.

Returns
TypeDescription
String

getUniqueDatabaseRole()

public String getUniqueDatabaseRole()

Returns a database role name which is guaranteed to be unique within the context of this environment.

Returns
TypeDescription
String

isEmulator() (deprecated)

public boolean isEmulator()

Deprecated. use EmulatorSpannerHelper#isUsingEmulator() instead.

Checks whether the emulator is being used.

Returns
TypeDescription
boolean

true if the emulator is being used. Returns false otherwise.