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-validator.git
The following commit(s) were added to refs/heads/master by this push:
new bd4a0aad Use JUnit Pioneer to fix CalendarValidatorTest
bd4a0aad is described below
commit bd4a0aadebb03999eec5fc5bff971cb98e6558b9
Author: Gary D. Gregory <[email protected]>
AuthorDate: Thu Dec 26 09:45:49 2024 -0500
Use JUnit Pioneer to fix CalendarValidatorTest
- Update other tests in the class to use JUnit Pioneer
- Local build OK
---
pom.xml | 14 +++++---------
.../validator/routines/CalendarValidatorTest.java | 18 ++++++------------
2 files changed, 11 insertions(+), 21 deletions(-)
diff --git a/pom.xml b/pom.xml
index a569ea75..fc3abf2d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -164,13 +164,11 @@
</build>
<dependencies>
-
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.4</version>
</dependency>
-
<dependency>
<groupId>commons-digester</groupId>
<artifactId>commons-digester</artifactId>
@@ -187,19 +185,16 @@
</exclusion>
</exclusions>
</dependency>
-
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.3.4</version>
</dependency>
-
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.2</version>
</dependency>
-
<!-- Needed for IBANValidatorTest -->
<dependency>
<groupId>org.apache.commons</groupId>
@@ -207,13 +202,16 @@
<version>1.12.0</version>
<scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
-
+ <dependency>
+ <groupId>org.junit-pioneer</groupId>
+ <artifactId>junit-pioneer</artifactId>
+ <version>2.3.0</version>
+ </dependency>
<dependency>
<!-- For testing DomainValidatorStartup -->
<groupId>org.bitstrings.test</groupId>
@@ -221,14 +219,12 @@
<version>1.2.2</version>
<scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.17.0</version>
<scope>test</scope>
</dependency>
-
</dependencies>
<reporting>
diff --git
a/src/test/java/org/apache/commons/validator/routines/CalendarValidatorTest.java
b/src/test/java/org/apache/commons/validator/routines/CalendarValidatorTest.java
index 85ba54bc..7842673d 100644
---
a/src/test/java/org/apache/commons/validator/routines/CalendarValidatorTest.java
+++
b/src/test/java/org/apache/commons/validator/routines/CalendarValidatorTest.java
@@ -27,15 +27,15 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import java.text.DateFormat;
import java.text.Format;
import java.text.SimpleDateFormat;
-import java.time.Instant;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
-import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junitpioneer.jupiter.DefaultLocale;
+import org.junitpioneer.jupiter.DefaultTimeZone;
/**
* Test Case for CalendarValidator.
@@ -46,20 +46,13 @@ public class CalendarValidatorTest extends
AbstractCalendarValidatorTest {
private static final int TIME_12_03_45 = 120345;
private CalendarValidator calValidator;
- private Locale originalLocale;
@BeforeEach
protected void setUp() {
- originalLocale = Locale.getDefault();
calValidator = new CalendarValidator();
validator = calValidator;
}
- @AfterEach
- protected void tearDown() {
- Locale.setDefault(originalLocale);
- }
-
/**
* Test adjustToTimeZone() method
*/
@@ -112,8 +105,8 @@ public class CalendarValidatorTest extends
AbstractCalendarValidatorTest {
* Test CalendarValidator validate Methods
*/
@Test
+ @DefaultLocale(country = "US", language = "en")
public void testCalendarValidatorMethods() {
- Locale.setDefault(Locale.US);
final Locale locale = Locale.GERMAN;
final String pattern = "yyyy-MM-dd";
final String patternVal = "2005-12-31";
@@ -241,8 +234,8 @@ public class CalendarValidatorTest extends
AbstractCalendarValidatorTest {
* Test Date/Time style Validator (there isn't an implementation for this)
*/
@Test
+ @DefaultLocale(country = "UK", language = "en")
public void testDateTimeStyle() {
- Locale.setDefault(Locale.UK);
// Formats vary between JVMs, so create the test strings using the
current JVM
final DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT,
DateFormat.SHORT);
final Calendar cal = Calendar.getInstance();
@@ -271,8 +264,9 @@ public class CalendarValidatorTest extends
AbstractCalendarValidatorTest {
*/
@Override
@Test
+ @DefaultLocale(country = "UK", language = "en")
+ @DefaultTimeZone("GMT")
public void testFormat() {
- Locale.setDefault(Locale.UK);
// final Calendar cal20051231 = Calendar.getInstance(GMT);
// set as UTC milliseconds from the epoch
//
cal20051231.setTimeInMillis(Instant.parse("2005-12-31T01:15:00.00Z").toEpochMilli());