Class BambooTestUtils

java.lang.Object
com.atlassian.bamboo.utils.BambooTestUtils

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

    • 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 Details

    • getShortTempDir

      public static Path getShortTempDir()
    • createTempDirectory

      public static Path createTempDirectory(String prefix) throws IOException
      Throws:
      IOException
    • 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)
    • 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

      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.
    • readFileFromResource

      @Deprecated public static String readFileFromResource(Object object, String fileName) throws IOException
      Deprecated.
      Throws:
      IOException
    • readFileFromResource

      public static String readFileFromResource(Class<?> clazz, String fileName) throws IOException
      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

      @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.