Class IOTester


  • public final class IOTester
    extends java.lang.Object
    With the IOTester you can assert if two files have equals content or if two directories have the same structure with equal files.

    Note: This test is not yet tested with binary files.

    Since:
    1.1 (30.03.2011)
    Author:
    oliver
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void assertContentEquals​(java.io.BufferedReader r1, java.io.BufferedReader r2)
      Asserts that the content of two Readers are equal.
      static void assertContentEquals​(java.io.InputStream in1, java.io.InputStream in2)
      Asserts that the content of two InputStream are equal.
      static void assertContentEquals​(java.io.InputStream in1, java.io.InputStream in2, int from, int to)
      Asserts that the content of two InputStream are equal.
      static void assertContentEquals​(java.io.InputStream in1, java.io.InputStream in2, java.nio.charset.Charset encoding)
      Asserts that the content of two InputStream are equal.
      static void assertContentEquals​(java.io.InputStream in1, java.io.InputStream in2, java.nio.charset.Charset encoding, int from, int to)
      Asserts that the content of two InputStream are equal.
      static void assertContentEquals​(java.io.InputStream in1, java.io.InputStream in2, java.nio.charset.Charset encoding, java.util.regex.Pattern... ignores)
      Asserts that the content of two Readers are equal.
      static void assertContentEquals​(java.io.InputStream in1, java.io.InputStream in2, java.util.regex.Pattern... ignores)
      Asserts that the content of two Readers are equal.
      static void assertContentEquals​(java.io.Reader r1, java.io.Reader r2)
      Asserts that the content of two Readers are equal.
      static void assertContentEquals​(java.io.Reader r1, java.io.Reader r2, int from, int to)
      Asserts that the content of two Readers are equal.
      static void assertContentEquals​(java.io.Reader r1, java.io.Reader r2, java.util.regex.Pattern... ignores)
      Asserts that the content of two Readers are equal.
      static void assertContentEquals​(java.io.Reader r1, java.io.Reader r2, StringConverter converter)
      Asserts that the content of two Readers are equal.
      static void assertContentEquals​(java.io.Reader r1, java.io.Reader r2, StringConverter converter, java.util.regex.Pattern[] ignores)
      Asserts that the content of two Readers are equal.
      static void assertContentEquals​(LineReader r1, LineReader r2, int from, int to)
      Asserts that the content of two Readers are equal.
      static void assertContentEquals​(LineReader r1, LineReader r2, java.util.regex.Pattern... ignores)
      Asserts that the content of two Readers are equal.
      static void assertContentEquals​(LineReader r1, LineReader r2, StringConverter converter, java.util.regex.Pattern[] ignores)
      Asserts that the content of two Readers are equal.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • assertContentEquals

        public static void assertContentEquals​(java.io.InputStream in1,
                                               java.io.InputStream in2)
                                        throws java.lang.AssertionError
        Asserts that the content of two InputStream are equal. If they are not equals the first different line or byte will be shown.
        Parameters:
        in1 - the first InputStream
        in2 - the second InputStream
        Throws:
        java.lang.AssertionError - if the check fails
      • assertContentEquals

        public static void assertContentEquals​(java.io.InputStream in1,
                                               java.io.InputStream in2,
                                               java.nio.charset.Charset encoding)
                                        throws java.lang.AssertionError
        Asserts that the content of two InputStream are equal. If they are not equals the first different line or byte will be shown.
        Parameters:
        in1 - the first InputStream
        in2 - the second InputStream
        encoding - the encoding
        Throws:
        java.lang.AssertionError - if the check fails
      • assertContentEquals

        public static void assertContentEquals​(java.io.InputStream in1,
                                               java.io.InputStream in2,
                                               int from,
                                               int to)
                                        throws java.lang.AssertionError
        Asserts that the content of two InputStream are equal. If they are not equals the first different line or byte will be shown.
        Parameters:
        in1 - the first InputStream
        in2 - the second InputStream
        from - the line number from which the comparison is started (starting with 1)
        to - the last line number where the comparison ends.
        Throws:
        java.lang.AssertionError - if the check fails
      • assertContentEquals

        public static void assertContentEquals​(java.io.InputStream in1,
                                               java.io.InputStream in2,
                                               java.nio.charset.Charset encoding,
                                               int from,
                                               int to)
                                        throws java.lang.AssertionError
        Asserts that the content of two InputStream are equal. If they are not equals the first different line or byte will be shown.
        Parameters:
        in1 - the first InputStream
        in2 - the second InputStream
        encoding - the encoding
        from - the line number from which the comparison is started (starting with 1)
        to - the last line number where the comparison ends.
        Throws:
        java.lang.AssertionError - if the check fails
      • assertContentEquals

        public static void assertContentEquals​(java.io.InputStream in1,
                                               java.io.InputStream in2,
                                               java.util.regex.Pattern... ignores)
                                        throws java.lang.AssertionError
        Asserts that the content of two Readers are equal. If they are not equals the first different line or byte will be shown.
        Parameters:
        in1 - the first InputStream
        in2 - the second InputStream
        ignores - the lines matching this pattern will be ignored
        Throws:
        java.lang.AssertionError - if the check fails
      • assertContentEquals

        public static void assertContentEquals​(java.io.InputStream in1,
                                               java.io.InputStream in2,
                                               java.nio.charset.Charset encoding,
                                               java.util.regex.Pattern... ignores)
                                        throws java.lang.AssertionError
        Asserts that the content of two Readers are equal. If they are not equals the first different line or byte will be shown.
        Parameters:
        in1 - the first InputStream
        in2 - the second InputStream
        encoding - the encoding
        ignores - the lines matching this pattern will be ignored
        Throws:
        java.lang.AssertionError - if the check fails
      • assertContentEquals

        public static void assertContentEquals​(java.io.Reader r1,
                                               java.io.Reader r2)
                                        throws java.lang.AssertionError
        Asserts that the content of two Readers are equal. If they are not equals the first different line or byte will be shown.
        Parameters:
        r1 - the first Reader
        r2 - the second Reader
        Throws:
        java.lang.AssertionError - if the check fails
      • assertContentEquals

        public static void assertContentEquals​(java.io.Reader r1,
                                               java.io.Reader r2,
                                               int from,
                                               int to)
                                        throws java.lang.AssertionError
        Asserts that the content of two Readers are equal. If they are not equals the first different line or byte will be shown.
        Parameters:
        r1 - the first Reader
        r2 - the second Reader
        from - the line number from which the comparison is started (starting with 1)
        to - the last line number where the comparison ends.
        Throws:
        java.lang.AssertionError - if the check fails
      • assertContentEquals

        public static void assertContentEquals​(java.io.Reader r1,
                                               java.io.Reader r2,
                                               java.util.regex.Pattern... ignores)
                                        throws java.lang.AssertionError
        Asserts that the content of two Readers are equal. If they are not equals the first different line or byte will be shown.
        Parameters:
        r1 - the first Reader
        r2 - the second Reader
        ignores - the lines matching this pattern will be ignored
        Throws:
        java.lang.AssertionError - if the check fails
      • assertContentEquals

        public static void assertContentEquals​(java.io.Reader r1,
                                               java.io.Reader r2,
                                               StringConverter converter)
                                        throws java.lang.AssertionError
        Asserts that the content of two Readers are equal. If they are not equals the first different line or byte will be shown.

        For comparison the lines are converted before by the given StringConverter. This allows you e.g. to ignore white spaces (by using StringConverter.IGNORE_WHITESPACES as parameter) or to ignore upper / lower case problems (StringConverter.LOWER_CASE).

        Parameters:
        r1 - the first Reader
        r2 - the second Reader
        converter - the converter
        Throws:
        java.lang.AssertionError - if the check fails
        Since:
        1.6
      • assertContentEquals

        public static void assertContentEquals​(java.io.BufferedReader r1,
                                               java.io.BufferedReader r2)
                                        throws java.lang.AssertionError
        Asserts that the content of two Readers are equal. If they are not equals the first different line or byte will be shown.
        Parameters:
        r1 - the first Reader
        r2 - the second Reader
        Throws:
        java.lang.AssertionError - if the check fails
      • assertContentEquals

        public static void assertContentEquals​(LineReader r1,
                                               LineReader r2,
                                               int from,
                                               int to)
                                        throws java.lang.AssertionError
        Asserts that the content of two Readers are equal. If they are not equals the first different line or byte will be shown.
        Parameters:
        r1 - the first Reader
        r2 - the second Reader
        from - the line number from which the comparison is started (starting with 1)
        to - the last line number where the comparison ends.
        Throws:
        java.lang.AssertionError - if the check fails
      • assertContentEquals

        public static void assertContentEquals​(LineReader r1,
                                               LineReader r2,
                                               java.util.regex.Pattern... ignores)
                                        throws java.lang.AssertionError
        Asserts that the content of two Readers are equal. If they are not equals the first different line or byte will be shown.
        Parameters:
        r1 - the first Reader
        r2 - the second Reader
        ignores - the lines matching this pattern will be ignored
        Throws:
        java.lang.AssertionError - if the check fails
      • assertContentEquals

        public static void assertContentEquals​(java.io.Reader r1,
                                               java.io.Reader r2,
                                               StringConverter converter,
                                               java.util.regex.Pattern[] ignores)
        Asserts that the content of two Readers are equal. If they are not equals the first different line or byte will be shown.

        For comparison the lines are converted before by the given StringConverter. This allows you e.g. to ignore white spaces (by using StringConverter.IGNORE_WHITESPACES as parameter) or to ignore upper / lower case problems (StringConverter.LOWER_CASE).

        Lines which matches the given 'ignores' pattern will be ignored for comparison. This is done before the converter is executed. E.g. the 'ignores' pattern must match the original line.

        Parameters:
        r1 - the r1
        r2 - the r2
        converter - the converter
        ignores - the ignores
        Since:
        1.6
      • assertContentEquals

        public static void assertContentEquals​(LineReader r1,
                                               LineReader r2,
                                               StringConverter converter,
                                               java.util.regex.Pattern[] ignores)
        Asserts that the content of two Readers are equal. If they are not equals the first different line or byte will be shown.

        For comparison the lines are converted before by the given StringConverter. This allows you e.g. to ignore white spaces (by using StringConverter.IGNORE_WHITESPACES as parameter) or to ignore upper / lower case problems (StringConverter.LOWER_CASE).

        Lines which matches the given 'ignores' pattern will be ignored for comparison. This is done before the converter is executed. E.g. the 'ignores' pattern must match the original line.

        Parameters:
        r1 - the r1
        r2 - the r2
        converter - the converter
        ignores - the ignores