Class SpincastTestingUtils

java.lang.Object
org.spincast.testing.core.utils.SpincastTestingUtils

public class SpincastTestingUtils extends Object
Spincast testing utilities.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
    static final String
     
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    Finds a free port.
    static File
     
    static File
    Gets a File from a classpath path (only works when the application si not running from an executable .jar).
    static Date
    Get a test date without time.
    protected static InputStream
     
    static boolean
    isPortAvailable(String host, int port)
    Is the specified port available? Note that this will be true at the time the method run, but may be false a couple of milliseconds after...
    static void
    logException(String fileName, Exception ex, String info)
    This method can be called to log some information about an exception wihch is hard to debug.
    static boolean
    waitForMaxSize(Collection<?> collection, int maxSize)
    This method checks frequently if the size of the specified collection is under the speficied max size.
    static boolean
    waitForMaxSize(Collection<?> collection, int maxSize, int maxMillisecToWait)
    This method checks frequently if the size of the specified collection is under the speficied max size.
    static boolean
    waitForNumber(int[] oneIntArray, int expected)
    This method checks frequently if the number of the first element of the specified int[] has reached the expected value.
    static boolean
    waitForNumber(int[] oneIntArray, int expected, int maxMillisecToWait)
    This method checks frequently if the number of the first element of the specified int[] has reached the expected value.
    static boolean
    waitForSize(Collection<?> collection, int expected)
    This method checks frequently if the size of the specified collection has reached the expected size.
    static boolean
    waitForSize(Collection<?> collection, int expected, int maxMillisecToWait)
    This method checks frequently if the size of the specified collection has reached the expected size.
    static boolean
    waitForTrue(TrueChecker trueChecker)
    Since Websockets are async, it's hard to wait for a specific period of time before validating if an event occured.
    static boolean
    waitForTrue(TrueChecker trueChecker, int maxMillisecToWait)
    Since Websockets are async, it's hard to wait for a specific period of time before validating if an event occured.
    protected static int
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • SpincastTestingUtils

      public SpincastTestingUtils()
  • Method Details

    • getThisClassFileInputStream

      protected static InputStream getThisClassFileInputStream()
    • generateTempClassFile

      public static File generateTempClassFile(File writableDir)
    • findFreePort

      public static int findFreePort()
      Finds a free port.
    • isPortAvailable

      public static boolean isPortAvailable(String host, int port)
      Is the specified port available? Note that this will be true at the time the method run, but may be false a couple of milliseconds after...
    • waitForTrue

      public static boolean waitForTrue(TrueChecker trueChecker)
      Since Websockets are async, it's hard to wait for a specific period of time before validating if an event occured. This method checks frequently if the TrueChecker returns true and when it does, it returns too. Il also waits for a maximum of 5 seconds.
    • waitForTrue

      public static boolean waitForTrue(TrueChecker trueChecker, int maxMillisecToWait)
      Since Websockets are async, it's hard to wait for a specific period of time before validating if an event occured. This method checks frequently if the TrueChecker returns true and when it does, it returns too. Il also waits for the maximum number of milliseconds specified.
    • waitForTrueLoopInterval

      protected static int waitForTrueLoopInterval()
    • waitForSize

      public static boolean waitForSize(Collection<?> collection, int expected)
      This method checks frequently if the size of the specified collection has reached the expected size. If so, it returns. Always returns after 5 seconds.
    • waitForSize

      public static boolean waitForSize(Collection<?> collection, int expected, int maxMillisecToWait)
      This method checks frequently if the size of the specified collection has reached the expected size. If so, it returns.
    • waitForMaxSize

      public static boolean waitForMaxSize(Collection<?> collection, int maxSize)
      This method checks frequently if the size of the specified collection is under the speficied max size. If so, it returns. Always returns after 5 seconds.
    • waitForMaxSize

      public static boolean waitForMaxSize(Collection<?> collection, int maxSize, int maxMillisecToWait)
      This method checks frequently if the size of the specified collection is under the speficied max size. If so, it returns.
    • waitForNumber

      public static boolean waitForNumber(int[] oneIntArray, int expected)
      This method checks frequently if the number of the first element of the specified int[] has reached the expected value. If so, it returns. Always returns after 5 seconds.
    • waitForNumber

      public static boolean waitForNumber(int[] oneIntArray, int expected, int maxMillisecToWait)
      This method checks frequently if the number of the first element of the specified int[] has reached the expected value. If so, it returns.
    • getTestDateNoTime

      public static Date getTestDateNoTime()
      Get a test date without time.
    • logException

      public static void logException(String fileName, Exception ex, String info)
      This method can be called to log some information about an exception wihch is hard to debug. It will log it in a directory which won't be deleted when the tests are done.
    • getClasspathFileNotInJar

      public static File getClasspathFileNotInJar(String relativePath)
      Gets a File from a classpath path (only works when the application si not running from an executable .jar).