Package org.spincast.testing.core.utils
Class SpincastTestingUtils
java.lang.Object
org.spincast.testing.core.utils.SpincastTestingUtils
Spincast testing utilities.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Handler<DefaultRequestContext>
static final String
static final String
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
Finds a free port.static File
generateTempClassFile
(File writableDir) static File
getClasspathFileNotInJar
(String relativePath) 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
-
Field Details
-
TEST_STRING
- See Also:
-
TEST_STRING_LONG
- See Also:
-
dummyRouteHandler
-
-
Constructor Details
-
SpincastTestingUtils
public SpincastTestingUtils()
-
-
Method Details
-
getThisClassFileInputStream
-
generateTempClassFile
-
findFreePort
public static int findFreePort()Finds a free port. -
isPortAvailable
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
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
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
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
This method checks frequently if the size of the specified collection has reached the expected size. If so, it returns. -
waitForMaxSize
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
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
Get a test date without time. -
logException
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
Gets a File from a classpath path (only works when the application si not running from an executable .jar).
-