public class ServerUtils
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
ServerUtils.ProcessParameters
Forking process parameters.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
PROPERTIES_FILE_NAME |
Constructor and Description |
---|
ServerUtils() |
Modifier and Type | Method and Description |
---|---|
static java.nio.file.Path |
getDefaultSharedSettingsPath()
Returns the default path to the settings directory for the test
resources server in case it needs to be shared between builds.
|
static java.nio.file.Path |
getDefaultSharedSettingsPath(java.lang.String namespace)
Returns the default path to the settings directory for the test
resources server in case it needs to be shared between builds.
|
static boolean |
isServerStarted(int port)
Determines if a server is already started at the given port.
|
static java.util.Optional<ServerSettings> |
readServerSettings(java.nio.file.Path settingsDirectory)
Reads the server settings from an input directory.
|
static ServerSettings |
startOrConnectToExistingServer(java.lang.Integer explicitPort,
java.nio.file.Path portFilePath,
java.nio.file.Path serverSettingsDirectory,
java.lang.String accessToken,
java.util.Collection<java.io.File> serverClasspath,
java.lang.Integer clientTimeoutMs,
ServerFactory serverFactory)
Starts a server at the given port, or connects to an existing server running
at the given port.
|
static ServerSettings |
startOrConnectToExistingServer(java.lang.Integer explicitPort,
java.nio.file.Path portFilePath,
java.nio.file.Path serverSettingsDirectory,
java.lang.String accessToken,
java.nio.file.Path cdsDirectory,
java.util.Collection<java.io.File> serverClasspath,
java.lang.Integer clientTimeoutMs,
ServerFactory serverFactory)
Starts a server at the given port, or connects to an existing server running
at the given port.
|
static void |
stopServer(java.nio.file.Path serverSettingsDirectory)
Stops a running server.
|
static void |
writeServerSettings(java.nio.file.Path destinationDirectory,
ServerSettings settings)
Writes the server settings in an output directory.
|
public static final java.lang.String PROPERTIES_FILE_NAME
public static void writeServerSettings(java.nio.file.Path destinationDirectory, ServerSettings settings) throws java.io.IOException
destinationDirectory
- the destination directorysettings
- the settingsjava.io.IOException
- if an error occurspublic static java.util.Optional<ServerSettings> readServerSettings(java.nio.file.Path settingsDirectory)
settingsDirectory
- the settings directorypublic static boolean isServerStarted(int port)
port
- the port to checkpublic static ServerSettings startOrConnectToExistingServer(java.lang.Integer explicitPort, java.nio.file.Path portFilePath, java.nio.file.Path serverSettingsDirectory, java.lang.String accessToken, java.nio.file.Path cdsDirectory, java.util.Collection<java.io.File> serverClasspath, java.lang.Integer clientTimeoutMs, ServerFactory serverFactory) throws java.io.IOException
explicitPort
- the explicit port to connect to, if it exists.portFilePath
- the path to the port file, where the port will be written.serverSettingsDirectory
- the server settings directory, will be written.accessToken
- the access token, if anycdsDirectory
- the CDS directory. If not null, class data sharing will be enabledserverClasspath
- the server classpathclientTimeoutMs
- the client timeoutserverFactory
- the server factory, responsible for forking a processjava.io.IOException
- if an error occurspublic static ServerSettings startOrConnectToExistingServer(java.lang.Integer explicitPort, java.nio.file.Path portFilePath, java.nio.file.Path serverSettingsDirectory, java.lang.String accessToken, java.util.Collection<java.io.File> serverClasspath, java.lang.Integer clientTimeoutMs, ServerFactory serverFactory) throws java.io.IOException
explicitPort
- the explicit port to connect to, if it exists.portFilePath
- the path to the port file, where the port will be written.serverSettingsDirectory
- the server settings directory, will be written.accessToken
- the access token, if anyserverClasspath
- the server classpathclientTimeoutMs
- the client timeoutserverFactory
- the server factory, responsible for forking a processjava.io.IOException
- if an error occurspublic static void stopServer(java.nio.file.Path serverSettingsDirectory) throws java.io.IOException
serverSettingsDirectory
- the settings directoryjava.io.IOException
- if an error occurspublic static java.nio.file.Path getDefaultSharedSettingsPath()
getDefaultSharedSettingsPath(String)
without a namespace.public static java.nio.file.Path getDefaultSharedSettingsPath(java.lang.String namespace)
namespace
- the namespace of the shared settings