Class TestTools

java.lang.Object
loci.tests.testng.TestTools

public class TestTools extends Object
Utility methods for use with TestNG tests.
  • Field Details

  • Constructor Details

    • TestTools

      public TestTools()
  • Method Details

    • getProperty

      public static String getProperty(String key)
      Safely return a system property by key excluding default Ant values
    • sha1

      public static String sha1(byte[] b, int offset, int len)
      Calculate the SHA-1 of a byte array.
    • sha1

      public static String sha1(byte[] b)
      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

      public static String md5(byte[] b, int offset, int len)
      Calculate the MD5 of a byte array.
    • md5

      public static String md5(byte[] b)
      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

      public static String shortClassName(Object o)
      Gets the class name sans package for the given object.
    • isConfigFile

      public static boolean isConfigFile(loci.common.Location file, String configFileSuffix)
      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 public static String getExternalConfigFile(String root, ConfigurationTree config)
      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

      public static void parseConfigFiles(String dir, ConfigurationTree config)
    • isIgnoredFile

      public static boolean isIgnoredFile(String file, ConfigurationTree config)
      Determines if the given file should be ignored by the test suite.
    • isIgnoredFile

      public static boolean isIgnoredFile(String file, ConfigurationTree config, boolean ignoreDoTest)
    • 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 if x + tileWidth > sizeX.
      tileHeight - Maximum height of the tile requested. The tile request itself will be smaller if y + tileHeight > sizeY.
      Returns:
      The total number of tiles iterated over.
    • mapFile

      public static boolean mapFile(String id) throws IOException
      Map the given file into memory.
      Returns:
      true if the mapping was successful.
      Throws:
      IOException
    • isOutOfMemory

      public static boolean isOutOfMemory(Throwable t)
      Determine whether or not a Throwable was caused by an OutOfMemoryError.
      Parameters:
      t - Throwable object to check
      Returns:
      true if t is or was caused by an OutOfMemoryError, false otherwise
    • getHandles

      public static ArrayList<String> getHandles() throws IOException
      Retrieve a list of open file handles for the current process.
      Throws:
      IOException
    • getHandles

      public static ArrayList<String> getHandles(boolean filter) throws IOException
      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