Package org.glassfish.tests.utils
Class ServerUtils
- java.lang.Object
-
- org.glassfish.tests.utils.ServerUtils
-
public class ServerUtils extends Object
- Author:
- David Matejcek
-
-
Constructor Summary
Constructors Constructor Description ServerUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static FilecreateWar(File warFile, Class<?>... classes)Creates a simple war file made of provided classes.static Stringdownload(URL url)Downloads content from the url.static intgetFreePort()Tries to alocate a free local port.static StringgetLocalIP4Address()
-
-
-
Method Detail
-
getFreePort
public static int getFreePort() throws IllegalStateExceptionTries to alocate a free local port.- Returns:
- a free local port number.
- Throws:
IllegalStateException- if it fails for 20 times
-
getLocalIP4Address
public static String getLocalIP4Address()
- Returns:
- the IP address of the localhost.
-
createWar
public static File createWar(File warFile, Class<?>... classes)
Creates a simple war file made of provided classes.- Parameters:
warFile-classes-- Returns:
- file usable for deployment.
-
download
public static String download(URL url) throws IOException
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-- Returns:
- content from the url.
- Throws:
IOException
-
-