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 2025/04/06 17:51:33 UTC

(commons-io) branch master updated (d3edd85e4 -> e48e3e3fd)

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 d3edd85e4 Javadoc
     new bf503a33d Better test method name
     new d528fb580 Migrate test from deprecated code
     new 819afc8d4 Migrate test from deprecated code
     new e48e3e3fd Migrate from deprecated code

The 4 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:
 .../commons/io/input/AbstractInputStreamTest.java  | 27 ++++++++++++++++++++--
 .../commons/io/input/ByteBufferCleanerTest.java    |  2 +-
 .../io/input/MemoryMappedFileInputStreamTest.java  |  2 +-
 3 files changed, 27 insertions(+), 4 deletions(-)


(commons-io) 02/04: Migrate test from deprecated code

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 d528fb5809e99b43a95ab01cedf97025290ca6c3
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Apr 6 13:47:47 2025 -0400

    Migrate test from deprecated code
---
 .../org/apache/commons/io/input/MemoryMappedFileInputStreamTest.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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 4b684621a..d78825c67 100644
--- a/src/test/java/org/apache/commons/io/input/MemoryMappedFileInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/MemoryMappedFileInputStreamTest.java
@@ -61,7 +61,7 @@ public void afterEach() {
     }
 
     private Path createTestFile(final int size) throws IOException {
-        return Files.write(Files.createTempFile(tempDir, null, null), RandomUtils.insecure().nextBytes(size));
+        return Files.write(Files.createTempFile(tempDir, null, null), RandomUtils.insecure().randomBytes(size));
     }
 
     private MemoryMappedFileInputStream newInputStream(final Path file) throws IOException {


(commons-io) 01/04: Better test method name

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 bf503a33deb1d3d2fa8fcf89fbee1c61c5a079d9
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Apr 6 10:38:56 2025 -0400

    Better test method name
---
 src/test/java/org/apache/commons/io/input/AbstractInputStreamTest.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/test/java/org/apache/commons/io/input/AbstractInputStreamTest.java b/src/test/java/org/apache/commons/io/input/AbstractInputStreamTest.java
index 477ba5826..5de74b06b 100644
--- a/src/test/java/org/apache/commons/io/input/AbstractInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/AbstractInputStreamTest.java
@@ -163,7 +163,7 @@ public void testReadMultipleBytes() throws IOException {
     }
 
     @Test
-    public void testReadOneByte() throws IOException {
+    public void testReadOneByOne() throws IOException {
         for (final InputStream inputStream : inputStreams) {
             for (final byte randomByte : expectedRandomBytes) {
                 assertEquals(randomByte, (byte) inputStream.read());


(commons-io) 04/04: Migrate from deprecated code

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 e48e3e3fd06995078a1d1832124c5bc77df28969
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Apr 6 13:51:28 2025 -0400

    Migrate from deprecated code
    
    Add a test to check that available() doesn't have a side effect on
    read()
---
 .../commons/io/input/AbstractInputStreamTest.java  | 25 +++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/src/test/java/org/apache/commons/io/input/AbstractInputStreamTest.java b/src/test/java/org/apache/commons/io/input/AbstractInputStreamTest.java
index 5de74b06b..0cf985f81 100644
--- a/src/test/java/org/apache/commons/io/input/AbstractInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/AbstractInputStreamTest.java
@@ -24,6 +24,8 @@
 import java.io.InputStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Supplier;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.RandomUtils;
@@ -56,7 +58,7 @@ static int[] getArrayLengths() {
     @BeforeEach
     public void setUp() throws IOException {
         // Create a byte array of size 2 MB with random bytes
-        actualRandomBytes = RandomUtils.insecure().nextBytes(2 * 1024 * 1024);
+        actualRandomBytes = RandomUtils.insecure().randomBytes(2 * 1024 * 1024);
         expectedRandomBytes = actualRandomBytes;
         inputFile = Files.createTempFile("temp-file", ".tmp");
         Files.write(inputFile, actualRandomBytes);
@@ -171,6 +173,27 @@ public void testReadOneByOne() throws IOException {
         }
     }
 
+    @Test
+    public void testReadOneByOneCheckAvailable() throws IOException {
+        final AtomicInteger refII = new AtomicInteger();
+        for (int idxInputs = 0; idxInputs < inputStreams.length; idxInputs++) {
+            refII.set(idxInputs);
+            final AtomicInteger refIB = new AtomicInteger();
+            @SuppressWarnings("resource")
+            final InputStream inputStream = inputStreams[idxInputs];
+            for (int idxBytes = 0; idxBytes < expectedRandomBytes.length; idxBytes++) {
+                refIB.set(idxBytes);
+                final byte randomByte = expectedRandomBytes[idxBytes];
+                // Check that available() doesn't have a side effect on read()
+                final int available = inputStream.available();
+                final Supplier<String> messageSupplier = () -> String.format("idxInputs = %,d, idxBytes = %,d, available = %,d", refII.get(), refIB.get(),
+                        available);
+                assertTrue(available >= 0, messageSupplier);
+                assertEquals(randomByte, (byte) inputStream.read());
+            }
+        }
+    }
+
     @Test
     public void testReadPastEOF() throws IOException {
         final InputStream is = inputStreams[0];


(commons-io) 03/04: Migrate test from deprecated code

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 819afc8d494741ff8bd05f36d43af813b6f6b04a
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Apr 6 13:47:55 2025 -0400

    Migrate test from deprecated code
---
 src/test/java/org/apache/commons/io/input/ByteBufferCleanerTest.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/test/java/org/apache/commons/io/input/ByteBufferCleanerTest.java b/src/test/java/org/apache/commons/io/input/ByteBufferCleanerTest.java
index 21f86b824..535f713a5 100644
--- a/src/test/java/org/apache/commons/io/input/ByteBufferCleanerTest.java
+++ b/src/test/java/org/apache/commons/io/input/ByteBufferCleanerTest.java
@@ -39,7 +39,7 @@ void testCleanEmpty() {
     @Test
     void testCleanFull() {
         final ByteBuffer buffer = ByteBuffer.allocateDirect(10);
-        buffer.put(RandomUtils.insecure().nextBytes(10), 0, 10);
+        buffer.put(RandomUtils.insecure().randomBytes(10), 0, 10);
         // There is no way verify that the buffer has been cleaned up, we are just verifying that
         // clean() doesn't blow up
         ByteBufferCleaner.clean(buffer);