Class EMTestUtils

java.lang.Object
org.evomaster.test.utils.EMTestUtils

public class EMTestUtils extends Object
Class containing utility functions that can be used in the automatically generated tests
  • Constructor Details

    • EMTestUtils

      public EMTestUtils()
  • Method Details

    • resolveLocation

      public static String resolveLocation(String locationHeader, String expectedTemplate)
      Parameters:
      locationHeader - a URI-reference, coming from a "location" header. See RFC 7231. Note: it can be a relative reference
      expectedTemplate - a full URI of the target resource, but with some path elements that might (or might not) be unresolved. If locationHeader is not empty, it will replace the beginning of this template.
      Returns:
      a fully resolved URI for the target resource. If there are problems, just return the input locationHeader. If this latter is empty/null, then return the template
    • isValidURIorEmpty

      public static boolean isValidURIorEmpty(String uri)
      Parameters:
      uri - a string representing a URI
      Returns:
      whether the given input string is either empty or a valid URI
    • extractJDKPathWithEnvVarName

      public static String extractJDKPathWithEnvVarName(String jdkEnvVarName)
      Resolves the absolute path to the Java executable using the given JDK environment variable name.

      This method expects the environment variable (e.g. JAVA_HOME) to point to a JDK installation directory. It appends "bin" and "java" to construct the full path to the Java executable.

      Parameters:
      jdkEnvVarName - the name of the JDK environment variable (e.g. "JAVA_HOME")
      Returns:
      the absolute path to the Java executable as a String
      Throws:
      RuntimeException - if the environment variable is not defined or empty
    • extractSutJarNameWithEnvVarName

      public static String extractSutJarNameWithEnvVarName(String sutDistEnvVarName, String sutJarEnvVarName)
      Resolves the absolute path to a System-Under-Test (SUT) JAR file using environment variables.
      Parameters:
      sutDistEnvVarName - the environment variable that contains the base directory of the SUT distribution
      sutJarEnvVarName - the name of the JAR file (or relative path inside the distribution)
      Returns:
      the absolute path to the SUT JAR file as a String
      Throws:
      RuntimeException - if the distribution environment variable is not defined or empty