Class ServerUtils

java.lang.Object
org.glassfish.tests.utils.ServerUtils

public class ServerUtils extends Object
Author:
David Matejcek
  • Constructor Details

    • ServerUtils

      public ServerUtils()
  • Method Details

    • getFreePort

      public static int getFreePort() throws IllegalStateException
      Tries 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