Class Fixtures


  • public class Fixtures
    extends Object
    Helper methods for working with test fixtures.
    • Constructor Detail

      • Fixtures

        public Fixtures()
    • 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 URI
        UncheckedIOException - 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 resource
        charset - the charset of the fixture file
        Returns:
        the fixture contents
        Throws:
        org.kiwiproject.net.UncheckedURISyntaxException - if the resource name/path is invalid as a URI
        UncheckedIOException - if an I/O error occurs
      • fixtureFile

        public static File fixtureFile​(String resourceName)
        Resolves the given fixture file name/path as a File.
        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 a Path.
        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