Package org.evomaster.test.utils
Class EMTestUtils
java.lang.Object
org.evomaster.test.utils.EMTestUtils
Class containing utility functions that can be used in the
automatically generated tests
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringextractJDKPathWithEnvVarName(String jdkEnvVarName) Resolves the absolute path to the Java executable using the given JDK environment variable name.static StringextractSutJarNameWithEnvVarName(String sutDistEnvVarName, String sutJarEnvVarName) Resolves the absolute path to a System-Under-Test (SUT) JAR file using environment variables.static booleanisValidURIorEmpty(String uri) static StringresolveLocation(String locationHeader, String expectedTemplate)
-
Constructor Details
-
EMTestUtils
public EMTestUtils()
-
-
Method Details
-
resolveLocation
- Parameters:
locationHeader- a URI-reference, coming from a "location" header. See RFC 7231. Note: it can be a relative referenceexpectedTemplate- a full URI of the target resource, but with some path elements that might (or might not) be unresolved. IflocationHeaderis 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
- Parameters:
uri- a string representing a URI- Returns:
- whether the given input string is either empty or a valid URI
-
extractJDKPathWithEnvVarName
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 distributionsutJarEnvVarName- 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
-