Class BambooTestUtils


  • public class BambooTestUtils
    extends Object
    This class provides a collection of utility methods for use in the unit tests
    • Field Detail

      • NL

        public static final String NL
        Convenience constant for new line
      • SEP

        public static final String SEP
        Convenice constant for file separators
      • USE_FAST_LOGIN

        public static final boolean USE_FAST_LOGIN
        Whether fast login via URL parameters should be used by tests. If this is false, tests should fall back to standard login.

        The value is false by default, unless a system property is specified.

    • Method Detail

      • getShortTempDir

        public static Path getShortTempDir()
      • getSubstitutedResource

        public static String getSubstitutedResource​(@NotNull
                                                    @NotNull String resourceName,
                                                    @NotNull
                                                    @NotNull Object object,
                                                    @NotNull
                                                    @NotNull Properties subs)
      • getInputStream

        public static InputStream getInputStream​(String resourceName)
        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 stream
        object - This object's class is used to load resource
        Returns:
        The stream
      • getInputStream

        public static InputStream getInputStream​(String resourceName,
                                                 Class<?> clazz)
        Obtains the given fileName as an input stream. Assumes the file is located in the test source tree,
        Parameters:
        resourceName - The resource name
        clazz - The class to be used to load resource
        Returns:
        The stream
      • getReader

        public static Reader getReader​(String resourceName)
      • getFileFromResourceDirectory

        public static File getFileFromResourceDirectory​(Object object,
                                                        String fileName)
      • getFileFromResourceDirectory

        public static File getFileFromResourceDirectory​(Class<?> ref,
                                                        String fileName)
      • getTestDataFile

        public static File getTestDataFile​(String fileName)
        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.
      • createActionContext

        public static void createActionContext()
      • destroyActionContext

        public static void destroyActionContext()
      • toVariableUsage

        @NotNull
        public static @NotNull String toVariableUsage​(@NotNull
                                                      @NotNull String variableName)
        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 namespace
        variableName - variable name
        Returns:
        variable usage string
      • createSet

        public static <T> Set<T> createSet​(T... items)
        Varargs to set.