Class UrlBuilder

java.lang.Object
org.codice.ddf.test.common.UrlBuilder

public class UrlBuilder extends Object
Builder class for URLs.
  • Method Details

    • from

      public static UrlBuilder from(String hostname, String port, String securePort, String rootContext)
      Creates a UrlBuilder from static values.
      Parameters:
      hostname - host name to use in the URL
      port - port to use in the URL
      securePort - secure port to use in the URL
      rootContext - root context of the URL
      Returns:
      new UrlBuilder instance
    • fromSystemProperties

      public static UrlBuilder fromSystemProperties(String hostnameSystemProperty, String portSystemProperty, String securePortSystemProperty, String rootContextSystemProperty)
      Creates a UrlBuilder from system property values.
      Parameters:
      hostnameSystemProperty - name of the system property that contains the host name to use in the URL
      portSystemProperty - name of the system property that contains the port to use in the URL
      securePortSystemProperty - name of the system property that contains the secure port to use in the URL
      rootContextSystemProperty - name of the system property that contains the root context of the URL
      Returns:
      new UrlBuilder instance
    • add

      public UrlBuilder add(String contextPath)
      Adds a context path to an existing URL. The method will take care of adding and/or removing any extraneous / at the beginning or end of the context path provided to guarantee that the URL is always valid.
      Parameters:
      contextPath - context path to add to the URL
      Returns:
      this UrlBuilder
    • build

      public URL build()
      Builds an http URL from the base URL information provided and all the context paths added.
      Returns:
      http URL
    • buildSecure

      public URL buildSecure()
      Builds an https URL from the base URL information provided and all the context paths added.
      Returns:
      https URL