11/******************************************************************************
22 * Cal - A command line calendar utility
3- *
3+ * <p>
44 * Copyright (c) 2019-2025 Michael Fross
5- *
5+ * <p>
66 * Permission is hereby granted, free of charge, to any person obtaining a copy
77 * of this software and associated documentation files (the "Software"), to deal
88 * in the Software without restriction, including without limitation the rights
99 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1010 * copies of the Software, and to permit persons to whom the Software is
1111 * furnished to do so, subject to the following conditions:
12- *
12+ * <p>
1313 * The above copyright notice and this permission notice shall be included in all
1414 * copies or substantial portions of the Software.
15- *
15+ * <p>
1616 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1717 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1818 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1919 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2020 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2121 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222 * SOFTWARE.
23- *
23+ * <p>
2424 ******************************************************************************/
2525package org .fross .cal ;
2626
2727import org .fross .library .Output ;
28+ import org .junit .jupiter .api .Assertions ;
2829import org .junit .jupiter .api .Test ;
2930
3031import java .util .Locale ;
@@ -68,27 +69,33 @@ class HolidaysTest {
6869//
6970// }
7071
71- // Test holiday list - US
72+ // Test holiday list - US 2023
7273 @ Test
7374 void holidayListTestUS () {
75+ Locale .setDefault (Locale .US );
76+ Output .println ("Current locale set to: " + Locale .getDefault ().getDisplayCountry ());
77+
7478 // ------------------------------------------------------------------------
7579 // For now, skip this test if the JVM does not report it's in the US
7680 // ------------------------------------------------------------------------
77- if (Locale .getDefault ().getDisplayCountry ().toString (). compareTo ("United States" ) != 0 ) {
81+ if (Locale .getDefault ().getDisplayCountry ().compareTo ("United States" ) != 0 ) {
7882 Output .println ("Current locale set to: '" + Locale .getDefault ().getDisplayCountry () + "' -- Skipping Test" );
7983 return ;
8084 }
8185
86+ // Clear the cache before the test
87+ CommandLineArgs .clearCache ();
88+
8289 Output .print ("Current locale set to: '" + Locale .getDefault ().getDisplayCountry () + "'" );
8390
8491 // Get the holiday list for the US in 2023
8592 TreeMap <String , String > holidayListUS = Holidays .getHolidays (2023 );
8693
8794 // There should be 12 holidays in 2023
88- assertEquals (14 , holidayListUS .size ());
95+ Assertions .assertNotNull (holidayListUS );
96+ assertEquals (10 , holidayListUS .size ());
8997
90- String [] correctValuesUS = {"2023-01-02" , "2023-01-16" , "2023-02-12" , "2023-02-20" , "2023-04-07" , "2023-05-08" , "2023-05-29" ,
91- "2023-06-19" , "2023-07-04" , "2023-09-04" , "2023-10-09" , "2023-11-10" , "2023-11-23" , "2023-12-25" };
98+ String [] correctValuesUS = {"2023-01-02" , "2023-01-16" , "2023-02-20" , "2023-05-29" , "2023-06-19" , "2023-07-04" , "2023-09-04" , "2023-11-10" , "2023-11-23" , "2023-12-25" };
9299
93100 // Loop through the results and verify the keys (dates)
94101 int i = 0 ;
@@ -102,37 +109,45 @@ void holidayListTestUS() {
102109 // Test US month holidays for April 2025
103110 @ Test
104111 void monthHolidayListTestUS () {
112+ Output .println ("Current locale set to: " + Locale .getDefault ().getDisplayCountry ());
113+
105114 // ------------------------------------------------------------------------
106- // For now , skip this test if the JVM does not report it's in the US
115+ // For this test , skip this test if the JVM does not report it's in the US
107116 // ------------------------------------------------------------------------
108117 if (Locale .getDefault ().getDisplayCountry ().toString ().compareTo ("United States" ) != 0 ) {
109118 Output .println ("Current locale set to: '" + Locale .getDefault ().getDisplayCountry () + "' -- Skipping Test" );
110119 return ;
111120 }
112121
113- StringBuilder sb = Holidays .queryHolidayListMonth (4 , 2025 );
114- assertEquals ("2025-04-18 | Good Friday" , sb .toString ().trim ());
122+ StringBuilder sb = Holidays .queryHolidayListMonth (12 , 2025 );
123+ assertEquals ("2025-12-25 | Christmas Day" , sb .toString ().trim ());
124+
125+ sb = Holidays .queryHolidayListMonth (7 , 2025 );
126+ assertEquals ("2025-07-04 | Independence Day" , sb .toString ().trim ());
115127
116128 }
117129
118- // // Test holiday list - CA
130+ // Test holiday list - CA
119131// @Test
120132// void holidayListTestCA() {
133+ // Output.println("\nExecuting holidayListTestCA()");
121134// // ------------------------------------------------------------------------
122135// // Set the default country to Canada
123136// // ------------------------------------------------------------------------
124137// Locale.setDefault(Locale.CANADA);
125138// Output.println("Current locale set to: " + Locale.getDefault().getDisplayCountry());
126139//
140+ // // Clear the cache before the test
141+ // CommandLineArgs.clearCache();
142+ //
127143// // Get the holiday list for the 2023 Canadian holidays
128144// TreeMap<String, String> holidayListCA = Holidays.getHolidays(2024);
129145//
130- // // There should be 19 holidays in 2023
131- // assertEquals(19, holidayListCA.size());
146+ // // There should be 8 holidays in 2024
147+ // Assertions.assertNotNull(holidayListCA);
148+ // assertEquals(8, holidayListCA.size());
132149//
133- // String[] correctValuesCA = { "2024-01-01", "2024-02-19", "2024-03-17", "2024-03-29", "2024-04-01", "2024-04-23", "2024-05-20", "2024-06-21",
134- // "2024-06-24", "2024-07-01", "2024-07-12", "2024-08-05", "2024-08-19", "2024-09-02", "2024-09-30", "2024-10-14", "2024-11-11", "2024-12-25",
135- // "2024-12-26" };
150+ // String[] correctValuesCA = { "2024-01-01", "2024-03-29", "2024-05-20", "2024-07-01", "2024-09-02", "2024-09-30", "2024-10-14", "2024-12-25" };
136151//
137152// // Loop through the results and verify the keys (dates)
138153// int i = 0;
0 commit comments