Skip to content

Commit

Permalink
Use JUnit Pioneer to fix CalendarValidatorTest
Browse files Browse the repository at this point in the history
- Update other tests in the class to use JUnit Pioneer
- Local build OK
  • Loading branch information
garydgregory committed Dec 26, 2024
1 parent 51de373 commit bd4a0aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 21 deletions.
14 changes: 5 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -187,48 +185,46 @@
</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>
<artifactId>commons-csv</artifactId>
<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>
<artifactId>junit-clptr</artifactId>
<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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
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.
Expand All @@ -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
*/
Expand Down Expand Up @@ -112,8 +105,8 @@ public void testAdjustToTimeZone() {
* 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";
Expand Down Expand Up @@ -241,8 +234,8 @@ public void testCompare() {
* 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();
Expand Down Expand Up @@ -271,8 +264,9 @@ protected Object processParsedValue(final Object value, final Format formatter)
*/
@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());
Expand Down

0 comments on commit bd4a0aa

Please sign in to comment.