Class BaseEmulatorHelper<T> (2.29.0)

public abstract class BaseEmulatorHelper<T>

Utility class to start and stop a local service which is used by unit testing.

Inheritance

java.lang.Object > BaseEmulatorHelper<T>

Type Parameter

NameDescription
T

Static Fields

DEFAULT_HOST

protected static final String DEFAULT_HOST
Field Value
TypeDescription
String

DEFAULT_PORT

protected static final int DEFAULT_PORT
Field Value
TypeDescription
int

PROJECT_ID_PREFIX

protected static final String PROJECT_ID_PREFIX
Field Value
TypeDescription
String

Static Methods

findAvailablePort(int defaultPort)

protected static int findAvailablePort(int defaultPort)
Parameter
NameDescription
defaultPortint
Returns
TypeDescription
int

isWindows()

protected static boolean isWindows()
Returns
TypeDescription
boolean

Constructors

BaseEmulatorHelper(String emulator, int port, String projectId)

protected BaseEmulatorHelper(String emulator, int port, String projectId)
Parameters
NameDescription
emulatorString
portint
projectIdString

Methods

getEmulatorRunners()

protected abstract List<BaseEmulatorHelper.EmulatorRunner> getEmulatorRunners()

Returns the emulator runners supported by this emulator. Runners are evaluated in order, the first available runner is selected and executed

Returns
TypeDescription
List<EmulatorRunner>

getLogger()

protected abstract Logger getLogger()

Returns a logger.

Returns
TypeDescription
Logger

getOptions()

public abstract T getOptions()

Returns service options to access the local emulator.

Returns
TypeDescription
T

getPort()

public int getPort()

Returns the port to which the local emulator is listening.

Returns
TypeDescription
int

getProjectId()

public String getProjectId()

Returns the project ID associated with the local emulator.

Returns
TypeDescription
String

reset()

public abstract void reset()

Resets the internal state of the emulator.

Exceptions
TypeDescription
IOException

sendPostRequest(String request)

protected final String sendPostRequest(String request)
Parameter
NameDescription
requestString
Returns
TypeDescription
String
Exceptions
TypeDescription
IOException

start()

public abstract void start()

Starts the local emulator.

Exceptions
TypeDescription
IOException
InterruptedException

startProcess(String blockUntilOutput)

protected final void startProcess(String blockUntilOutput)

Starts the local service as a subprocess. Blocks the execution until blockUntilOutput is found on stdout.

Parameter
NameDescription
blockUntilOutputString
Exceptions
TypeDescription
IOException
InterruptedException

stop(Duration timeout)

public abstract void stop(Duration timeout)

Stops the local emulator.

Parameter
NameDescription
timeoutorg.threeten.bp.Duration
Exceptions
TypeDescription
IOException
InterruptedException
TimeoutException

waitForProcess(Duration timeout)

protected final int waitForProcess(Duration timeout)

Waits for the local service's subprocess to terminate, and stop any possible thread listening for its output.

Parameter
NameDescription
timeoutorg.threeten.bp.Duration
Returns
TypeDescription
int
Exceptions
TypeDescription
IOException
InterruptedException
TimeoutException