Class FixtureUtilities


  • public class FixtureUtilities
    extends Object
    Static methods to support the implementation of tests that use fixture configuration files. See OnlineTestCase and OnlineTestSupport for details.
    Author:
    Ben Caradoc-Davies, CSIRO Earth Science and Resource Engineering
    • Constructor Detail

      • FixtureUtilities

        public FixtureUtilities()
    • Method Detail

      • getFixtureDirectory

        public static File getFixtureDirectory()
        Return the directory containing GeoTools test fixture configuration files. This is ".geotools" in the user home directory.
      • getFixtureFile

        public static File getFixtureFile​(File fixtureDirectory,
                                          String fixtureId)
        Return the file that should contain the fixture configuration properties. It is not guaranteed to exist.

        Dots "." in the fixture id represent a subdirectory path under the GeoTools configuration file directory. For example, an id a.b.foo would be resolved to .geotools/a/b/foo.properties. the base fixture configuration file directory, typically ".geotools" in the user home directory. the fixture id

      • printSkipNotice

        public static void printSkipNotice​(String fixtureId,
                                           File fixtureFile)
        Print a notice that tests are being skipped, identifying the property file whose absence is responsible.
        Parameters:
        fixtureId - the fixture id
        fixtureFile - the missing fixture configuration file
      • loadFixture

        public static Properties loadFixture​(String fixtureId)
        Return Properties loaded from a fixture configuration file, or null if not found.

        If a fixture configuration file is not found, a notice is printed to standard output stating that tests for this fixture id are skipped.

        This method allows tests that cannot extend OnlineTestCase or OnlineTestSupport because they already extend another class (for example, a non-online test framework) to access fixture configuration files in the same way that those classes do. Only basic fixture configuration loading is supported. This method does not support the extra services such as fixture caching and connection testing provided by OnlineTestCase and OnlineTestSupport.

        A JUnit 4 test fixture can readily be disabled in the absence of a fixture configuration file by placing Assume.assumeNotNull(FixtureUtilities.loadFixture(fixtureId)) or similar in its @BeforeClass method. JUnit 3 tests must provide their own logic, typically overriding TestCase.run() or TestCase.runTest(), or providing a suite.

        Parameters:
        fixtureId - the fixture id, where dots "." are converted to subdirectories.
        Returns:
        the fixture Properties or null
        See Also:
        OnlineTestCase, OnlineTestSupport