Package org.spincast.testing.core.utils
Class SpincastTestingUtils
java.lang.Object
org.spincast.testing.core.utils.SpincastTestingUtils
Spincast testing utilities.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Handler<DefaultRequestContext>static final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intFinds a free port.static FilegenerateTempClassFile(File writableDir) static FilegetClasspathFileNotInJar(String relativePath) Gets a File from a classpath path (only works when the application si not running from an executable .jar).static DateGet a test date without time.protected static InputStreamstatic booleanisPortAvailable(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 voidlogException(String fileName, Exception ex, String info) This method can be called to log some information about an exception wihch is hard to debug.static booleanwaitForMaxSize(Collection<?> collection, int maxSize) This method checks frequently if the size of the specified collection is under the speficied max size.static booleanwaitForMaxSize(Collection<?> collection, int maxSize, int maxMillisecToWait) This method checks frequently if the size of the specified collection is under the speficied max size.static booleanwaitForNumber(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 booleanwaitForNumber(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 booleanwaitForSize(Collection<?> collection, int expected) This method checks frequently if the size of the specified collection has reached the expected size.static booleanwaitForSize(Collection<?> collection, int expected, int maxMillisecToWait) This method checks frequently if the size of the specified collection has reached the expected size.static booleanwaitForTrue(TrueChecker trueChecker) Since Websockets are async, it's hard to wait for a specific period of time before validating if an event occured.static booleanwaitForTrue(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).
-