@InternalApi public abstract class BaseEmulatorHelper<T extends ServiceOptions> extends Object
Modifier and Type | Class and Description |
---|---|
protected static class |
BaseEmulatorHelper.DownloadableEmulatorRunner
Utility class to start and run an emulator from a download URL.
|
protected static interface |
BaseEmulatorHelper.EmulatorRunner
Utility interface to start and run an emulator.
|
protected static class |
BaseEmulatorHelper.GcloudEmulatorRunner
Utility class to start and run an emulator from the Google Cloud SDK.
|
Modifier and Type | Field and Description |
---|---|
protected static String |
DEFAULT_HOST |
protected static int |
DEFAULT_PORT |
protected static String |
PROJECT_ID_PREFIX |
Modifier | Constructor and Description |
---|---|
protected |
BaseEmulatorHelper(String emulator,
int port,
String projectId) |
Modifier and Type | Method and Description |
---|---|
protected static int |
findAvailablePort(int defaultPort) |
protected abstract List<BaseEmulatorHelper.EmulatorRunner> |
getEmulatorRunners()
Returns the emulator runners supported by this emulator.
|
protected abstract Logger |
getLogger()
Returns a logger.
|
abstract T |
getOptions()
Returns service options to access the local emulator.
|
int |
getPort()
Returns the port to which the local emulator is listening.
|
String |
getProjectId()
Returns the project ID associated with the local emulator.
|
protected static boolean |
isWindows() |
abstract void |
reset()
Resets the internal state of the emulator.
|
protected String |
sendPostRequest(String request) |
abstract void |
start()
Starts the local emulator.
|
protected void |
startProcess(String blockUntilOutput)
Starts the local service as a subprocess.
|
abstract void |
stop(org.threeten.bp.Duration timeout)
Stops the local emulator.
|
protected int |
waitForProcess(org.threeten.bp.Duration timeout)
Waits for the local service's subprocess to terminate, and stop any possible thread listening
for its output.
|
protected static final String PROJECT_ID_PREFIX
protected static final String DEFAULT_HOST
protected static final int DEFAULT_PORT
@InternalApi(value="This class should only be extended within google-cloud-java") protected BaseEmulatorHelper(String emulator, int port, String projectId)
protected abstract List<BaseEmulatorHelper.EmulatorRunner> getEmulatorRunners()
protected abstract Logger getLogger()
protected final void startProcess(String blockUntilOutput) throws IOException, InterruptedException
blockUntilOutput
is found on stdout.IOException
InterruptedException
protected final int waitForProcess(org.threeten.bp.Duration timeout) throws IOException, InterruptedException, TimeoutException
public int getPort()
public String getProjectId()
public abstract T getOptions()
public abstract void start() throws IOException, InterruptedException
IOException
InterruptedException
public abstract void stop(org.threeten.bp.Duration timeout) throws IOException, InterruptedException, TimeoutException
public abstract void reset() throws IOException
IOException
protected final String sendPostRequest(String request) throws IOException
IOException
protected static int findAvailablePort(int defaultPort)
protected static boolean isWindows()
Copyright © 2019 Google LLC. All rights reserved.