Package loci.tests.testng
Class TestTools
java.lang.Object
loci.tests.testng.TestTools
Utility methods for use with TestNG tests.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA single iteration of a tile for each loop. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancanFitInMemory(long bufferSize) Returns true if a byte buffer of the given size will fit in memory.static intforEachTile(TestTools.TileLoopIteration iteration, int sizeX, int sizeY, int sizeZ, int sizeC, int sizeT, int tileWidth, int tileHeight) Iterates over every tile in a given pixel buffer based on the over arching dimensions and a requested maximum tile width and height.static StringgetExternalConfigFile(String root, ConfigurationTree config) Deprecated.No replacement.static StringgetExternalSymlinkConfigFile(String root, ConfigurationTree config) Deprecated.No replacement.static voidgetFiles(String root, List files, ConfigurationTree config, String toplevelConfig) Recursively generate a list of files to test.static voidgetFiles(String root, List files, ConfigurationTree config, String toplevelConfig, String[] subdirs) Recursively generate a list of files to test.static voidgetFiles(String root, List files, ConfigurationTree config, String toplevelConfig, String[] subdirs, String configFileSuffix) Recursively generate a list of files to test.static voidgetFiles(String root, List files, ConfigurationTree config, String toplevelConfig, String[] subdirs, String configFileSuffix, boolean ignoreDoTest) Recursively generate a list of files to test.Retrieve a list of open file handles for the current process.getHandles(boolean filter) Retrieve a list of open file handles for the current process.static StringgetProperty(String key) Safely return a system property by key excluding default Ant valuesstatic intGet the configured number of threads.static longGets the quantity of used memory, in MB.static booleanisConfigFile(loci.common.Location file, String configFileSuffix) Recursively generate a list of files to test.static booleanisIgnoredFile(String file, ConfigurationTree config) Determines if the given file should be ignored by the test suite.static booleanisIgnoredFile(String file, ConfigurationTree config, boolean ignoreDoTest) static booleanDetermine whether or not a Throwable was caused by an OutOfMemoryError.static booleanMap the given file into memory.static Stringmd5(byte[] b) Calculate the MD5 of a byte array.static Stringmd5(byte[] b, int offset, int len) Calculate the MD5 of a byte array.static Stringmd5(byte[] b, int sizeX, int sizeY, int posX, int posY, int width, int height, int bpp) Calculate the MD5 of a byte array.static voidparseConfigFiles(String dir, ConfigurationTree config) static Stringsha1(byte[] b) Calculate the SHA-1 of a byte array.static Stringsha1(byte[] b, int offset, int len) Calculate the SHA-1 of a byte array.static StringGets the class name sans package for the given object.
-
Field Details
-
DIVIDER
- See Also:
-
baseConfigName
- See Also:
-
-
Constructor Details
-
TestTools
public TestTools()
-
-
Method Details
-
getProperty
Safely return a system property by key excluding default Ant values -
sha1
Calculate the SHA-1 of a byte array. -
sha1
Calculate the SHA-1 of a byte array. -
md5
public static String md5(byte[] b, int sizeX, int sizeY, int posX, int posY, int width, int height, int bpp) Calculate the MD5 of a byte array. -
md5
Calculate the MD5 of a byte array. -
md5
Calculate the MD5 of a byte array. -
getThreadCount
public static int getThreadCount()Get the configured number of threads. Defaults to 1 if the testng.threadCount is not set or unparseable.- Returns:
- the number of threads used in the test suite
-
canFitInMemory
public static boolean canFitInMemory(long bufferSize) Returns true if a byte buffer of the given size will fit in memory. -
getUsedMemory
public static long getUsedMemory()Gets the quantity of used memory, in MB. -
shortClassName
Gets the class name sans package for the given object. -
isConfigFile
Recursively generate a list of files to test. -
getFiles
public static void getFiles(String root, List files, ConfigurationTree config, String toplevelConfig) Recursively generate a list of files to test. -
getFiles
public static void getFiles(String root, List files, ConfigurationTree config, String toplevelConfig, String[] subdirs) Recursively generate a list of files to test. -
getExternalConfigFile
Deprecated.No replacement.Retrieve an external configuration file given a root directory and test configuration. -
getExternalSymlinkConfigFile
@Deprecated public static String getExternalSymlinkConfigFile(String root, ConfigurationTree config) Deprecated.No replacement.Retrieve an external symlinked configuration file given a root directory and a test configuration. -
getFiles
public static void getFiles(String root, List files, ConfigurationTree config, String toplevelConfig, String[] subdirs, String configFileSuffix) Recursively generate a list of files to test. -
getFiles
public static void getFiles(String root, List files, ConfigurationTree config, String toplevelConfig, String[] subdirs, String configFileSuffix, boolean ignoreDoTest) Recursively generate a list of files to test. -
parseConfigFiles
-
isIgnoredFile
Determines if the given file should be ignored by the test suite. -
isIgnoredFile
-
forEachTile
public static int forEachTile(TestTools.TileLoopIteration iteration, int sizeX, int sizeY, int sizeZ, int sizeC, int sizeT, int tileWidth, int tileHeight) Iterates over every tile in a given pixel buffer based on the over arching dimensions and a requested maximum tile width and height.- Parameters:
iteration- Invoker to call for each tile.sizeX- Width of the entire image.sizeY- Height of the entire image.sizeZ- Number of optical sections the image contains.sizeC- Number of channels the image contains.sizeT- Number of timepoints the image contains.tileWidth- Maximum width of the tile requested. The tile request itself will be smaller than the original tile width requested ifx + tileWidth > sizeX.tileHeight- Maximum height of the tile requested. The tile request itself will be smaller ify + tileHeight > sizeY.- Returns:
- The total number of tiles iterated over.
-
mapFile
Map the given file into memory.- Returns:
- true if the mapping was successful.
- Throws:
IOException
-
isOutOfMemory
Determine whether or not a Throwable was caused by an OutOfMemoryError.- Parameters:
t- Throwable object to check- Returns:
- true if
tis or was caused by an OutOfMemoryError, false otherwise
-
getHandles
Retrieve a list of open file handles for the current process.- Throws:
IOException
-
getHandles
Retrieve a list of open file handles for the current process.- Parameters:
filter- if true, removes any native libraries or JRE/JDK files- Throws:
IOException
-