public.javadoc.org.spincast.testing.core.utils.SpincastTestingUtils.html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spincast-website Show documentation
Show all versions of spincast-website Show documentation
Source code for the https://www.spincast.org website.
SpincastTestingUtils (org.spincast:spincast-framework 1.0.0 API)
org.spincast.testing.core.utils
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 and Description
static Handler<DefaultRequestContext>
dummyRouteHandler
static String
TEST_STRING
static String
TEST_STRING_LONG
-
Constructor Summary
Constructors
Constructor and Description
SpincastTestingUtils()
-
Method Summary
All Methods Static Methods Concrete Methods
Modifier and Type
Method and Description
static int
findFreePort()
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
getTestDateNoTime()
Get a test date without time.
protected static InputStream
getThisClassFileInputStream()
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
waitForTrueLoopInterval()
-
-
Field Detail
-
TEST_STRING
public static final String TEST_STRING
- See Also:
- Constant Field Values
-
TEST_STRING_LONG
public static final String TEST_STRING_LONG
- See Also:
- Constant Field Values
-
dummyRouteHandler
public static final Handler<DefaultRequestContext> dummyRouteHandler
-
Method Detail
-
getThisClassFileInputStream
protected static InputStream getThisClassFileInputStream()
-
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.
Copyright © 2019. All rights reserved.