You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/07/26 13:14:37 UTC

[commons-io] branch master updated (10079fda -> 08590bdb)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git


    from 10079fda Add missing XmlStreamReader test
     new 013b67ad Sort test members
     new 7387d242 Sort main members
     new 027475dd Organize test imports
     new 99a3ab7b Add missing RandomAccessFileInputStream test
     new 08590bdb Make new constructors private

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/commons/io/charset/CharsetDecoders.java |  4 +++
 .../apache/commons/io/charset/CharsetEncoders.java |  5 +++
 .../org/apache/commons/io/file/FilesUncheck.java   | 34 +++++++++---------
 .../java/org/apache/commons/io/file/PathUtils.java | 10 +++---
 .../apache/commons/io/function/IOBiFunction.java   | 20 +++++------
 .../apache/commons/io/function/IOQuadFunction.java | 24 ++++++-------
 .../apache/commons/io/function/IOTriFunction.java  | 22 ++++++------
 .../input/MessageDigestCalculatingInputStream.java | 38 ++++++++++----------
 .../org/apache/commons/io/monitor/FileEntry.java   |  8 ++---
 .../apache/commons/io/output/XmlStreamWriter.java  | 12 +++----
 .../org/apache/commons/io/ByteOrderMarkTest.java   |  1 +
 .../org/apache/commons/io/EndianUtilsTest.java     |  1 +
 .../io/FileUtilsDeleteDirectoryBaseTest.java       | 10 +++---
 .../commons/io/FileUtilsDirectoryContainsTest.java |  1 +
 .../java/org/apache/commons/io/FileUtilsTest.java  |  4 +--
 .../org/apache/commons/io/FilenameUtilsTest.java   |  1 +
 .../java/org/apache/commons/io/HexDumpTest.java    |  1 +
 .../java/org/apache/commons/io/IOUtilsTest.java    | 42 +++++++++++-----------
 .../commons/io/file/CopyDirectoryVisitorTest.java  |  1 +
 .../commons/io/filefilter/RegexFileFilterTest.java |  4 +--
 .../apache/commons/io/function/IOConsumerTest.java |  1 +
 .../commons/io/function/IOPredicateTest.java       | 16 ++++-----
 .../commons/io/input/AutoCloseInputStreamTest.java |  1 +
 .../io/input/MemoryMappedFileInputStreamTest.java  |  2 +-
 .../io/input/RandomAccessFileInputStreamTest.java  | 16 +++++++--
 .../commons/io/output/StringBuilderWriterTest.java |  1 +
 .../commons/io/output/WriterOutputStreamTest.java  | 10 +++---
 .../commons/io/output/XmlStreamWriterTest.java     |  2 +-
 28 files changed, 160 insertions(+), 132 deletions(-)


[commons-io] 02/05: Sort main members

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git

commit 7387d242272dcae8392f49826a3825096c687708
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Jul 26 09:04:31 2022 -0400

    Sort main members
---
 .../org/apache/commons/io/file/FilesUncheck.java   | 34 +++++++++----------
 .../java/org/apache/commons/io/file/PathUtils.java | 10 +++---
 .../apache/commons/io/function/IOBiFunction.java   | 20 ++++++------
 .../apache/commons/io/function/IOQuadFunction.java | 24 +++++++-------
 .../apache/commons/io/function/IOTriFunction.java  | 22 ++++++-------
 .../input/MessageDigestCalculatingInputStream.java | 38 +++++++++++-----------
 .../org/apache/commons/io/monitor/FileEntry.java   |  8 ++---
 .../apache/commons/io/output/XmlStreamWriter.java  | 12 +++----
 8 files changed, 84 insertions(+), 84 deletions(-)

diff --git a/src/main/java/org/apache/commons/io/file/FilesUncheck.java b/src/main/java/org/apache/commons/io/file/FilesUncheck.java
index 8a406278..f3cd712d 100644
--- a/src/main/java/org/apache/commons/io/file/FilesUncheck.java
+++ b/src/main/java/org/apache/commons/io/file/FilesUncheck.java
@@ -468,27 +468,27 @@ public class FilesUncheck {
     }
 
     /**
-     * Delegates to {@link Files#newDirectoryStream(Path, String)} throwing {@link UncheckedIOException} instead of
-     * {@link IOException}.
+     * Delegates to {@link Files#newDirectoryStream(Path, java.nio.file.DirectoryStream.Filter)} throwing
+     * {@link UncheckedIOException} instead of {@link IOException}.
      *
      * @param dir See delegate.
-     * @param glob See delegate.
+     * @param filter See delegate.
      * @return See delegate.
      */
-    public static DirectoryStream<Path> newDirectoryStream(final Path dir, final String glob) {
-        return Uncheck.apply(Files::newDirectoryStream, dir, glob);
+    public static DirectoryStream<Path> newDirectoryStream(final Path dir, final DirectoryStream.Filter<? super Path> filter) {
+        return Uncheck.apply(Files::newDirectoryStream, dir, filter);
     }
 
     /**
-     * Delegates to {@link Files#newDirectoryStream(Path, java.nio.file.DirectoryStream.Filter)} throwing
-     * {@link UncheckedIOException} instead of {@link IOException}.
+     * Delegates to {@link Files#newDirectoryStream(Path, String)} throwing {@link UncheckedIOException} instead of
+     * {@link IOException}.
      *
      * @param dir See delegate.
-     * @param filter See delegate.
+     * @param glob See delegate.
      * @return See delegate.
      */
-    public static DirectoryStream<Path> newDirectoryStream(final Path dir, final DirectoryStream.Filter<? super Path> filter) {
-        return Uncheck.apply(Files::newDirectoryStream, dir, filter);
+    public static DirectoryStream<Path> newDirectoryStream(final Path dir, final String glob) {
+        return Uncheck.apply(Files::newDirectoryStream, dir, glob);
     }
 
     /**
@@ -657,28 +657,28 @@ public class FilesUncheck {
     }
 
     /**
-     * Delegates to {@link Files#walk(Path, int, FileVisitOption...)} throwing {@link UncheckedIOException} instead of
+     * Delegates to {@link Files#walk(Path, FileVisitOption...)} throwing {@link UncheckedIOException} instead of
      * {@link IOException}.
      *
      * @param start See delegate.
-     * @param maxDepth See delegate.
      * @param options See delegate.
      * @return See delegate.
      */
-    public static Stream<Path> walk(final Path start, final int maxDepth, final FileVisitOption... options) {
-        return Uncheck.apply(Files::walk, start, maxDepth, options);
+    public static Stream<Path> walk(final Path start, final FileVisitOption... options) {
+        return Uncheck.apply(Files::walk, start, options);
     }
 
     /**
-     * Delegates to {@link Files#walk(Path, FileVisitOption...)} throwing {@link UncheckedIOException} instead of
+     * Delegates to {@link Files#walk(Path, int, FileVisitOption...)} throwing {@link UncheckedIOException} instead of
      * {@link IOException}.
      *
      * @param start See delegate.
+     * @param maxDepth See delegate.
      * @param options See delegate.
      * @return See delegate.
      */
-    public static Stream<Path> walk(final Path start, final FileVisitOption... options) {
-        return Uncheck.apply(Files::walk, start, options);
+    public static Stream<Path> walk(final Path start, final int maxDepth, final FileVisitOption... options) {
+        return Uncheck.apply(Files::walk, start, maxDepth, options);
     }
 
     /**
diff --git a/src/main/java/org/apache/commons/io/file/PathUtils.java b/src/main/java/org/apache/commons/io/file/PathUtils.java
index 59e45532..b504c4a3 100644
--- a/src/main/java/org/apache/commons/io/file/PathUtils.java
+++ b/src/main/java/org/apache/commons/io/file/PathUtils.java
@@ -836,27 +836,27 @@ public final class PathUtils {
      * Gets the file's last modified time or null if the file does not exist.
      *
      * @param path the file to query.
+     * @param defaultIfAbsent Returns this file time of the file does not exist, may be null.
      * @param options options indicating how symbolic links are handled.
      * @return the file's last modified time.
      * @throws IOException Thrown if an I/O error occurs.
      * @since 2.12.0
      */
-    public static FileTime getLastModifiedFileTime(final Path path, final LinkOption... options) throws IOException {
-        return getLastModifiedFileTime(path, null, options);
+    public static FileTime getLastModifiedFileTime(final Path path, final FileTime defaultIfAbsent, final LinkOption... options) throws IOException {
+        return Files.exists(path) ? getLastModifiedTime(path, options) : defaultIfAbsent;
     }
 
     /**
      * Gets the file's last modified time or null if the file does not exist.
      *
      * @param path the file to query.
-     * @param defaultIfAbsent Returns this file time of the file does not exist, may be null.
      * @param options options indicating how symbolic links are handled.
      * @return the file's last modified time.
      * @throws IOException Thrown if an I/O error occurs.
      * @since 2.12.0
      */
-    public static FileTime getLastModifiedFileTime(final Path path, final FileTime defaultIfAbsent, final LinkOption... options) throws IOException {
-        return Files.exists(path) ? getLastModifiedTime(path, options) : defaultIfAbsent;
+    public static FileTime getLastModifiedFileTime(final Path path, final LinkOption... options) throws IOException {
+        return getLastModifiedFileTime(path, null, options);
     }
 
     /**
diff --git a/src/main/java/org/apache/commons/io/function/IOBiFunction.java b/src/main/java/org/apache/commons/io/function/IOBiFunction.java
index aed614b2..cc5afdb9 100644
--- a/src/main/java/org/apache/commons/io/function/IOBiFunction.java
+++ b/src/main/java/org/apache/commons/io/function/IOBiFunction.java
@@ -51,16 +51,6 @@ public interface IOBiFunction<T, U, R> {
         return Constants.IO_BI_FUNCTION;
     }
 
-    /**
-     * Applies this function to the given arguments.
-     *
-     * @param t the first function argument
-     * @param u the second function argument
-     * @return the function result
-     * @throws IOException if an I/O error occurs.
-     */
-    R apply(T t, U u) throws IOException;
-
     /**
      * Returns a composed function that first applies this function to its input, and then applies the {@code after}
      * function to the result. If evaluation of either function throws an exception, it is relayed to the caller of the
@@ -75,4 +65,14 @@ public interface IOBiFunction<T, U, R> {
         Objects.requireNonNull(after);
         return (final T t, final U u) -> after.apply(apply(t, u));
     }
+
+    /**
+     * Applies this function to the given arguments.
+     *
+     * @param t the first function argument
+     * @param u the second function argument
+     * @return the function result
+     * @throws IOException if an I/O error occurs.
+     */
+    R apply(T t, U u) throws IOException;
 }
diff --git a/src/main/java/org/apache/commons/io/function/IOQuadFunction.java b/src/main/java/org/apache/commons/io/function/IOQuadFunction.java
index 73916364..470d4950 100644
--- a/src/main/java/org/apache/commons/io/function/IOQuadFunction.java
+++ b/src/main/java/org/apache/commons/io/function/IOQuadFunction.java
@@ -41,18 +41,6 @@ import java.util.function.Function;
 @FunctionalInterface
 public interface IOQuadFunction<T, U, V, W, R> {
 
-    /**
-     * Applies this function to the given arguments.
-     *
-     * @param t the first function argument
-     * @param u the second function argument
-     * @param v the third function argument
-     * @param w the fourth function argument
-     * @return the function result
-     * @throws IOException if an I/O error occurs.
-     */
-    R apply(T t, U u, V v, W w) throws IOException;
-
     /**
      * Returns a composed function that first applies this function to its input, and then applies the {@code after}
      * function to the result. If evaluation of either function throws an exception, it is relayed to the caller of the
@@ -67,4 +55,16 @@ public interface IOQuadFunction<T, U, V, W, R> {
         Objects.requireNonNull(after);
         return (final T t, final U u, final V v, final W w) -> after.apply(apply(t, u, v, w));
     }
+
+    /**
+     * Applies this function to the given arguments.
+     *
+     * @param t the first function argument
+     * @param u the second function argument
+     * @param v the third function argument
+     * @param w the fourth function argument
+     * @return the function result
+     * @throws IOException if an I/O error occurs.
+     */
+    R apply(T t, U u, V v, W w) throws IOException;
 }
diff --git a/src/main/java/org/apache/commons/io/function/IOTriFunction.java b/src/main/java/org/apache/commons/io/function/IOTriFunction.java
index c27929f2..d89ee1e8 100644
--- a/src/main/java/org/apache/commons/io/function/IOTriFunction.java
+++ b/src/main/java/org/apache/commons/io/function/IOTriFunction.java
@@ -40,17 +40,6 @@ import java.util.function.Function;
 @FunctionalInterface
 public interface IOTriFunction<T, U, V, R> {
 
-    /**
-     * Applies this function to the given arguments.
-     *
-     * @param t the first function argument
-     * @param u the second function argument
-     * @param v the third function argument
-     * @return the function result
-     * @throws IOException if an I/O error occurs.
-     */
-    R apply(T t, U u, V v) throws IOException;
-
     /**
      * Returns a composed function that first applies this function to its input, and then applies the {@code after}
      * function to the result. If evaluation of either function throws an exception, it is relayed to the caller of the
@@ -66,4 +55,15 @@ public interface IOTriFunction<T, U, V, R> {
         return (final T t, final U u, final V v) -> after.apply(apply(t, u, v));
     }
 
+    /**
+     * Applies this function to the given arguments.
+     *
+     * @param t the first function argument
+     * @param u the second function argument
+     * @param v the third function argument
+     * @return the function result
+     * @throws IOException if an I/O error occurs.
+     */
+    R apply(T t, U u, V v) throws IOException;
+
 }
diff --git a/src/main/java/org/apache/commons/io/input/MessageDigestCalculatingInputStream.java b/src/main/java/org/apache/commons/io/input/MessageDigestCalculatingInputStream.java
index 5f3d54dd..5062c352 100644
--- a/src/main/java/org/apache/commons/io/input/MessageDigestCalculatingInputStream.java
+++ b/src/main/java/org/apache/commons/io/input/MessageDigestCalculatingInputStream.java
@@ -39,14 +39,6 @@ import java.security.Provider;
  */
 public class MessageDigestCalculatingInputStream extends ObservableInputStream {
 
-    /**
-     * The default message digest algorithm.
-     * <p>
-     * The MD5 cryptographic algorithm is weak and should not be used.
-     * </p>
-     */
-    private static final String DEFAULT_ALGORITHM = "MD5";
-
     /**
      * Maintains the message digest.
      */
@@ -72,6 +64,25 @@ public class MessageDigestCalculatingInputStream extends ObservableInputStream {
         }
     }
 
+    /**
+     * The default message digest algorithm.
+     * <p>
+     * The MD5 cryptographic algorithm is weak and should not be used.
+     * </p>
+     */
+    private static final String DEFAULT_ALGORITHM = "MD5";
+
+    /**
+     * Gets a MessageDigest object that implements the default digest algorithm.
+     *
+     * @return a Message Digest object that implements the default algorithm.
+     * @throws NoSuchAlgorithmException if no Provider supports a MessageDigestSpi implementation.
+     * @see Provider
+     */
+    static MessageDigest getDefaultMessageDigest() throws NoSuchAlgorithmException {
+        return MessageDigest.getInstance(DEFAULT_ALGORITHM);
+    }
+
     private final MessageDigest messageDigest;
 
     /**
@@ -117,17 +128,6 @@ public class MessageDigestCalculatingInputStream extends ObservableInputStream {
         this(inputStream, MessageDigest.getInstance(algorithm));
     }
 
-    /**
-     * Gets a MessageDigest object that implements the default digest algorithm.
-     *
-     * @return a Message Digest object that implements the default algorithm.
-     * @throws NoSuchAlgorithmException if no Provider supports a MessageDigestSpi implementation.
-     * @see Provider
-     */
-    static MessageDigest getDefaultMessageDigest() throws NoSuchAlgorithmException {
-        return MessageDigest.getInstance(DEFAULT_ALGORITHM);
-    }
-
     /**
      * Gets the {@link MessageDigest}, which is being used for generating the
      * checksum.
diff --git a/src/main/java/org/apache/commons/io/monitor/FileEntry.java b/src/main/java/org/apache/commons/io/monitor/FileEntry.java
index 819892a5..773e1752 100644
--- a/src/main/java/org/apache/commons/io/monitor/FileEntry.java
+++ b/src/main/java/org/apache/commons/io/monitor/FileEntry.java
@@ -269,10 +269,6 @@ public class FileEntry implements Serializable {
         setLastModified(new SerializableFileTime(lastModified));
     }
 
-    void setLastModified(final SerializableFileTime lastModified) {
-        this.lastModified = lastModified;
-    }
-
     /**
      * Sets the last modified time from the last time it
      * was checked.
@@ -283,6 +279,10 @@ public class FileEntry implements Serializable {
         setLastModified(FileTime.fromMillis(lastModified));
     }
 
+    void setLastModified(final SerializableFileTime lastModified) {
+        this.lastModified = lastModified;
+    }
+
     /**
      * Sets the length.
      *
diff --git a/src/main/java/org/apache/commons/io/output/XmlStreamWriter.java b/src/main/java/org/apache/commons/io/output/XmlStreamWriter.java
index 37233fff..ab55e093 100644
--- a/src/main/java/org/apache/commons/io/output/XmlStreamWriter.java
+++ b/src/main/java/org/apache/commons/io/output/XmlStreamWriter.java
@@ -97,9 +97,11 @@ public class XmlStreamWriter extends Writer {
      *
      * @param out The output stream
      * @param defaultEncoding The default encoding if not encoding could be detected
+     * @since 2.12.0
      */
-    public XmlStreamWriter(final OutputStream out, final String defaultEncoding) {
-        this(out, Charsets.toCharset(defaultEncoding, StandardCharsets.UTF_8));
+    public XmlStreamWriter(final OutputStream out, final Charset defaultEncoding) {
+        this.out = out;
+        this.defaultCharset = Objects.requireNonNull(defaultEncoding);
     }
 
     /**
@@ -108,11 +110,9 @@ public class XmlStreamWriter extends Writer {
      *
      * @param out The output stream
      * @param defaultEncoding The default encoding if not encoding could be detected
-     * @since 2.12.0
      */
-    public XmlStreamWriter(final OutputStream out, final Charset defaultEncoding) {
-        this.out = out;
-        this.defaultCharset = Objects.requireNonNull(defaultEncoding);
+    public XmlStreamWriter(final OutputStream out, final String defaultEncoding) {
+        this(out, Charsets.toCharset(defaultEncoding, StandardCharsets.UTF_8));
     }
 
     /**


[commons-io] 05/05: Make new constructors private

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git

commit 08590bdb52cb69c176d9f5960d792f2f1f524c55
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Jul 26 09:12:16 2022 -0400

    Make new constructors private
---
 src/main/java/org/apache/commons/io/charset/CharsetDecoders.java | 4 ++++
 src/main/java/org/apache/commons/io/charset/CharsetEncoders.java | 5 +++++
 2 files changed, 9 insertions(+)

diff --git a/src/main/java/org/apache/commons/io/charset/CharsetDecoders.java b/src/main/java/org/apache/commons/io/charset/CharsetDecoders.java
index 180d585f..51c24ec5 100644
--- a/src/main/java/org/apache/commons/io/charset/CharsetDecoders.java
+++ b/src/main/java/org/apache/commons/io/charset/CharsetDecoders.java
@@ -37,4 +37,8 @@ public class CharsetDecoders {
         return charsetDecoder != null ? charsetDecoder : Charset.defaultCharset().newDecoder();
     }
 
+    /** No instances. */
+    private CharsetDecoders() {
+        // No instances.
+    }
 }
diff --git a/src/main/java/org/apache/commons/io/charset/CharsetEncoders.java b/src/main/java/org/apache/commons/io/charset/CharsetEncoders.java
index 81961d1d..b3463954 100644
--- a/src/main/java/org/apache/commons/io/charset/CharsetEncoders.java
+++ b/src/main/java/org/apache/commons/io/charset/CharsetEncoders.java
@@ -37,4 +37,9 @@ public class CharsetEncoders {
         return charsetEncoder != null ? charsetEncoder : Charset.defaultCharset().newEncoder();
     }
 
+    /** No instances. */
+    private CharsetEncoders() {
+        // No instances.
+    }
+
 }


[commons-io] 01/05: Sort test members

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git

commit 013b67adbbac20040083350c2b0c7fa630dc8011
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Jul 26 09:03:55 2022 -0400

    Sort test members
---
 .../io/FileUtilsDeleteDirectoryBaseTest.java       | 10 +++---
 .../java/org/apache/commons/io/FileUtilsTest.java  |  4 +--
 .../java/org/apache/commons/io/IOUtilsTest.java    | 42 +++++++++++-----------
 .../commons/io/function/IOPredicateTest.java       | 16 ++++-----
 .../commons/io/output/WriterOutputStreamTest.java  | 10 +++---
 5 files changed, 41 insertions(+), 41 deletions(-)

diff --git a/src/test/java/org/apache/commons/io/FileUtilsDeleteDirectoryBaseTest.java b/src/test/java/org/apache/commons/io/FileUtilsDeleteDirectoryBaseTest.java
index 0d1283a9..94c1ec3d 100644
--- a/src/test/java/org/apache/commons/io/FileUtilsDeleteDirectoryBaseTest.java
+++ b/src/test/java/org/apache/commons/io/FileUtilsDeleteDirectoryBaseTest.java
@@ -37,6 +37,11 @@ public abstract class FileUtilsDeleteDirectoryBaseTest {
 
     protected abstract boolean setupSymlink(final File res, final File link) throws Exception;
 
+    @Test
+    public void testDeleteDirectoryNullArgument() {
+        assertThrows(NullPointerException.class, () -> FileUtils.deleteDirectory(null));
+    }
+
     @Test
     public void testDeleteDirWithASymlinkDir() throws Exception {
 
@@ -250,9 +255,4 @@ public abstract class FileUtilsDeleteDirectoryBaseTest {
         assertEquals(0, top.list().length);
     }
 
-    @Test
-    public void testDeleteDirectoryNullArgument() {
-        assertThrows(NullPointerException.class, () -> FileUtils.deleteDirectory(null));
-    }
-
 }
diff --git a/src/test/java/org/apache/commons/io/FileUtilsTest.java b/src/test/java/org/apache/commons/io/FileUtilsTest.java
index 1f0e07c0..0069683d 100644
--- a/src/test/java/org/apache/commons/io/FileUtilsTest.java
+++ b/src/test/java/org/apache/commons/io/FileUtilsTest.java
@@ -89,8 +89,6 @@ import org.junit.jupiter.api.Test;
 @SuppressWarnings({"deprecation", "ResultOfMethodCallIgnored"}) // unit tests include tests of many deprecated methods
 public class FileUtilsTest extends AbstractTempDirTest {
 
-    private static final String UTF_8 = StandardCharsets.UTF_8.name();
-
     /**
      * DirectoryWalker implementation that recursively lists all files and directories.
      */
@@ -133,6 +131,8 @@ public class FileUtilsTest extends AbstractTempDirTest {
         }
     }
 
+    private static final String UTF_8 = StandardCharsets.UTF_8.name();
+
     /** Test data. */
     private static final long DATE3 = 1000000002000L;
 
diff --git a/src/test/java/org/apache/commons/io/IOUtilsTest.java b/src/test/java/org/apache/commons/io/IOUtilsTest.java
index 9623fa8f..3e6c3a86 100644
--- a/src/test/java/org/apache/commons/io/IOUtilsTest.java
+++ b/src/test/java/org/apache/commons/io/IOUtilsTest.java
@@ -624,25 +624,6 @@ public class IOUtilsTest {
         testSingleEOL("1235", "1234", false);
     }
 
-    public void testSingleEOL(final String s1, final String s2, final boolean ifEquals) throws IOException {
-        assertEquals(ifEquals, IOUtils.contentEqualsIgnoreEOL(
-                new CharArrayReader(s1.toCharArray()),
-                new CharArrayReader(s2.toCharArray())
-        ), "failed at :{" + s1 + "," + s2 + "}");
-        assertEquals(ifEquals, IOUtils.contentEqualsIgnoreEOL(
-                new CharArrayReader(s2.toCharArray()),
-                new CharArrayReader(s1.toCharArray())
-        ), "failed at :{" + s2 + "," + s1 + "}");
-        assertTrue(IOUtils.contentEqualsIgnoreEOL(
-                new CharArrayReader(s1.toCharArray()),
-                new CharArrayReader(s1.toCharArray())
-        ),"failed at :{" + s1 + "," + s1 + "}");
-        assertTrue(IOUtils.contentEqualsIgnoreEOL(
-                new CharArrayReader(s2.toCharArray()),
-                new CharArrayReader(s2.toCharArray())
-        ), "failed at :{" + s2 + "," + s2 + "}");
-    }
-
     @Test
     public void testCopy_ByteArray_OutputStream() throws Exception {
         final File destination = TestUtils.newFile(temporaryFolder, "copy8.txt");
@@ -1160,8 +1141,6 @@ public class IOUtilsTest {
         assertEquals(fileSize, content.getBytes().length);
     }
 
-    // Tests from IO-305
-
     @Test
     public void testResourceToString_ExistingResourceAtSubPackage_WithClassLoader() throws Exception {
         final long fileSize = TestResources.getFile("FileUtilsTestDataCR.dat").length();
@@ -1172,6 +1151,8 @@ public class IOUtilsTest {
         assertEquals(fileSize, content.getBytes().length);
     }
 
+    // Tests from IO-305
+
     @Test
     public void testResourceToString_NonExistingResource() {
         assertThrows(IOException.class,
@@ -1259,6 +1240,25 @@ public class IOUtilsTest {
         assertThrows(NullPointerException.class, () -> IOUtils.resourceToURL(null, ClassLoader.getSystemClassLoader()));
     }
 
+    public void testSingleEOL(final String s1, final String s2, final boolean ifEquals) throws IOException {
+        assertEquals(ifEquals, IOUtils.contentEqualsIgnoreEOL(
+                new CharArrayReader(s1.toCharArray()),
+                new CharArrayReader(s2.toCharArray())
+        ), "failed at :{" + s1 + "," + s2 + "}");
+        assertEquals(ifEquals, IOUtils.contentEqualsIgnoreEOL(
+                new CharArrayReader(s2.toCharArray()),
+                new CharArrayReader(s1.toCharArray())
+        ), "failed at :{" + s2 + "," + s1 + "}");
+        assertTrue(IOUtils.contentEqualsIgnoreEOL(
+                new CharArrayReader(s1.toCharArray()),
+                new CharArrayReader(s1.toCharArray())
+        ),"failed at :{" + s1 + "," + s1 + "}");
+        assertTrue(IOUtils.contentEqualsIgnoreEOL(
+                new CharArrayReader(s2.toCharArray()),
+                new CharArrayReader(s2.toCharArray())
+        ), "failed at :{" + s2 + "," + s2 + "}");
+    }
+
     @Test
     public void testSkip_FileReader() throws Exception {
         try (Reader in = Files.newBufferedReader(testFilePath)) {
diff --git a/src/test/java/org/apache/commons/io/function/IOPredicateTest.java b/src/test/java/org/apache/commons/io/function/IOPredicateTest.java
index a2413b58..db7d6f9e 100644
--- a/src/test/java/org/apache/commons/io/function/IOPredicateTest.java
+++ b/src/test/java/org/apache/commons/io/function/IOPredicateTest.java
@@ -91,6 +91,14 @@ public class IOPredicateTest {
         assertFalse(IS_HIDDEN.test(PATH_FIXTURE));
     }
 
+    @Test
+    public void testFalse() throws IOException {
+        assertFalse(Constants.IO_PREDICATE_FALSE.test("A"));
+        // Make sure we keep the argument type
+        final IOPredicate<String> alwaysFalse = IOPredicate.alwaysFalse();
+        assertFalse(alwaysFalse.test("A"));
+    }
+
     @Test
     public void testIsEqualChecked() throws IOException {
         assertThrowsChecked(() -> IOPredicate.isEqual(THROWING_EQUALS).test("B"));
@@ -147,14 +155,6 @@ public class IOPredicateTest {
         assertTrue(Constants.IO_PREDICATE_TRUE.asPredicate().test("A"));
     }
 
-    @Test
-    public void testFalse() throws IOException {
-        assertFalse(Constants.IO_PREDICATE_FALSE.test("A"));
-        // Make sure we keep the argument type
-        final IOPredicate<String> alwaysFalse = IOPredicate.alwaysFalse();
-        assertFalse(alwaysFalse.test("A"));
-    }
-
     @Test
     public void testTrue() throws IOException {
         assertTrue(Constants.IO_PREDICATE_TRUE.test("A"));
diff --git a/src/test/java/org/apache/commons/io/output/WriterOutputStreamTest.java b/src/test/java/org/apache/commons/io/output/WriterOutputStreamTest.java
index 1a32e3ff..497334f4 100644
--- a/src/test/java/org/apache/commons/io/output/WriterOutputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/output/WriterOutputStreamTest.java
@@ -79,6 +79,11 @@ public class WriterOutputStreamTest {
         testWithSingleByteWrite(LARGE_TEST_STRING, UTF_8);
     }
 
+    @Test
+    public void testNullCharsetDecoderWithSingleByteWrite() throws IOException {
+        testWithSingleByteWrite(TEST_STRING, (CharsetDecoder) null);
+    }
+
     @Test
     public void testNullCharsetNameWithSingleByteWrite() throws IOException {
         testWithSingleByteWrite(TEST_STRING, (String) null);
@@ -89,11 +94,6 @@ public class WriterOutputStreamTest {
         testWithSingleByteWrite(TEST_STRING, (Charset) null);
     }
 
-    @Test
-    public void testNullCharsetDecoderWithSingleByteWrite() throws IOException {
-        testWithSingleByteWrite(TEST_STRING, (CharsetDecoder) null);
-    }
-
     @Test
     public void testUTF16BEWithBufferedWrite() throws IOException {
         testWithBufferedWrite(TEST_STRING, UTF_16BE);


[commons-io] 03/05: Organize test imports

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git

commit 027475dd1e22665da9bae8ba76563bd6ac1a27d5
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Jul 26 09:05:21 2022 -0400

    Organize test imports
---
 src/test/java/org/apache/commons/io/ByteOrderMarkTest.java            | 1 +
 src/test/java/org/apache/commons/io/EndianUtilsTest.java              | 1 +
 .../java/org/apache/commons/io/FileUtilsDirectoryContainsTest.java    | 1 +
 src/test/java/org/apache/commons/io/FilenameUtilsTest.java            | 1 +
 src/test/java/org/apache/commons/io/HexDumpTest.java                  | 1 +
 .../java/org/apache/commons/io/file/CopyDirectoryVisitorTest.java     | 1 +
 .../java/org/apache/commons/io/filefilter/RegexFileFilterTest.java    | 4 ++--
 src/test/java/org/apache/commons/io/function/IOConsumerTest.java      | 1 +
 .../java/org/apache/commons/io/input/AutoCloseInputStreamTest.java    | 1 +
 .../org/apache/commons/io/input/MemoryMappedFileInputStreamTest.java  | 2 +-
 .../java/org/apache/commons/io/output/StringBuilderWriterTest.java    | 1 +
 src/test/java/org/apache/commons/io/output/XmlStreamWriterTest.java   | 2 +-
 12 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/test/java/org/apache/commons/io/ByteOrderMarkTest.java b/src/test/java/org/apache/commons/io/ByteOrderMarkTest.java
index 1cc156bc..fe2430bc 100644
--- a/src/test/java/org/apache/commons/io/ByteOrderMarkTest.java
+++ b/src/test/java/org/apache/commons/io/ByteOrderMarkTest.java
@@ -22,6 +22,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import java.nio.charset.Charset;
 
 import org.junit.jupiter.api.Test;
diff --git a/src/test/java/org/apache/commons/io/EndianUtilsTest.java b/src/test/java/org/apache/commons/io/EndianUtilsTest.java
index e8adbe51..c49f3333 100644
--- a/src/test/java/org/apache/commons/io/EndianUtilsTest.java
+++ b/src/test/java/org/apache/commons/io/EndianUtilsTest.java
@@ -18,6 +18,7 @@ package org.apache.commons.io;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.EOFException;
diff --git a/src/test/java/org/apache/commons/io/FileUtilsDirectoryContainsTest.java b/src/test/java/org/apache/commons/io/FileUtilsDirectoryContainsTest.java
index 2dc8f337..bba9f098 100644
--- a/src/test/java/org/apache/commons/io/FileUtilsDirectoryContainsTest.java
+++ b/src/test/java/org/apache/commons/io/FileUtilsDirectoryContainsTest.java
@@ -19,6 +19,7 @@ package org.apache.commons.io;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
+
 import java.io.File;
 import java.io.IOException;
 
diff --git a/src/test/java/org/apache/commons/io/FilenameUtilsTest.java b/src/test/java/org/apache/commons/io/FilenameUtilsTest.java
index aa1ea8a1..2912575f 100644
--- a/src/test/java/org/apache/commons/io/FilenameUtilsTest.java
+++ b/src/test/java/org/apache/commons/io/FilenameUtilsTest.java
@@ -21,6 +21,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
+
 import java.io.BufferedOutputStream;
 import java.io.File;
 import java.io.IOException;
diff --git a/src/test/java/org/apache/commons/io/HexDumpTest.java b/src/test/java/org/apache/commons/io/HexDumpTest.java
index 75ab9e79..6e8e0046 100644
--- a/src/test/java/org/apache/commons/io/HexDumpTest.java
+++ b/src/test/java/org/apache/commons/io/HexDumpTest.java
@@ -18,6 +18,7 @@ package org.apache.commons.io;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import java.io.IOException;
 
 import org.apache.commons.io.output.ByteArrayOutputStream;
diff --git a/src/test/java/org/apache/commons/io/file/CopyDirectoryVisitorTest.java b/src/test/java/org/apache/commons/io/file/CopyDirectoryVisitorTest.java
index 9ed8a80e..fb0fe15e 100644
--- a/src/test/java/org/apache/commons/io/file/CopyDirectoryVisitorTest.java
+++ b/src/test/java/org/apache/commons/io/file/CopyDirectoryVisitorTest.java
@@ -21,6 +21,7 @@ import static org.apache.commons.io.file.CounterAssertions.assertCounts;
 import static org.junit.jupiter.api.Assertions.assertArrayEquals;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotEquals;
+
 import java.io.IOException;
 import java.nio.file.CopyOption;
 import java.nio.file.Path;
diff --git a/src/test/java/org/apache/commons/io/filefilter/RegexFileFilterTest.java b/src/test/java/org/apache/commons/io/filefilter/RegexFileFilterTest.java
index ee95fff1..3318ad13 100644
--- a/src/test/java/org/apache/commons/io/filefilter/RegexFileFilterTest.java
+++ b/src/test/java/org/apache/commons/io/filefilter/RegexFileFilterTest.java
@@ -16,10 +16,10 @@
  */
 package org.apache.commons.io.filefilter;
 
-import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.File;
 import java.io.IOException;
diff --git a/src/test/java/org/apache/commons/io/function/IOConsumerTest.java b/src/test/java/org/apache/commons/io/function/IOConsumerTest.java
index 79c421e9..22eac031 100644
--- a/src/test/java/org/apache/commons/io/function/IOConsumerTest.java
+++ b/src/test/java/org/apache/commons/io/function/IOConsumerTest.java
@@ -19,6 +19,7 @@ package org.apache.commons.io.function;
 
 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 import static org.junit.jupiter.api.Assertions.assertEquals;
+
 import java.io.Closeable;
 import java.io.IOException;
 import java.io.StringReader;
diff --git a/src/test/java/org/apache/commons/io/input/AutoCloseInputStreamTest.java b/src/test/java/org/apache/commons/io/input/AutoCloseInputStreamTest.java
index b80b2fb1..455db058 100644
--- a/src/test/java/org/apache/commons/io/input/AutoCloseInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/AutoCloseInputStreamTest.java
@@ -22,6 +22,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
+
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
diff --git a/src/test/java/org/apache/commons/io/input/MemoryMappedFileInputStreamTest.java b/src/test/java/org/apache/commons/io/input/MemoryMappedFileInputStreamTest.java
index 0645150b..dae929ff 100644
--- a/src/test/java/org/apache/commons/io/input/MemoryMappedFileInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/MemoryMappedFileInputStreamTest.java
@@ -16,9 +16,9 @@
  */
 package org.apache.commons.io.input;
 
+import static org.apache.commons.lang3.ArrayUtils.EMPTY_BYTE_ARRAY;
 import static org.junit.jupiter.api.Assertions.assertArrayEquals;
 import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.apache.commons.lang3.ArrayUtils.EMPTY_BYTE_ARRAY;
 
 import java.io.IOException;
 import java.io.InputStream;
diff --git a/src/test/java/org/apache/commons/io/output/StringBuilderWriterTest.java b/src/test/java/org/apache/commons/io/output/StringBuilderWriterTest.java
index a268585e..f9ea879f 100644
--- a/src/test/java/org/apache/commons/io/output/StringBuilderWriterTest.java
+++ b/src/test/java/org/apache/commons/io/output/StringBuilderWriterTest.java
@@ -18,6 +18,7 @@ package org.apache.commons.io.output;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertSame;
+
 import java.io.IOException;
 import java.io.Writer;
 
diff --git a/src/test/java/org/apache/commons/io/output/XmlStreamWriterTest.java b/src/test/java/org/apache/commons/io/output/XmlStreamWriterTest.java
index 4f4e126c..2a005bed 100644
--- a/src/test/java/org/apache/commons/io/output/XmlStreamWriterTest.java
+++ b/src/test/java/org/apache/commons/io/output/XmlStreamWriterTest.java
@@ -16,8 +16,8 @@
  */
 package org.apache.commons.io.output;
 
-import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.ByteArrayOutputStream;


[commons-io] 04/05: Add missing RandomAccessFileInputStream test

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git

commit 99a3ab7b71ce63d8ad608c1fea2ba8e4ec50de83
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Jul 26 09:10:13 2022 -0400

    Add missing RandomAccessFileInputStream test
---
 .../io/input/RandomAccessFileInputStreamTest.java        | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/test/java/org/apache/commons/io/input/RandomAccessFileInputStreamTest.java b/src/test/java/org/apache/commons/io/input/RandomAccessFileInputStreamTest.java
index 7622e61b..45e1d019 100644
--- a/src/test/java/org/apache/commons/io/input/RandomAccessFileInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/RandomAccessFileInputStreamTest.java
@@ -57,7 +57,7 @@ public class RandomAccessFileInputStreamTest {
     }
 
     @Test
-    public void testCtorCloseOnCloseFalse() throws IOException {
+    public void testConstructorCloseOnCloseFalse() throws IOException {
         try (RandomAccessFile file = createRandomAccessFile()) {
             try (RandomAccessFileInputStream inputStream = new RandomAccessFileInputStream(file, false)) {
                 assertFalse(inputStream.isCloseOnClose());
@@ -67,7 +67,7 @@ public class RandomAccessFileInputStreamTest {
     }
 
     @Test
-    public void testCtorCloseOnCloseTrue() throws IOException {
+    public void testConstructorCloseOnCloseTrue() throws IOException {
         try (RandomAccessFile file = createRandomAccessFile()) {
             try (RandomAccessFileInputStream inputStream = new RandomAccessFileInputStream(file, true)) {
                 assertTrue(inputStream.isCloseOnClose());
@@ -77,7 +77,17 @@ public class RandomAccessFileInputStreamTest {
     }
 
     @Test
-    public void testCtorNullFile() {
+    public void testConstructorFile() throws IOException {
+        try (RandomAccessFile file = createRandomAccessFile()) {
+            try (RandomAccessFileInputStream inputStream = new RandomAccessFileInputStream(file)) {
+                assertFalse(inputStream.isCloseOnClose());
+            }
+            file.read();
+        }
+    }
+
+    @Test
+    public void testConstructorFileNull() {
         assertThrows(NullPointerException.class, () -> new RandomAccessFileInputStream(null));
     }