Package com.atlassian.bamboo.utils
Class BambooTestUtils
java.lang.Object
com.atlassian.bamboo.utils.BambooTestUtils
This class provides a collection of utility methods for use in the unit tests
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidassertFormError(ErrorCollection errorCollection, String field, String errorMessage) static voidstatic <T> Set<T> createSet(T... items) Varargs to set.static PathcreateTempDirectory(String prefix) static voidstatic FilegetFileFromResourceDirectory(Class<?> ref, String fileName) static FilegetFileFromResourceDirectory(Object object, String fileName) static InputStreamgetInputStream(@NotNull String resourceName, @NotNull Object object) Obtains the given fileName as an input stream.static InputStreamgetInputStream(String resourceName) Obtains the given fileName as an input stream.static InputStreamgetInputStream(String resourceName, Class<?> clazz) Obtains the given fileName as an input stream.static com.fasterxml.jackson.databind.JsonNodegetJsonResource(String resourceName, Class<?> clazz) static Readerstatic Pathstatic StringgetSubstitutedResource(@NotNull String resourceName, @NotNull Object object, @NotNull Properties subs) static FilegetTestDataFile(String fileName) Get file from test data directory.static StringreadFileFromResource(Class<?> clazz, String fileName) static StringreadFileFromResource(Object object, String fileName) Deprecated.static <T extends Serializable>
TserializeAndDeserialize(T object) static @NotNull StringtoVariableUsage(@NotNull String variableName) Converts variable name to a variable usage string using the default namespace "bamboo".static StringtoVariableUsage(@NotNull String variableNamespace, @NotNull String variableName) Converts variable name to a variable usage string using the provided namespace.
-
Field Details
-
NL
Convenience constant for new line -
SEP
Convenice constant for file separators -
USE_FAST_LOGIN
public static final boolean USE_FAST_LOGINWhether fast login via URL parameters should be used by tests. If this isfalse, tests should fall back to standard login.The value is
falseby default, unless a system property is specified.
-
-
Method Details
-
getShortTempDir
-
createTempDirectory
- Throws:
IOException
-
getSubstitutedResource
public static String getSubstitutedResource(@NotNull @NotNull String resourceName, @NotNull @NotNull Object object, @NotNull @NotNull Properties subs) -
getInputStream
Obtains the given fileName as an input stream. Assumes the file is located in the test source tree,- Parameters:
resourceName- The file to read as a stream- Returns:
- The stream
-
getInputStream
public static InputStream getInputStream(@NotNull @NotNull String resourceName, @NotNull @NotNull Object object) Obtains the given fileName as an input stream. Assumes the file is located in the test source tree,- Parameters:
resourceName- The file to read as a streamobject- This object's class is used to load resource- Returns:
- The stream
-
getInputStream
Obtains the given fileName as an input stream. Assumes the file is located in the test source tree,- Parameters:
resourceName- The resource nameclazz- The class to be used to load resource- Returns:
- The stream
-
getReader
-
getJsonResource
public static com.fasterxml.jackson.databind.JsonNode getJsonResource(String resourceName, Class<?> clazz) throws IOException - Throws:
IOException
-
assertFormError
public static void assertFormError(ErrorCollection errorCollection, String field, String errorMessage) -
getFileFromResourceDirectory
-
getFileFromResourceDirectory
-
getTestDataFile
Get file from test data directory. Test data directory is an external resource (separate source repository), its location is provided to test by system property. -
readFileFromResource
@Deprecated public static String readFileFromResource(Object object, String fileName) throws IOException Deprecated.since 6.3 usereadFileFromResource(Class, String)instead- Throws:
IOException
-
readFileFromResource
- Throws:
IOException
-
createActionContext
public static void createActionContext() -
destroyActionContext
public static void destroyActionContext() -
serializeAndDeserialize
public static <T extends Serializable> T serializeAndDeserialize(@NotNull T object) throws IOException, ClassNotFoundException - Throws:
IOExceptionClassNotFoundException
-
toVariableUsage
Converts variable name to a variable usage string using the default namespace "bamboo". For example, variable 'docker.image' will be converted to '${bamboo.docker.image}'.- Parameters:
variableName- variable name- Returns:
- variable usage string
-
toVariableUsage
public static String toVariableUsage(@NotNull @NotNull String variableNamespace, @NotNull @NotNull String variableName) Converts variable name to a variable usage string using the provided namespace. For example, variable 'docker.image' in namespace 'bamboo' will be converted to '${bamboo.docker.image}'.- Parameters:
variableNamespace- variable namespacevariableName- variable name- Returns:
- variable usage string
-
createSet
Varargs to set.
-
readFileFromResource(Class, String)instead