Class FixtureUtilities
- Object
-
- FixtureUtilities
-
public class FixtureUtilities extends Object
Static methods to support the implementation of tests that use fixture configuration files. SeeOnlineTestCase
andOnlineTestSupport
for details.- Author:
- Ben Caradoc-Davies, CSIRO Earth Science and Resource Engineering
-
-
Constructor Summary
Constructors Constructor Description FixtureUtilities()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static File
getFixtureDirectory()
Return the directory containing GeoTools test fixture configuration files.static File
getFixtureFile(File fixtureDirectory, String fixtureId)
Return the file that should contain the fixture configuration properties.static Properties
loadFixture(String fixtureId)
Return Properties loaded from a fixture configuration file, or null if not found.static Properties
loadProperties(File file)
LoadProperties
from aFile
.static void
printSkipNotice(String fixtureId, File fixtureFile)
Print a notice that tests are being skipped, identifying the property file whose absence is responsible.
-
-
-
Method Detail
-
loadProperties
public static Properties loadProperties(File file)
LoadProperties
from aFile
.
-
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 idfixtureFile
- 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
orOnlineTestSupport
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 byOnlineTestCase
andOnlineTestSupport
.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 overridingTestCase.run()
orTestCase.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
-
-