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/03/03 14:54:50 UTC
(commons-io) branch master updated (a7cf506dd -> 46e99a439)
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 a7cf506dd Add missing argument in test
new e7a754265 Add Javadoc since tag
new 77a191563 Simplify test
new ae70118ac Remove unused test infra
new 46e99a439 More FileChannels testing
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:
.../apache/commons/io/channels/FileChannels.java | 1 +
.../commons/io/channels/FileChannelsTest.java | 234 ++++++++++-----------
2 files changed, 116 insertions(+), 119 deletions(-)
(commons-io) 03/04: Remove unused test infra
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 ae70118ac7e95d910e90c9f1b1893f593b5e2f67
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Mon Mar 3 08:02:41 2025 -0500
Remove unused test infra
---
src/test/java/org/apache/commons/io/channels/FileChannelsTest.java | 7 -------
1 file changed, 7 deletions(-)
diff --git a/src/test/java/org/apache/commons/io/channels/FileChannelsTest.java b/src/test/java/org/apache/commons/io/channels/FileChannelsTest.java
index 2ad0d1c5f..a29fb4457 100644
--- a/src/test/java/org/apache/commons/io/channels/FileChannelsTest.java
+++ b/src/test/java/org/apache/commons/io/channels/FileChannelsTest.java
@@ -30,7 +30,6 @@
import java.nio.channels.SeekableByteChannel;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.time.Duration;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
@@ -59,12 +58,6 @@ public static int[] getBufferSizes() {
return new int[] { 1, 2, IOUtils.DEFAULT_BUFFER_SIZE / 10, IOUtils.DEFAULT_BUFFER_SIZE, IOUtils.DEFAULT_BUFFER_SIZE * 10 };
}
- public static Object[][] getBufferSizesAndTimeouts() {
- // 1 and 2 are unusual and slow edge cases, but edge cases nonetheless.
- return new Object[][] { { 1, Duration.ZERO }, { 2, Duration.ZERO }, { IOUtils.DEFAULT_BUFFER_SIZE / 10, Duration.ZERO },
- { IOUtils.DEFAULT_BUFFER_SIZE, Duration.ZERO }, { IOUtils.DEFAULT_BUFFER_SIZE * 10, Duration.ZERO } };
- }
-
private static FileChannel open(final Path path, final FileChannelType fileChannelType) throws IOException {
final FileChannel fc = FileChannel.open(path);
if (fileChannelType != null) {
(commons-io) 02/04: Simplify 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 77a191563d80a53b6c972f53415bc30f306819da
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Mon Mar 3 07:59:12 2025 -0500
Simplify test
---
.../commons/io/channels/FileChannelsTest.java | 158 ++++++++++-----------
1 file changed, 79 insertions(+), 79 deletions(-)
diff --git a/src/test/java/org/apache/commons/io/channels/FileChannelsTest.java b/src/test/java/org/apache/commons/io/channels/FileChannelsTest.java
index fecc70a58..2ad0d1c5f 100644
--- a/src/test/java/org/apache/commons/io/channels/FileChannelsTest.java
+++ b/src/test/java/org/apache/commons/io/channels/FileChannelsTest.java
@@ -27,6 +27,7 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
+import java.nio.channels.SeekableByteChannel;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;
@@ -64,81 +65,6 @@ public static Object[][] getBufferSizesAndTimeouts() {
{ IOUtils.DEFAULT_BUFFER_SIZE, Duration.ZERO }, { IOUtils.DEFAULT_BUFFER_SIZE * 10, Duration.ZERO } };
}
- private static byte reverse(final byte b) {
- return (byte) (~b & 0xff);
- }
-
- private boolean isEmpty(final File empty) {
- return empty.length() == 0;
- }
-
- private FileChannel reset(final FileChannel fc) throws IOException {
- return fc.position(0);
- }
-
- @CartesianTest()
- public void testContentEquals(
- @Values(ints = { 1, 2, IOUtils.DEFAULT_BUFFER_SIZE / 10, IOUtils.DEFAULT_BUFFER_SIZE, IOUtils.DEFAULT_BUFFER_SIZE * 10 }) final int bufferSize,
- @CartesianTest.Enum final FileChannelType fileChannelType1, @CartesianTest.Enum final FileChannelType fileChannelType2) throws IOException {
- final Path bigFile1 = Files.createTempFile(getClass().getSimpleName(), "-1.bin");
- final Path bigFile2 = Files.createTempFile(getClass().getSimpleName(), "-2.bin");
- final Path bigFile3 = Files.createTempFile(getClass().getSimpleName(), "-3.bin");
- try {
- // This length must match any restriction from the Surefire configuration.
- final int newLength = 1_000_000;
- final byte[] bytes1 = new byte[newLength];
- final byte[] bytes2 = new byte[newLength];
- // Make sure bytes1 and bytes2 are different despite the shuffle
- ArrayUtils.shuffle(bytes1);
- bytes1[0] = 1;
- ArrayUtils.shuffle(bytes2);
- bytes2[0] = 2;
- Files.write(bigFile1, bytes1);
- Files.write(bigFile2, bytes2);
- try (FileChannel fc1 = open(bigFile1, fileChannelType1); FileChannel fc2 = open(bigFile2, fileChannelType2)) {
- assertFalse(FileChannels.contentEquals(fc1, fc2, bufferSize));
- assertFalse(FileChannels.contentEquals(reset(fc2), reset(fc1), bufferSize));
- assertTrue(FileChannels.contentEquals(reset(fc1), reset(fc1), bufferSize));
- }
- // Make the LAST byte different.
- byte[] bytes3 = bytes1.clone();
- final int last = bytes3.length - 1;
- bytes3[last] = reverse(bytes3[last]);
- Files.write(bigFile3, bytes3);
- try (FileChannel fc1 = open(bigFile1, fileChannelType1); FileChannel fc3 = open(bigFile3, fileChannelType2)) {
- assertFalse(FileChannels.contentEquals(fc1, fc3, bufferSize));
- assertFalse(FileChannels.contentEquals(reset(fc3), reset(fc1), bufferSize));
- // Test just the last byte
- fc1.position(last);
- fc3.position(last);
- assertFalse(FileChannels.contentEquals(fc1, fc3, bufferSize));
- }
- // Make the LAST byte equal.
- bytes3 = bytes1.clone();
- Files.write(bigFile3, bytes3);
- try (FileChannel fc1 = open(bigFile1, fileChannelType1); FileChannel fc3 = open(bigFile3, fileChannelType2)) {
- // Test just the last byte
- fc1.position(last);
- fc3.position(last);
- assertTrue(FileChannels.contentEquals(fc1, fc3, bufferSize));
- }
- // Make a byte in the middle different
- bytes3 = bytes1.clone();
- final int middle = bytes3.length / 2;
- bytes3[middle] = reverse(bytes3[middle]);
- Files.write(bigFile3, bytes3);
- try (FileChannel fc1 = open(bigFile1, fileChannelType1); FileChannel fc3 = open(bigFile3, fileChannelType2)) {
- assertFalse(FileChannels.contentEquals(fc1, fc3, bufferSize));
- assertFalse(FileChannels.contentEquals(reset(fc3), reset(fc1), bufferSize));
- }
- } finally {
- // Delete ASAP
- Files.deleteIfExists(bigFile1);
- Files.deleteIfExists(bigFile2);
- Files.deleteIfExists(bigFile3);
- }
- }
-
private static FileChannel open(final Path path, final FileChannelType fileChannelType) throws IOException {
final FileChannel fc = FileChannel.open(path);
if (fileChannelType != null) {
@@ -156,6 +82,18 @@ private static FileChannel open(final Path path, final FileChannelType fileChann
return FileChannel.open(path);
}
+ private static byte reverse(final byte b) {
+ return (byte) (~b & 0xff);
+ }
+
+ private boolean isEmpty(final File empty) {
+ return empty.length() == 0;
+ }
+
+ private FileChannel reset(final FileChannel fc) throws IOException {
+ return fc.position(0);
+ }
+
private void testContentEquals(final String content1, final String content2, final int bufferSize) throws IOException {
assertTrue(FileChannels.contentEquals(null, null, bufferSize));
// Prepare test files with same size but different content
@@ -221,10 +159,9 @@ public void testContentEqualsEmpty(final int bufferSize) throws IOException {
}
@CartesianTest
- public void testContentEqualsTimeout(
- @Values(ints = { 1, 2, IOUtils.DEFAULT_BUFFER_SIZE / 10, IOUtils.DEFAULT_BUFFER_SIZE, IOUtils.DEFAULT_BUFFER_SIZE * 10 }) final int bufferSize,
- @Values(ints = { 0, 1 }) final int timeoutMillis) throws IOException {
- final Duration timeout = Duration.ofMillis(timeoutMillis);
+ public void testContentEqualsFileChannel(
+ @Values(ints = { 1, 2, IOUtils.DEFAULT_BUFFER_SIZE / 10, IOUtils.DEFAULT_BUFFER_SIZE, IOUtils.DEFAULT_BUFFER_SIZE * 10 }) final int bufferSize)
+ throws IOException {
final Path bigFile1 = Files.createTempFile(getClass().getSimpleName(), "-1.bin");
final Path bigFile2 = Files.createTempFile(getClass().getSimpleName(), "-2.bin");
final Path bigFile3 = Files.createTempFile(getClass().getSimpleName(), "-3.bin");
@@ -283,4 +220,67 @@ public void testContentEqualsTimeout(
Files.deleteIfExists(bigFile3);
}
}
+
+ @CartesianTest()
+ public void testContentEqualsSeekableByteChannel(
+ @Values(ints = { 1, 2, IOUtils.DEFAULT_BUFFER_SIZE / 10, IOUtils.DEFAULT_BUFFER_SIZE, IOUtils.DEFAULT_BUFFER_SIZE * 10 }) final int bufferSize,
+ @CartesianTest.Enum final FileChannelType fileChannelType1, @CartesianTest.Enum final FileChannelType fileChannelType2) throws IOException {
+ final Path bigFile1 = Files.createTempFile(getClass().getSimpleName(), "-1.bin");
+ final Path bigFile2 = Files.createTempFile(getClass().getSimpleName(), "-2.bin");
+ final Path bigFile3 = Files.createTempFile(getClass().getSimpleName(), "-3.bin");
+ try {
+ // This length must match any restriction from the Surefire configuration.
+ final int newLength = 1_000_000;
+ final byte[] bytes1 = new byte[newLength];
+ final byte[] bytes2 = new byte[newLength];
+ // Make sure bytes1 and bytes2 are different despite the shuffle
+ ArrayUtils.shuffle(bytes1);
+ bytes1[0] = 1;
+ ArrayUtils.shuffle(bytes2);
+ bytes2[0] = 2;
+ Files.write(bigFile1, bytes1);
+ Files.write(bigFile2, bytes2);
+ try (FileChannel fc1 = open(bigFile1, fileChannelType1); FileChannel fc2 = open(bigFile2, fileChannelType2)) {
+ assertFalse(FileChannels.contentEquals((SeekableByteChannel) fc1, fc2, bufferSize));
+ assertFalse(FileChannels.contentEquals((SeekableByteChannel) reset(fc2), reset(fc1), bufferSize));
+ assertTrue(FileChannels.contentEquals((SeekableByteChannel) reset(fc1), reset(fc1), bufferSize));
+ }
+ // Make the LAST byte different.
+ byte[] bytes3 = bytes1.clone();
+ final int last = bytes3.length - 1;
+ bytes3[last] = reverse(bytes3[last]);
+ Files.write(bigFile3, bytes3);
+ try (FileChannel fc1 = open(bigFile1, fileChannelType1); FileChannel fc3 = open(bigFile3, fileChannelType2)) {
+ assertFalse(FileChannels.contentEquals((SeekableByteChannel) fc1, fc3, bufferSize));
+ assertFalse(FileChannels.contentEquals((SeekableByteChannel) reset(fc3), reset(fc1), bufferSize));
+ // Test just the last byte
+ fc1.position(last);
+ fc3.position(last);
+ assertFalse(FileChannels.contentEquals((SeekableByteChannel) fc1, fc3, bufferSize));
+ }
+ // Make the LAST byte equal.
+ bytes3 = bytes1.clone();
+ Files.write(bigFile3, bytes3);
+ try (FileChannel fc1 = open(bigFile1, fileChannelType1); FileChannel fc3 = open(bigFile3, fileChannelType2)) {
+ // Test just the last byte
+ fc1.position(last);
+ fc3.position(last);
+ assertTrue(FileChannels.contentEquals((SeekableByteChannel) fc1, fc3, bufferSize));
+ }
+ // Make a byte in the middle different
+ bytes3 = bytes1.clone();
+ final int middle = bytes3.length / 2;
+ bytes3[middle] = reverse(bytes3[middle]);
+ Files.write(bigFile3, bytes3);
+ try (FileChannel fc1 = open(bigFile1, fileChannelType1); FileChannel fc3 = open(bigFile3, fileChannelType2)) {
+ assertFalse(FileChannels.contentEquals((SeekableByteChannel) fc1, fc3, bufferSize));
+ assertFalse(FileChannels.contentEquals((SeekableByteChannel) reset(fc3), reset(fc1), bufferSize));
+ }
+ } finally {
+ // Delete ASAP
+ Files.deleteIfExists(bigFile1);
+ Files.deleteIfExists(bigFile2);
+ Files.deleteIfExists(bigFile3);
+ }
+ }
}
(commons-io) 04/04: More FileChannels testing
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 46e99a439a6d67eadad60b351922d63c1892e71f
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Mon Mar 3 09:54:44 2025 -0500
More FileChannels testing
---
.../commons/io/channels/FileChannelsTest.java | 99 +++++++++++-----------
1 file changed, 51 insertions(+), 48 deletions(-)
diff --git a/src/test/java/org/apache/commons/io/channels/FileChannelsTest.java b/src/test/java/org/apache/commons/io/channels/FileChannelsTest.java
index a29fb4457..7ba6ee8bc 100644
--- a/src/test/java/org/apache/commons/io/channels/FileChannelsTest.java
+++ b/src/test/java/org/apache/commons/io/channels/FileChannelsTest.java
@@ -21,7 +21,6 @@
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
import java.io.File;
import java.io.FileInputStream;
@@ -36,8 +35,6 @@
import org.apache.commons.io.file.AbstractTempDirTest;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.MethodSource;
import org.junitpioneer.jupiter.cartesian.CartesianTest;
import org.junitpioneer.jupiter.cartesian.CartesianTest.Values;
@@ -53,41 +50,43 @@ enum FileChannelType {
private static final int SMALL_BUFFER_SIZE = 1024;
private static final String CONTENT = StringUtils.repeat("x", SMALL_BUFFER_SIZE);
- public static int[] getBufferSizes() {
- // 1 and 2 are unusual and slow edge cases, but edge cases nonetheless.
- return new int[] { 1, 2, IOUtils.DEFAULT_BUFFER_SIZE / 10, IOUtils.DEFAULT_BUFFER_SIZE, IOUtils.DEFAULT_BUFFER_SIZE * 10 };
+ @SuppressWarnings("resource") // Caller closes
+ private static FileChannel getChannel(final FileInputStream inNotEmpty, final FileChannelType fileChannelType) throws IOException {
+ return wrap(inNotEmpty.getChannel(), fileChannelType);
}
+ private static boolean isEmpty(final File empty) {
+ return empty.length() == 0;
+ }
+
+ @SuppressWarnings("resource") // Caller closes
private static FileChannel open(final Path path, final FileChannelType fileChannelType) throws IOException {
- final FileChannel fc = FileChannel.open(path);
- if (fileChannelType != null) {
- switch (fileChannelType) {
- case NON_BLOCKING:
- return new NonBlockingFileChannelProxy(fc);
- case STOCK:
- return fc;
- case PROXY:
- return new FileChannelProxy(fc);
- default:
- fail("Unexpected FileChannelType " + fileChannelType);
- }
- }
- return FileChannel.open(path);
+ return wrap(FileChannel.open(path), fileChannelType);
}
- private static byte reverse(final byte b) {
- return (byte) (~b & 0xff);
+ private static FileChannel reset(final FileChannel fc) throws IOException {
+ return fc.position(0);
}
- private boolean isEmpty(final File empty) {
- return empty.length() == 0;
+ private static byte reverse(final byte b) {
+ return (byte) (~b & 0xff);
}
- private FileChannel reset(final FileChannel fc) throws IOException {
- return fc.position(0);
+ private static FileChannel wrap(final FileChannel fc, final FileChannelType fileChannelType) throws IOException {
+ switch (fileChannelType) {
+ case NON_BLOCKING:
+ return new NonBlockingFileChannelProxy(fc);
+ case STOCK:
+ return fc;
+ case PROXY:
+ return new FileChannelProxy(fc);
+ default:
+ throw new UnsupportedOperationException("Unexpected FileChannelType " + fileChannelType);
+ }
}
- private void testContentEquals(final String content1, final String content2, final int bufferSize) throws IOException {
+ private void testContentEquals(final String content1, final String content2, final int bufferSize, final FileChannelType fileChannelType)
+ throws IOException {
assertTrue(FileChannels.contentEquals(null, null, bufferSize));
// Prepare test files with same size but different content
// (first 3 bytes are different, followed by a large amount of equal content)
@@ -99,34 +98,37 @@ private void testContentEquals(final String content1, final String content2, fin
assertNotEquals(FileUtils.checksumCRC32(file1), FileUtils.checksumCRC32(file2));
try (FileInputStream in1 = new FileInputStream(file1);
FileInputStream in2 = new FileInputStream(file2);
- FileChannel channel1 = in1.getChannel();
- FileChannel channel2 = in2.getChannel()) {
+ FileChannel channel1 = getChannel(in1, fileChannelType);
+ FileChannel channel2 = getChannel(in2, fileChannelType)) {
assertFalse(FileChannels.contentEquals(channel1, channel2, bufferSize));
}
try (FileInputStream in1 = new FileInputStream(file1);
FileInputStream in2 = new FileInputStream(file2);
- FileChannel channel1 = in1.getChannel();
- FileChannel channel2 = in2.getChannel()) {
+ FileChannel channel1 = getChannel(in1, fileChannelType);
+ FileChannel channel2 = getChannel(in2, fileChannelType)) {
assertTrue(FileChannels.contentEquals(channel1, channel1, bufferSize));
assertTrue(FileChannels.contentEquals(channel2, channel2, bufferSize));
}
}
- @ParameterizedTest()
- @MethodSource("getBufferSizes")
- public void testContentEqualsDifferentPostfix(final int bufferSize) throws IOException {
- testContentEquals(CONTENT + "ABC", CONTENT + "XYZ", bufferSize);
+ @CartesianTest()
+ public void testContentEqualsDifferentPostfix(
+ @Values(ints = { 1, 2, IOUtils.DEFAULT_BUFFER_SIZE / 10, IOUtils.DEFAULT_BUFFER_SIZE, IOUtils.DEFAULT_BUFFER_SIZE * 10 }) final int bufferSize,
+ @CartesianTest.Enum final FileChannelType fileChannelType) throws IOException {
+ testContentEquals(CONTENT + "ABC", CONTENT + "XYZ", bufferSize, fileChannelType);
}
- @ParameterizedTest()
- @MethodSource("getBufferSizes")
- public void testContentEqualsDifferentPrefix(final int bufferSize) throws IOException {
- testContentEquals("ABC" + CONTENT, "XYZ" + CONTENT, bufferSize);
+ @CartesianTest()
+ public void testContentEqualsDifferentPrefix(
+ @Values(ints = { 1, 2, IOUtils.DEFAULT_BUFFER_SIZE / 10, IOUtils.DEFAULT_BUFFER_SIZE, IOUtils.DEFAULT_BUFFER_SIZE * 10 }) final int bufferSize,
+ @CartesianTest.Enum final FileChannelType fileChannelType) throws IOException {
+ testContentEquals("ABC" + CONTENT, "XYZ" + CONTENT, bufferSize, fileChannelType);
}
- @ParameterizedTest()
- @MethodSource("getBufferSizes")
- public void testContentEqualsEmpty(final int bufferSize) throws IOException {
+ @CartesianTest()
+ public void testContentEqualsEmpty(
+ @Values(ints = { 1, 2, IOUtils.DEFAULT_BUFFER_SIZE / 10, IOUtils.DEFAULT_BUFFER_SIZE, IOUtils.DEFAULT_BUFFER_SIZE * 10 }) final int bufferSize,
+ @CartesianTest.Enum final FileChannelType fileChannelType) throws IOException {
assertTrue(FileChannels.contentEquals(null, null, bufferSize));
// setup fixtures
final File empty = new File(tempDirFile, "empty.txt");
@@ -139,8 +141,8 @@ public void testContentEqualsEmpty(final int bufferSize) throws IOException {
assertNotEquals(FileUtils.checksumCRC32(empty), FileUtils.checksumCRC32(notEmpty));
try (FileInputStream inEmpty = new FileInputStream(empty);
FileInputStream inNotEmpty = new FileInputStream(notEmpty);
- FileChannel channelEmpty = inEmpty.getChannel();
- FileChannel channelNotEmpty = inNotEmpty.getChannel()) {
+ FileChannel channelEmpty = getChannel(inEmpty, fileChannelType);
+ FileChannel channelNotEmpty = getChannel(inNotEmpty, fileChannelType)) {
assertFalse(FileChannels.contentEquals(channelEmpty, channelNotEmpty, bufferSize));
assertFalse(FileChannels.contentEquals(null, channelNotEmpty, bufferSize));
assertFalse(FileChannels.contentEquals(channelNotEmpty, null, bufferSize));
@@ -155,6 +157,7 @@ public void testContentEqualsEmpty(final int bufferSize) throws IOException {
public void testContentEqualsFileChannel(
@Values(ints = { 1, 2, IOUtils.DEFAULT_BUFFER_SIZE / 10, IOUtils.DEFAULT_BUFFER_SIZE, IOUtils.DEFAULT_BUFFER_SIZE * 10 }) final int bufferSize)
throws IOException {
+ final FileChannelType fileChannelType = FileChannelType.STOCK;
final Path bigFile1 = Files.createTempFile(getClass().getSimpleName(), "-1.bin");
final Path bigFile2 = Files.createTempFile(getClass().getSimpleName(), "-2.bin");
final Path bigFile3 = Files.createTempFile(getClass().getSimpleName(), "-3.bin");
@@ -170,7 +173,7 @@ public void testContentEqualsFileChannel(
bytes2[0] = 2;
Files.write(bigFile1, bytes1);
Files.write(bigFile2, bytes2);
- try (FileChannel fc1 = open(bigFile1, null); FileChannel fc2 = open(bigFile2, null)) {
+ try (FileChannel fc1 = open(bigFile1, fileChannelType); FileChannel fc2 = open(bigFile2, fileChannelType)) {
assertFalse(FileChannels.contentEquals(fc1, fc2, bufferSize));
assertFalse(FileChannels.contentEquals(reset(fc2), reset(fc1), bufferSize));
assertTrue(FileChannels.contentEquals(reset(fc1), reset(fc1), bufferSize));
@@ -180,7 +183,7 @@ public void testContentEqualsFileChannel(
final int last = bytes3.length - 1;
bytes3[last] = reverse(bytes3[last]);
Files.write(bigFile3, bytes3);
- try (FileChannel fc1 = open(bigFile1, null); FileChannel fc3 = open(bigFile3, null)) {
+ try (FileChannel fc1 = open(bigFile1, fileChannelType); FileChannel fc3 = open(bigFile3, fileChannelType)) {
assertFalse(FileChannels.contentEquals(fc1, fc3, bufferSize));
assertFalse(FileChannels.contentEquals(reset(fc3), reset(fc1), bufferSize));
// Test just the last byte
@@ -191,7 +194,7 @@ public void testContentEqualsFileChannel(
// Make the LAST byte equal.
bytes3 = bytes1.clone();
Files.write(bigFile3, bytes3);
- try (FileChannel fc1 = open(bigFile1, null); FileChannel fc3 = open(bigFile3, null)) {
+ try (FileChannel fc1 = open(bigFile1, fileChannelType); FileChannel fc3 = open(bigFile3, fileChannelType)) {
// Test just the last byte
fc1.position(last);
fc3.position(last);
@@ -202,7 +205,7 @@ public void testContentEqualsFileChannel(
final int middle = bytes3.length / 2;
bytes3[middle] = reverse(bytes3[middle]);
Files.write(bigFile3, bytes3);
- try (FileChannel fc1 = open(bigFile1, null); FileChannel fc3 = open(bigFile3, null)) {
+ try (FileChannel fc1 = open(bigFile1, fileChannelType); FileChannel fc3 = open(bigFile3, fileChannelType)) {
assertFalse(FileChannels.contentEquals(fc1, fc3, bufferSize));
assertFalse(FileChannels.contentEquals(reset(fc3), reset(fc1), bufferSize));
}
(commons-io) 01/04: Add Javadoc since tag
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 e7a7542658d016b30b7b0ef67ff8ef5b5b687230
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Mon Mar 3 07:56:21 2025 -0500
Add Javadoc since tag
---
src/main/java/org/apache/commons/io/channels/FileChannels.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/main/java/org/apache/commons/io/channels/FileChannels.java b/src/main/java/org/apache/commons/io/channels/FileChannels.java
index a67be7a85..75f34d1c4 100644
--- a/src/main/java/org/apache/commons/io/channels/FileChannels.java
+++ b/src/main/java/org/apache/commons/io/channels/FileChannels.java
@@ -59,6 +59,7 @@ public static boolean contentEquals(final FileChannel channel1, final FileChanne
* @param bufferCapacity The two internal buffer capacities, in bytes.
* @return true if the contents of both RandomAccessFiles are equal, false otherwise.
* @throws IOException if an I/O error occurs or the timeout is met.
+ * @since 2.19.0
*/
public static boolean contentEquals(final SeekableByteChannel channel1, final SeekableByteChannel channel2, final int bufferCapacity) throws IOException {
// Short-circuit test