Class TextFileMatchers

java.lang.Object
org.glassfish.tests.utils.junit.matcher.TextFileMatchers

public class TextFileMatchers extends Object
Matchers for text files.
Author:
David Matejcek
  • Constructor Details

    • TextFileMatchers

      public TextFileMatchers()
  • Method Details

    • hasLineCount

      public static org.hamcrest.Matcher<File> hasLineCount(long expected, Charset charset)
      Creates a matcher for matching file's line count. File encoding.hsould be known or expected at least.
      Parameters:
      expected - expected number of lines.
      charset - the file encoding
      Returns:
      generated matcher.
    • hasLineCount

      public static org.hamcrest.Matcher<File> hasLineCount(org.hamcrest.Matcher<Long> expected, Charset charset)
      Creates a matcher for matching file's line count. File encoding.hsould be known or expected at least.
      Parameters:
      expected - Matcher for expected number of lines.
      charset - the file encoding
      Returns:
      generated matcher.
    • getterMatches

      public static <T> org.hamcrest.Matcher<File> getterMatches(Function<File,T> fileGetter, org.hamcrest.Matcher<T> expected)
      Creates a matcher for matching some file feature.
      Type Parameters:
      T - Type of the file's feature
      Parameters:
      fileGetter - Converter of File instance to T type.
      expected - Matcher for T instance obtained from the fileGetter.
      Returns:
      generated matcher.