Package org.glassfish.tests.utils
Class ServerUtils
java.lang.Object
org.glassfish.tests.utils.ServerUtils
- Author:
- David Matejcek
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic FileCreates a simple war file made of provided classes.static StringDownloads content from the url.static intTries to allocate a free local port.static Stringstatic org.glassfish.embeddable.CommandResultrunCommand(org.glassfish.embeddable.GlassFish glassfish, String cmd, String params) Executes a command on embedded GlassFish instance.
-
Constructor Details
-
ServerUtils
public ServerUtils()
-
-
Method Details
-
getFreePort
Tries to allocate a free local port.- Returns:
- a free local port number.
- Throws:
IllegalStateException- if it fails for 20 times
-
getLocalIP4Address
- Returns:
- the IP address of the localhost.
-
createWar
Creates a simple war file made of provided classes.- Parameters:
warFile- the WAR fileclasses- a classes to be included to the WAR file- Returns:
- file usable for deployment.
-
download
Downloads content from the url. Expects there is a service listening and returning textual response. Therefore this is usable just for simple servlets.- Parameters:
url- target URL- Returns:
- content from the url.
- Throws:
IOException- if an error occurred
-
runCommand
public static org.glassfish.embeddable.CommandResult runCommand(org.glassfish.embeddable.GlassFish glassfish, String cmd, String params) throws org.glassfish.embeddable.GlassFishException Executes a command on embedded GlassFish instance.- Parameters:
glassfish- an embedded GlassFish instancecmd- a command to runparams- command parameters- Returns:
- result of command execution
- Throws:
org.glassfish.embeddable.GlassFishException- if an error occurred
-