Class TestUtils


  • public class TestUtils
    extends Object
    Author:
    Ales Justin, Jakub Stejskal
    • Method Detail

      • isExternalRegistry

        public static boolean isExternalRegistry()
      • getRegistryHost

        public static String getRegistryHost()
      • getRegistryPort

        public static int getRegistryPort()
      • getRegistryUIUrl

        public static String getRegistryUIUrl()
      • getRegistryApiUrl

        public static String getRegistryApiUrl()
      • getRegistryV1ApiUrl

        public static String getRegistryV1ApiUrl()
      • getRegistryV2ApiUrl

        public static String getRegistryV2ApiUrl()
      • getRegistryBaseUrl

        public static String getRegistryBaseUrl()
      • isReachable

        public static boolean isReachable()
        Method which try connection to registries. It's used as a initial check for registries availability.
        Returns:
        true if registries are ready for use, false in other cases
      • isReachable

        public static boolean isReachable​(String host,
                                          int port,
                                          String component)
        Generic check if an endpoint is network reachable
        Parameters:
        host -
        port -
        component -
        Returns:
        true if it's possible to open a network connection to the endpoint
      • isReady

        public static boolean isReady​(boolean logResponse)
        Checks the readniess endpoint of the registry
        Returns:
        true if registry readiness endpoint replies sucessfully
      • isReady

        public static boolean isReady​(String baseUrl,
                                      String healthUrl,
                                      boolean logResponse,
                                      String component)
        Generic check of the /health/ready endpoint
        Parameters:
        baseUrl -
        logResponse -
        component -
        Returns:
        true if the readiness endpoint replies successfully
      • waitFor

        public static long waitFor​(String description,
                                   long pollIntervalMs,
                                   long timeoutMs,
                                   BooleanSupplier ready)
                            throws TimeoutException
        Poll the given ready function every pollIntervalMs milliseconds until it returns true, or throw a TimeoutException if it doesn't returns true within timeoutMs milliseconds. (helpful if you have several calls which need to share a common timeout)
        Returns:
        The remaining time left until timeout occurs
        Throws:
        TimeoutException
      • writeFile

        public static void writeFile​(String filePath,
                                     String text)
        Method to create and write String content file.
        Parameters:
        filePath - path to file
        text - content
      • writeFile

        public static void writeFile​(Path filePath,
                                     String text)
      • generateTopic

        public static String generateTopic()
      • generateTopic

        public static String generateTopic​(String prefix)
      • generateSubject

        public static String generateSubject()
      • generateArtifactId

        public static String generateArtifactId()
      • generateGroupId

        public static String generateGroupId()