Skip to content

Commit

Permalink
Fix tests to work with JDK 17
Browse files Browse the repository at this point in the history
Fixes #674
  • Loading branch information
jodastephen committed Mar 5, 2023
1 parent b022729 commit f21869b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
9 changes: 5 additions & 4 deletions src/test/java/org/joda/time/TestDateMidnight_Properties.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

import java.util.Locale;

import junit.framework.TestCase;
import junit.framework.TestSuite;

import org.joda.time.chrono.CopticChronology;
import org.joda.time.chrono.LenientChronology;
import org.joda.time.chrono.StrictChronology;

import junit.framework.TestCase;
import junit.framework.TestSuite;

/**
* This class is a Junit unit test for DateTime.
*
Expand Down Expand Up @@ -235,7 +235,8 @@ public void testPropertyGetMonthOfYear() {
assertEquals(test.getChronology().months(), test.monthOfYear().getDurationField());
assertEquals(test.getChronology().years(), test.monthOfYear().getRangeDurationField());
assertEquals(9, test.monthOfYear().getMaximumTextLength(null));
assertEquals(3, test.monthOfYear().getMaximumShortTextLength(null));
int max = test.monthOfYear().getMaximumShortTextLength(null);
assertTrue(max == 3 || max == 4); // for JDK17+
test = new DateMidnight(2004, 7, 9);
assertEquals("juillet", test.monthOfYear().getAsText(Locale.FRENCH));
assertEquals("juil.", test.monthOfYear().getAsShortText(Locale.FRENCH));
Expand Down
9 changes: 5 additions & 4 deletions src/test/java/org/joda/time/TestDateTime_Properties.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

import java.util.Locale;

import junit.framework.TestCase;
import junit.framework.TestSuite;

import org.joda.time.chrono.CopticChronology;
import org.joda.time.chrono.LenientChronology;
import org.joda.time.chrono.StrictChronology;

import junit.framework.TestCase;
import junit.framework.TestSuite;

/**
* This class is a Junit unit test for DateTime.
*
Expand Down Expand Up @@ -358,7 +358,8 @@ public void testPropertyGetMonthOfYear() {
assertEquals(test.getChronology().months(), test.monthOfYear().getDurationField());
assertEquals(test.getChronology().years(), test.monthOfYear().getRangeDurationField());
assertEquals(9, test.monthOfYear().getMaximumTextLength(null));
assertEquals(3, test.monthOfYear().getMaximumShortTextLength(null));
int max = test.monthOfYear().getMaximumShortTextLength(null);
assertTrue(max == 3 || max == 4); // for JDK17+
test = new DateTime(2004, 7, 9, 0, 0, 0, 0);
assertEquals("juillet", test.monthOfYear().getAsText(Locale.FRENCH));
assertEquals("juillet", test.monthOfYear().getField().getAsText(7, Locale.FRENCH));
Expand Down
12 changes: 7 additions & 5 deletions src/test/java/org/joda/time/TestMonthDay_Properties.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

import java.util.Locale;

import junit.framework.TestCase;
import junit.framework.TestSuite;

import org.joda.time.chrono.CopticChronology;
import org.joda.time.chrono.LenientChronology;
import org.joda.time.chrono.StrictChronology;

import junit.framework.TestCase;
import junit.framework.TestSuite;

/**
* This class is a Junit unit test for MonthDay. Based on {@link TestYearMonth_Propeties}
*/
Expand Down Expand Up @@ -90,12 +90,14 @@ public void testPropertyGetMonthOfYear() {
assertEquals("9", test.monthOfYear().getAsString());
assertEquals("September", test.monthOfYear().getAsText());
assertEquals("septembre", test.monthOfYear().getAsText(Locale.FRENCH));
assertEquals("Sep", test.monthOfYear().getAsShortText());
String text = test.monthOfYear().getAsShortText();
assertTrue(text.equals("Sep") || text.equals("Sept"));
assertEquals("sept.", test.monthOfYear().getAsShortText(Locale.FRENCH));
assertEquals(test.getChronology().months(), test.monthOfYear().getDurationField());
// assertEquals(test.getChronology().days(), test.dayOfMonth().getRangeDurationField());
assertEquals(9, test.monthOfYear().getMaximumTextLength(null));
assertEquals(3, test.monthOfYear().getMaximumShortTextLength(null));
int max = test.monthOfYear().getMaximumShortTextLength(null);
assertTrue(max == 3 || max == 4); // for JDK17+
}

public void testPropertyGetMaxMinValuesMonthOfYear() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ public void testPropertyGetMonthOfYear() {
assertEquals(test.getChronology().months(), test.monthOfYear().getDurationField());
assertEquals(test.getChronology().years(), test.monthOfYear().getRangeDurationField());
assertEquals(9, test.monthOfYear().getMaximumTextLength(null));
assertEquals(3, test.monthOfYear().getMaximumShortTextLength(null));
int max = test.monthOfYear().getMaximumShortTextLength(null);
assertTrue(max == 3 || max == 4); // for JDK17+
test = new MutableDateTime(2004, 7, 9, 0, 0, 0, 0);
assertEquals("juillet", test.monthOfYear().getAsText(Locale.FRENCH));
assertEquals("juil.", test.monthOfYear().getAsShortText(Locale.FRENCH));
Expand Down

0 comments on commit f21869b

Please sign in to comment.