Package org.kiwiproject.test.util
Class Fixtures
- java.lang.Object
-
- org.kiwiproject.test.util.Fixtures
-
public class Fixtures extends Object
Helper methods for working with test fixtures.
-
-
Constructor Summary
Constructors Constructor Description Fixtures()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
fixture(String resourceName)
Reads the given fixture file from the classpath (e.static String
fixture(String resourceName, Charset charset)
Reads the given fixture file from the classpath (e.static File
fixtureFile(String resourceName)
Resolves the given fixture file name/path as aFile
.static Path
fixturePath(String resourceName)
Resolves the given fixture file name/path as aPath
.
-
-
-
Method Detail
-
fixture
public static String fixture(String resourceName)
Reads the given fixture file from the classpath (e. g.src/test/resources
) and returns its contents as a UTF-8 string.- Parameters:
resourceName
- the name/path of to the classpath resource- Returns:
- the fixture contents
- Throws:
org.kiwiproject.net.UncheckedURISyntaxException
- if the resource name/path is invalid as a URIUncheckedIOException
- if an I/O error occurs
-
fixture
public static String fixture(String resourceName, Charset charset)
Reads the given fixture file from the classpath (e. g.src/test/resources
) and returns its contents as a string.- Parameters:
resourceName
- the name/path of to the classpath resourcecharset
- the charset of the fixture file- Returns:
- the fixture contents
- Throws:
org.kiwiproject.net.UncheckedURISyntaxException
- if the resource name/path is invalid as a URIUncheckedIOException
- if an I/O error occurs
-
fixtureFile
public static File fixtureFile(String resourceName)
Resolves the given fixture file name/path as aFile
.- Parameters:
resourceName
- the name/path of to the classpath resource- Returns:
- the resource as a
File
- Throws:
org.kiwiproject.net.UncheckedURISyntaxException
- if the resource name/path is invalid as a URI
-
fixturePath
public static Path fixturePath(String resourceName)
Resolves the given fixture file name/path as aPath
.- Parameters:
resourceName
- the name/path of to the classpath resource- Returns:
- the resource as a
Path
- Throws:
org.kiwiproject.net.UncheckedURISyntaxException
- if the resource name/path is invalid
-
-