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
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
assertFormError
(ErrorCollection errorCollection, String field, String errorMessage) static void
static <T> Set<T>
createSet
(T... items) Varargs to set.static Path
createTempDirectory
(String prefix) static void
static File
getFileFromResourceDirectory
(Class<?> ref, String fileName) static File
getFileFromResourceDirectory
(Object object, String fileName) static InputStream
getInputStream
(@NotNull String resourceName, @NotNull Object object) Obtains the given fileName as an input stream.static InputStream
getInputStream
(String resourceName) Obtains the given fileName as an input stream.static InputStream
getInputStream
(String resourceName, Class<?> clazz) Obtains the given fileName as an input stream.static com.fasterxml.jackson.databind.JsonNode
getJsonResource
(String resourceName, Class<?> clazz) static Reader
static Path
static String
getSubstitutedResource
(@NotNull String resourceName, @NotNull Object object, @NotNull Properties subs) static File
getTestDataFile
(String fileName) Get file from test data directory.static String
readFileFromResource
(Class<?> clazz, String fileName) static String
readFileFromResource
(Object object, String fileName) Deprecated.static <T extends Serializable>
TserializeAndDeserialize
(T object) static @NotNull String
toVariableUsage
(@NotNull String variableName) Converts variable name to a variable usage string using the default namespace "bamboo".static String
toVariableUsage
(@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
false
by 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:
IOException
ClassNotFoundException
-
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