2.73.0 (latest) 2.72.0 2.71.0 2.70.0 2.69.0 2.66.0 2.65.0 2.64.1 2.63.1 2.62.2 2.61.0 2.60.3 2.59.0 2.58.2 2.57.0 2.56.0 2.55.0 2.53.1 2.52.0 2.51.0 2.50.0 2.49.1 2.48.0 2.47.0 2.45.0 2.44.1 2.43.0 2.42.0 2.41.0 2.40.0 2.39.0 2.38.1 2.37.0 2.36.1 2.35.0 2.33.0 2.32.0 2.31.0 2.29.0 2.28.0 2.27.0 2.26.0 2.25.0 2.24.1 2.23.0 2.22.1 2.21.1 2.20.1 2.13.0 2.12.0 2.11.0 2.9.4 2.8.27 2.7.1 2.6.1 2.5.11 2.4.0 2.3.5

    public abstract class BaseEmulatorHelper<T>

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

## Inheritance

[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> BaseEmulatorHelper\<T\>

## Inherited Members

[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

| ## Type Parameter ||
|---|---|
| **Name** | **Description** |
| `T` |   |

## Static Fields

### DEFAULT_HOST

    protected static final String DEFAULT_HOST

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### DEFAULT_PORT

    protected static final int DEFAULT_PORT

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### PROJECT_ID_PREFIX

    protected static final String PROJECT_ID_PREFIX

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

## Static Methods

### findAvailablePort(int defaultPort)

    protected static int findAvailablePort(int defaultPort)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `defaultPort` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### isWindows()

    protected static boolean isWindows()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

## Constructors

### BaseEmulatorHelper(String emulator, int port, String projectId)

    protected BaseEmulatorHelper(String emulator, int port, String projectId)

> [!WARNING]
> **Internal Only**: This feature is not stable for application use.
>
> *This class should only be extended within google-cloud-java*

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `emulator` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |
| `port` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |
| `projectId` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |

## 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** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/List.html<https://docs.cloud.google.com/java/docs/reference/google-cloud-core/latest/com.google.cloud.testing.BaseEmulatorHelper.EmulatorRunner>` |   |

### getLogger()

    protected abstract Logger getLogger()

Returns a logger.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/logging/Logger.html` |   |

### getOptions()

    public abstract T getOptions()

Returns service options to access the local emulator.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `T` |   |

### getPort()

    public int getPort()

Returns the port to which the local emulator is listening.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### getProjectId()

    public String getProjectId()

Returns the project ID associated with the local emulator.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### reset()

    public abstract void reset()

Resets the internal state of the emulator.

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### sendPostRequest(String request)

    protected final String sendPostRequest(String request)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### start()

    public abstract void start()

Starts the local emulator.

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/InterruptedException.html` |   |

### 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** ||
|---|---|
| **Name** | **Description** |
| `blockUntilOutput` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/InterruptedException.html` |   |

### stop(Duration timeout)

    public abstract void stop(Duration timeout)

> [!WARNING]
> **Obsolete**
>
> *Use stopDuration() instead*
>
> This feature is stable for usage in this major version, but may be deprecated in a future release.

This method is obsolete. Use [#stopDuration(java.time.Duration)](https://docs.cloud.google.com/java/docs/reference/google-cloud-core/latest/com.google.cloud.testing.BaseEmulatorHelper#com_google_cloud_testing_BaseEmulatorHelper_stopDuration_java_time_Duration_) instead

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `timeout` | `org.threeten.bp.Duration` |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/InterruptedException.html` |   |
| `https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/TimeoutException.html` |   |

### stopDuration(Duration timeout)

    public void stopDuration(Duration timeout)

Stops the local emulator.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `timeout` | `https://docs.oracle.com/javase/8/docs/api/java/time/Duration.html` |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/InterruptedException.html` |   |
| `https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/TimeoutException.html` |   |

### waitForProcess(Duration timeout)

    protected final int waitForProcess(Duration timeout)

> [!WARNING]
> **Obsolete**
>
> *Use waitForProcessDuration(java.time.Duration) instead*
>
> This feature is stable for usage in this major version, but may be deprecated in a future release.

This method is obsolete. Use [#waitForProcessDuration(java.time.Duration)](https://docs.cloud.google.com/java/docs/reference/google-cloud-core/latest/com.google.cloud.testing.BaseEmulatorHelper#com_google_cloud_testing_BaseEmulatorHelper_waitForProcessDuration_java_time_Duration_) instead

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `timeout` | `org.threeten.bp.Duration` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/InterruptedException.html` |   |
| `https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/TimeoutException.html` |   |

### waitForProcessDuration(Duration timeout)

    protected final int waitForProcessDuration(Duration timeout)

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

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `timeout` | `https://docs.oracle.com/javase/8/docs/api/java/time/Duration.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/InterruptedException.html` |   |
| `https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/TimeoutException.html` |   |