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/06/26 18:27:57 UTC
(commons-io) branch master updated: Refactor test fixtures
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
The following commit(s) were added to refs/heads/master by this push:
new c525669fe Refactor test fixtures
c525669fe is described below
commit c525669fefff37ebb7869a0730e83876958cc4e6
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Jun 26 14:27:46 2025 -0400
Refactor test fixtures
---
.../apache/commons/io/input/CharSequenceInputStreamTest.java | 12 ++----------
.../org/apache/commons/io/input/ReaderInputStreamTest.java | 11 ++---------
.../org/apache/commons/io/output/WriterOutputStreamTest.java | 11 ++---------
3 files changed, 6 insertions(+), 28 deletions(-)
diff --git a/src/test/java/org/apache/commons/io/input/CharSequenceInputStreamTest.java b/src/test/java/org/apache/commons/io/input/CharSequenceInputStreamTest.java
index a4491613c..63586df33 100644
--- a/src/test/java/org/apache/commons/io/input/CharSequenceInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/CharSequenceInputStreamTest.java
@@ -39,6 +39,7 @@
import org.apache.commons.io.CharsetsTest;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
@@ -48,17 +49,8 @@ class CharSequenceInputStreamTest {
private static final String UTF_16 = StandardCharsets.UTF_16.name();
private static final String UTF_8 = StandardCharsets.UTF_8.name();
private static final String ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- private static final String LARGE_TEST_STRING;
-
private static final String TEST_STRING = "\u00e0 peine arriv\u00e9s nous entr\u00e2mes dans sa chambre";
-
- static {
- final StringBuilder buffer = new StringBuilder();
- for (int i = 0; i < 100; i++) {
- buffer.append(TEST_STRING);
- }
- LARGE_TEST_STRING = buffer.toString();
- }
+ private static final String LARGE_TEST_STRING = StringUtils.repeat(TEST_STRING, 100);
private final Random random = new Random();
diff --git a/src/test/java/org/apache/commons/io/input/ReaderInputStreamTest.java b/src/test/java/org/apache/commons/io/input/ReaderInputStreamTest.java
index 47ce1a7db..fc4f19330 100644
--- a/src/test/java/org/apache/commons/io/input/ReaderInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/ReaderInputStreamTest.java
@@ -39,6 +39,7 @@
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.params.ParameterizedTest;
@@ -52,15 +53,7 @@ class ReaderInputStreamTest {
private static final String UTF_16 = StandardCharsets.UTF_16.name();
private static final String UTF_8 = StandardCharsets.UTF_8.name();
private static final String TEST_STRING = "\u00e0 peine arriv\u00e9s nous entr\u00e2mes dans sa chambre";
- private static final String LARGE_TEST_STRING;
-
- static {
- final StringBuilder buffer = new StringBuilder();
- for (int i = 0; i < 100; i++) {
- buffer.append(TEST_STRING);
- }
- LARGE_TEST_STRING = buffer.toString();
- }
+ private static final String LARGE_TEST_STRING = StringUtils.repeat(TEST_STRING, 100);
static Stream<Arguments> charsetData() {
// @formatter:off
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 d2e94c3fb..ffa213ffd 100644
--- a/src/test/java/org/apache/commons/io/output/WriterOutputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/output/WriterOutputStreamTest.java
@@ -29,6 +29,7 @@
import org.apache.commons.io.Charsets;
import org.apache.commons.io.charset.CharsetDecoders;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemProperties;
import org.junit.jupiter.api.Test;
@@ -42,15 +43,7 @@ class WriterOutputStreamTest {
private static final String UTF_16 = StandardCharsets.UTF_16.name();
private static final String UTF_8 = StandardCharsets.UTF_8.name();
private static final String TEST_STRING = "\u00e0 peine arriv\u00e9s nous entr\u00e2mes dans sa chambre";
- private static final String LARGE_TEST_STRING;
-
- static {
- final StringBuilder buffer = new StringBuilder();
- for (int i = 0; i < 100; i++) {
- buffer.append(TEST_STRING);
- }
- LARGE_TEST_STRING = buffer.toString();
- }
+ private static final String LARGE_TEST_STRING = StringUtils.repeat(TEST_STRING, 100);
private final Random random = new Random();