This is an automated email from the ASF dual-hosted git repository.
garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git
The following commit(s) were added to refs/heads/master by this push:
new e6b8bbd39 Add parallel test support for some methods (#1698)
e6b8bbd39 is described below
commit e6b8bbd39505694012d869fa2107ef068b88d800
Author: Gary Gregory <[email protected]>
AuthorDate: Tue Jun 9 16:54:04 2026 -0400
Add parallel test support for some methods (#1698)
---
.../org/apache/commons/lang3/LocaleUtilsTest.java | 3 +++
.../commons/lang3/StringUtilsContainsTest.java | 3 ---
.../commons/lang3/time/FastDateFormatTest.java | 18 ++++++++++--------
.../commons/lang3/time/FastDateParserTest.java | 21 ++++++++-------------
.../lang3/time/FastDateParser_MoreOrLessTest.java | 12 ++++++++++++
.../time/FastDateParser_TimeZoneStrategyTest.java | 1 +
.../org/apache/commons/lang3/time/WeekYearTest.java | 6 ++++++
7 files changed, 40 insertions(+), 24 deletions(-)
diff --git a/src/test/java/org/apache/commons/lang3/LocaleUtilsTest.java
b/src/test/java/org/apache/commons/lang3/LocaleUtilsTest.java
index 4adadb4cd..a1ab5a010 100644
--- a/src/test/java/org/apache/commons/lang3/LocaleUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/LocaleUtilsTest.java
@@ -42,6 +42,7 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.junitpioneer.jupiter.DefaultLocale;
+import org.junitpioneer.jupiter.ReadsDefaultLocale;
/**
* Tests for {@link LocaleUtils}.
@@ -194,6 +195,7 @@ private static void assertValidToLocale(
}
@BeforeEach
+ @ReadsDefaultLocale
public void setUp() {
// Testing #LANG-304. Must be called before availableLocaleSet is
called.
LocaleUtils.isAvailableLocale(Locale.getDefault());
@@ -540,6 +542,7 @@ void testToLocale_3Part() {
* Test toLocale(Locale) method.
*/
@Test
+ @ReadsDefaultLocale
void testToLocale_Locale_defaults() {
assertNull(LocaleUtils.toLocale((String) null));
assertEquals(Locale.getDefault(), LocaleUtils.toLocale((Locale) null));
diff --git
a/src/test/java/org/apache/commons/lang3/StringUtilsContainsTest.java
b/src/test/java/org/apache/commons/lang3/StringUtilsContainsTest.java
index 61579a921..54eab7a8f 100644
--- a/src/test/java/org/apache/commons/lang3/StringUtilsContainsTest.java
+++ b/src/test/java/org/apache/commons/lang3/StringUtilsContainsTest.java
@@ -238,11 +238,8 @@ void testContainsAnyIgnoreCase_StringStringArray() {
@WritesDefaultLocale
void testContainsIgnoreCase_LocaleIndependence() {
final Locale[] locales = { Locale.ENGLISH, new Locale("tr"),
Locale.getDefault() };
-
final String[][] tdata = { { "i", "I" }, { "I", "i" }, { "\u03C2",
"\u03C3" }, { "\u03A3", "\u03C2" }, { "\u03A3", "\u03C3" }, };
-
final String[][] fdata = { { "\u00DF", "SS" }, };
-
for (final Locale testLocale : locales) {
Locale.setDefault(testLocale);
for (int j = 0; j < tdata.length; j++) {
diff --git
a/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java
b/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java
index 15895c363..4023b8e30 100644
--- a/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java
@@ -46,6 +46,8 @@
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.DefaultLocale;
import org.junitpioneer.jupiter.DefaultTimeZone;
+import org.junitpioneer.jupiter.ReadsDefaultLocale;
+import org.junitpioneer.jupiter.ReadsDefaultTimeZone;
/**
* Tests {@link FastDateFormat}.
@@ -218,14 +220,14 @@ void test_getInstance_String_TimeZone_Locale() {
}
@Test
+ @ReadsDefaultLocale
+ @ReadsDefaultTimeZone
void testCheckDefaults() {
final FastDateFormat format = FastDateFormat.getInstance();
final FastDateFormat medium =
FastDateFormat.getDateTimeInstance(FastDateFormat.SHORT, FastDateFormat.SHORT);
assertEquals(medium, format);
-
final SimpleDateFormat sdf = new SimpleDateFormat();
assertEquals(sdf.toPattern(), format.getPattern());
-
assertEquals(Locale.getDefault(), format.getLocale());
assertEquals(TimeZone.getDefault(), format.getTimeZone());
}
@@ -246,13 +248,13 @@ void testCheckDifferingStyles() {
}
@Test
+ @ReadsDefaultLocale
+ @ReadsDefaultTimeZone
void testDateDefaults() {
assertEquals(FastDateFormat.getDateInstance(FastDateFormat.LONG,
Locale.CANADA),
FastDateFormat.getDateInstance(FastDateFormat.LONG,
TimeZone.getDefault(), Locale.CANADA));
-
assertEquals(FastDateFormat.getDateInstance(FastDateFormat.LONG,
TimeZones.getTimeZone("America/New_York")),
FastDateFormat.getDateInstance(FastDateFormat.LONG,
TimeZones.getTimeZone("America/New_York"), Locale.getDefault()));
-
assertEquals(FastDateFormat.getDateInstance(FastDateFormat.LONG),
FastDateFormat.getDateInstance(FastDateFormat.LONG,
TimeZone.getDefault(), Locale.getDefault()));
}
@@ -424,25 +426,25 @@ void testStandaloneShortMonthForm() {
}
@Test
+ @ReadsDefaultLocale
+ @ReadsDefaultTimeZone
void testTimeDateDefaults() {
assertEquals(FastDateFormat.getDateTimeInstance(FastDateFormat.LONG,
FastDateFormat.MEDIUM, Locale.CANADA),
FastDateFormat.getDateTimeInstance(FastDateFormat.LONG,
FastDateFormat.MEDIUM, TimeZone.getDefault(), Locale.CANADA));
-
assertEquals(FastDateFormat.getDateTimeInstance(FastDateFormat.LONG,
FastDateFormat.MEDIUM, TimeZones.getTimeZone("America/New_York")),
FastDateFormat.getDateTimeInstance(FastDateFormat.LONG,
FastDateFormat.MEDIUM, TimeZones.getTimeZone("America/New_York"),
Locale.getDefault()));
-
assertEquals(FastDateFormat.getDateTimeInstance(FastDateFormat.LONG,
FastDateFormat.MEDIUM),
FastDateFormat.getDateTimeInstance(FastDateFormat.LONG,
FastDateFormat.MEDIUM, TimeZone.getDefault(), Locale.getDefault()));
}
@Test
+ @ReadsDefaultLocale
+ @ReadsDefaultTimeZone
void testTimeDefaults() {
assertEquals(FastDateFormat.getTimeInstance(FastDateFormat.LONG,
Locale.CANADA),
FastDateFormat.getTimeInstance(FastDateFormat.LONG,
TimeZone.getDefault(), Locale.CANADA));
-
assertEquals(FastDateFormat.getTimeInstance(FastDateFormat.LONG,
TimeZones.getTimeZone("America/New_York")),
FastDateFormat.getTimeInstance(FastDateFormat.LONG,
TimeZones.getTimeZone("America/New_York"), Locale.getDefault()));
-
assertEquals(FastDateFormat.getTimeInstance(FastDateFormat.LONG),
FastDateFormat.getTimeInstance(FastDateFormat.LONG,
TimeZone.getDefault(), Locale.getDefault()));
}
diff --git
a/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java
b/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java
index 04c223ed3..4e07086a6 100644
--- a/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java
@@ -253,22 +253,17 @@ void test_Equality_Hash(final TriFunction<String,
TimeZone, Locale, DateParser>
}
@Test
+ @ReadsDefaultLocale
void test1806() throws ParseException {
final String formatStub = "yyyy-MM-dd'T'HH:mm:ss.SSS";
final String dateStub = "2001-02-04T12:08:56.235";
-
for (final Expected1806 trial : Expected1806.values()) {
final Calendar cal = initializeCalendar(trial.zone);
-
final String message = trial.zone.getDisplayName() + ";";
-
DateParser parser = getInstance(formatStub + "X", trial.zone);
- assertEquals(cal.getTime().getTime(), parser.parse(dateStub +
trial.one).getTime() - trial.offset,
- message + trial.one);
-
+ assertEquals(cal.getTime().getTime(), parser.parse(dateStub +
trial.one).getTime() - trial.offset, message + trial.one);
parser = getInstance(formatStub + "XX", trial.zone);
assertEquals(cal.getTime(), parser.parse(dateStub + trial.two),
message + trial.two);
-
parser = getInstance(formatStub + "XXX", trial.zone);
assertEquals(cal.getTime(), parser.parse(dateStub + trial.three),
message + trial.three);
}
@@ -442,13 +437,12 @@ void testLang303() throws ParseException {
}
@Test
+ @ReadsDefaultLocale
void testLang538() throws ParseException {
final DateParser parser = getInstance("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",
TimeZones.GMT);
-
final Calendar cal =
Calendar.getInstance(TimeZones.getTimeZone("GMT-8"));
cal.clear();
cal.set(2009, Calendar.OCTOBER, 16, 8, 42, 16);
-
assertEquals(cal.getTime(), parser.parse("2009-10-16T16:42:16.000Z"));
}
@@ -671,6 +665,8 @@ private void testSdfAndFdp(final TriFunction<String,
TimeZone, Locale, DateParse
* @throws ParseException so we don't have to catch it
*/
@Test
+ @ReadsDefaultLocale
+ @ReadsDefaultTimeZone
void testShortDateStyleWithLocales() throws ParseException {
DateParser fdf = getDateInstance(FastDateFormat.SHORT, Locale.US);
final Calendar cal = Calendar.getInstance();
@@ -704,15 +700,14 @@ void testSpecialCharacters(final TriFunction<String,
TimeZone, Locale, DateParse
}
@Test
+ @ReadsDefaultLocale
void testTimeZoneMatches() {
- final DateParser parser = getInstance(yMdHmsSZ, REYKJAVIK);
- assertEquals(REYKJAVIK, parser.getTimeZone());
+ assertEquals(REYKJAVIK, getInstance(yMdHmsSZ,
REYKJAVIK).getTimeZone());
}
@Test
void testToStringContainsName() {
- final DateParser parser = getInstance(YMD_SLASH);
- assertTrue(parser.toString().startsWith("FastDate"));
+ assertTrue(getInstance(YMD_SLASH).toString().startsWith("FastDate"));
}
// we cannot use historic dates to test time zone parsing, some time zones
have second offsets
diff --git
a/src/test/java/org/apache/commons/lang3/time/FastDateParser_MoreOrLessTest.java
b/src/test/java/org/apache/commons/lang3/time/FastDateParser_MoreOrLessTest.java
index 77eae646a..1754f04d4 100644
---
a/src/test/java/org/apache/commons/lang3/time/FastDateParser_MoreOrLessTest.java
+++
b/src/test/java/org/apache/commons/lang3/time/FastDateParser_MoreOrLessTest.java
@@ -28,12 +28,16 @@
import org.apache.commons.lang3.AbstractLangTest;
import org.junit.jupiter.api.Test;
+import org.junitpioneer.jupiter.ReadsDefaultLocale;
+import org.junitpioneer.jupiter.ReadsDefaultTimeZone;
class FastDateParser_MoreOrLessTest extends AbstractLangTest {
private static final TimeZone NEW_YORK =
TimeZones.getTimeZone("America/New_York");
@Test
+ @ReadsDefaultLocale
+ @ReadsDefaultTimeZone
void testInputHasLessCharacters() {
final FastDateParser parser = new FastDateParser("MM/dd/yyy",
TimeZone.getDefault(), Locale.getDefault());
final ParsePosition parsePosition = new ParsePosition(0);
@@ -42,6 +46,8 @@ void testInputHasLessCharacters() {
}
@Test
+ @ReadsDefaultLocale
+ @ReadsDefaultTimeZone
void testInputHasMoreCharacters() {
final FastDateParser parser = new FastDateParser("MM/dd",
TimeZone.getDefault(), Locale.getDefault());
final ParsePosition parsePosition = new ParsePosition(0);
@@ -55,6 +61,8 @@ void testInputHasMoreCharacters() {
}
@Test
+ @ReadsDefaultLocale
+ @ReadsDefaultTimeZone
void testInputHasPrecedingCharacters() {
final FastDateParser parser = new FastDateParser("MM/dd",
TimeZone.getDefault(), Locale.getDefault());
final ParsePosition parsePosition = new ParsePosition(0);
@@ -65,6 +73,8 @@ void testInputHasPrecedingCharacters() {
}
@Test
+ @ReadsDefaultLocale
+ @ReadsDefaultTimeZone
void testInputHasWhitespace() {
final FastDateParser parser = new FastDateParser("M/d/y",
TimeZone.getDefault(), Locale.getDefault());
//SimpleDateFormat parser = new SimpleDateFormat("M/d/y");
@@ -80,6 +90,8 @@ void testInputHasWhitespace() {
}
@Test
+ @ReadsDefaultLocale
+ @ReadsDefaultTimeZone
void testInputHasWrongCharacters() {
final FastDateParser parser = new FastDateParser("MM-dd-yyy",
TimeZone.getDefault(), Locale.getDefault());
final ParsePosition parsePosition = new ParsePosition(0);
diff --git
a/src/test/java/org/apache/commons/lang3/time/FastDateParser_TimeZoneStrategyTest.java
b/src/test/java/org/apache/commons/lang3/time/FastDateParser_TimeZoneStrategyTest.java
index 3a73dea64..7f278f0e7 100644
---
a/src/test/java/org/apache/commons/lang3/time/FastDateParser_TimeZoneStrategyTest.java
+++
b/src/test/java/org/apache/commons/lang3/time/FastDateParser_TimeZoneStrategyTest.java
@@ -95,6 +95,7 @@ private String[][] getZoneStringsSorted(final Locale locale) {
*/
@ParameterizedTest
@ValueSource(strings = { "ACT", "CST" })
+ @ReadsDefaultLocale
void testJava25DeprecatedZoneId(final String shortId) throws
ParseException {
final FastDateParser parser = new FastDateParser("dd.MM.yyyy HH:mm:ss
z", TimeZone.getTimeZone(shortId), Locale.getDefault());
final Date date1 = parser.parse("26.10.2014 02:00:00 " + shortId);
diff --git a/src/test/java/org/apache/commons/lang3/time/WeekYearTest.java
b/src/test/java/org/apache/commons/lang3/time/WeekYearTest.java
index 1cd47118c..42b5e0b11 100644
--- a/src/test/java/org/apache/commons/lang3/time/WeekYearTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/WeekYearTest.java
@@ -29,6 +29,8 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
+import org.junitpioneer.jupiter.ReadsDefaultLocale;
+import org.junitpioneer.jupiter.ReadsDefaultTimeZone;
class WeekYearTest extends AbstractLangTest {
@@ -57,6 +59,8 @@ public static Stream<Arguments> data() {
@ParameterizedTest
@MethodSource("data")
+ @ReadsDefaultLocale
+ @ReadsDefaultTimeZone
void testParser(final Calendar vulgar, final String isoForm) {
final DateParser parser = new FastDateParser("YYYY-'W'ww-u",
TimeZone.getDefault(), Locale.getDefault());
@@ -71,6 +75,8 @@ void testParser(final Calendar vulgar, final String isoForm) {
@ParameterizedTest
@MethodSource("data")
+ @ReadsDefaultLocale
+ @ReadsDefaultTimeZone
void testPrinter(final Calendar vulgar, final String isoForm) {
final FastDatePrinter printer = new FastDatePrinter("YYYY-'W'ww-u",
TimeZone.getDefault(), Locale.getDefault());