001    /*
002     *  Copyright 2001-2010 Stephen Colebourne
003     *
004     *  Licensed under the Apache License, Version 2.0 (the "License");
005     *  you may not use this file except in compliance with the License.
006     *  You may obtain a copy of the License at
007     *
008     *      http://www.apache.org/licenses/LICENSE-2.0
009     *
010     *  Unless required by applicable law or agreed to in writing, software
011     *  distributed under the License is distributed on an "AS IS" BASIS,
012     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     *  See the License for the specific language governing permissions and
014     *  limitations under the License.
015     */
016    package org.joda.time;
017    
018    import java.util.Locale;
019    
020    import junit.framework.TestCase;
021    import junit.framework.TestSuite;
022    
023    import org.joda.time.chrono.CopticChronology;
024    import org.joda.time.chrono.LenientChronology;
025    import org.joda.time.chrono.StrictChronology;
026    
027    /**
028     * This class is a Junit unit test for YearMonthDay.
029     *
030     * @author Stephen Colebourne
031     */
032    public class TestYearMonthDay_Properties extends TestCase {
033    
034        private static final DateTimeZone PARIS = DateTimeZone.forID("Europe/Paris");
035        private static final Chronology COPTIC_PARIS = CopticChronology.getInstance(PARIS);
036    
037        private long TEST_TIME_NOW =
038                (31L + 28L + 31L + 30L + 31L + 9L -1L) * DateTimeConstants.MILLIS_PER_DAY;
039                
040        private long TEST_TIME1 =
041            (31L + 28L + 31L + 6L -1L) * DateTimeConstants.MILLIS_PER_DAY
042            + 12L * DateTimeConstants.MILLIS_PER_HOUR
043            + 24L * DateTimeConstants.MILLIS_PER_MINUTE;
044            
045        private long TEST_TIME2 =
046            (365L + 31L + 28L + 31L + 30L + 7L -1L) * DateTimeConstants.MILLIS_PER_DAY
047            + 14L * DateTimeConstants.MILLIS_PER_HOUR
048            + 28L * DateTimeConstants.MILLIS_PER_MINUTE;
049            
050        private DateTimeZone zone = null;
051    
052        private Locale systemDefaultLocale = null;
053    
054        public static void main(String[] args) {
055            junit.textui.TestRunner.run(suite());
056        }
057    
058        public static TestSuite suite() {
059            return new TestSuite(TestYearMonthDay_Properties.class);
060        }
061    
062        public TestYearMonthDay_Properties(String name) {
063            super(name);
064        }
065    
066        protected void setUp() throws Exception {
067            DateTimeUtils.setCurrentMillisFixed(TEST_TIME_NOW);
068            zone = DateTimeZone.getDefault();
069            DateTimeZone.setDefault(DateTimeZone.UTC);
070            systemDefaultLocale = Locale.getDefault();
071            Locale.setDefault(Locale.ENGLISH);
072        }
073    
074        protected void tearDown() throws Exception {
075            DateTimeUtils.setCurrentMillisSystem();
076            DateTimeZone.setDefault(zone);
077            zone = null;
078            Locale.setDefault(systemDefaultLocale);
079            systemDefaultLocale = null;
080        }
081    
082        //-----------------------------------------------------------------------
083        public void testPropertyGetYear() {
084            YearMonthDay test = new YearMonthDay(1972, 6, 9);
085            assertSame(test.getChronology().year(), test.year().getField());
086            assertEquals("year", test.year().getName());
087            assertEquals("Property[year]", test.year().toString());
088            assertSame(test, test.year().getReadablePartial());
089            assertSame(test, test.year().getYearMonthDay());
090            assertEquals(1972, test.year().get());
091            assertEquals("1972", test.year().getAsString());
092            assertEquals("1972", test.year().getAsText());
093            assertEquals("1972", test.year().getAsText(Locale.FRENCH));
094            assertEquals("1972", test.year().getAsShortText());
095            assertEquals("1972", test.year().getAsShortText(Locale.FRENCH));
096            assertEquals(test.getChronology().years(), test.year().getDurationField());
097            assertEquals(null, test.year().getRangeDurationField());
098            assertEquals(9, test.year().getMaximumTextLength(null));
099            assertEquals(9, test.year().getMaximumShortTextLength(null));
100        }
101    
102        public void testPropertyGetMaxMinValuesYear() {
103            YearMonthDay test = new YearMonthDay(1972, 6, 9);
104            assertEquals(-292275054, test.year().getMinimumValue());
105            assertEquals(-292275054, test.year().getMinimumValueOverall());
106            assertEquals(292278993, test.year().getMaximumValue());
107            assertEquals(292278993, test.year().getMaximumValueOverall());
108        }
109    
110        public void testPropertyAddYear() {
111            YearMonthDay test = new YearMonthDay(1972, 6, 9);
112            YearMonthDay copy = test.year().addToCopy(9);
113            check(test, 1972, 6, 9);
114            check(copy, 1981, 6, 9);
115            
116            copy = test.year().addToCopy(0);
117            check(copy, 1972, 6, 9);
118            
119            copy = test.year().addToCopy(292277023 - 1972);
120            check(copy, 292277023, 6, 9);
121            
122            try {
123                test.year().addToCopy(292278993 - 1972 + 1);
124                fail();
125            } catch (IllegalArgumentException ex) {}
126            check(test, 1972, 6, 9);
127            
128            copy = test.year().addToCopy(-1972);
129            check(copy, 0, 6, 9);
130            
131            copy = test.year().addToCopy(-1973);
132            check(copy, -1, 6, 9);
133            
134            try {
135                test.year().addToCopy(-292275054 - 1972 - 1);
136                fail();
137            } catch (IllegalArgumentException ex) {}
138            check(test, 1972, 6, 9);
139        }
140    
141        public void testPropertyAddWrapFieldYear() {
142            YearMonthDay test = new YearMonthDay(1972, 6, 9);
143            YearMonthDay copy = test.year().addWrapFieldToCopy(9);
144            check(test, 1972, 6, 9);
145            check(copy, 1981, 6, 9);
146            
147            copy = test.year().addWrapFieldToCopy(0);
148            check(copy, 1972, 6, 9);
149            
150            copy = test.year().addWrapFieldToCopy(292278993 - 1972 + 1);
151            check(copy, -292275054, 6, 9);
152            
153            copy = test.year().addWrapFieldToCopy(-292275054 - 1972 - 1);
154            check(copy, 292278993, 6, 9);
155        }
156    
157        public void testPropertySetYear() {
158            YearMonthDay test = new YearMonthDay(1972, 6, 9);
159            YearMonthDay copy = test.year().setCopy(12);
160            check(test, 1972, 6, 9);
161            check(copy, 12, 6, 9);
162        }
163    
164        public void testPropertySetTextYear() {
165            YearMonthDay test = new YearMonthDay(1972, 6, 9);
166            YearMonthDay copy = test.year().setCopy("12");
167            check(test, 1972, 6, 9);
168            check(copy, 12, 6, 9);
169        }
170    
171        public void testPropertyCompareToYear() {
172            YearMonthDay test1 = new YearMonthDay(TEST_TIME1);
173            YearMonthDay test2 = new YearMonthDay(TEST_TIME2);
174            assertEquals(true, test1.year().compareTo(test2) < 0);
175            assertEquals(true, test2.year().compareTo(test1) > 0);
176            assertEquals(true, test1.year().compareTo(test1) == 0);
177            try {
178                test1.year().compareTo((ReadablePartial) null);
179                fail();
180            } catch (IllegalArgumentException ex) {}
181            
182            DateTime dt1 = new DateTime(TEST_TIME1);
183            DateTime dt2 = new DateTime(TEST_TIME2);
184            assertEquals(true, test1.year().compareTo(dt2) < 0);
185            assertEquals(true, test2.year().compareTo(dt1) > 0);
186            assertEquals(true, test1.year().compareTo(dt1) == 0);
187            try {
188                test1.year().compareTo((ReadableInstant) null);
189                fail();
190            } catch (IllegalArgumentException ex) {}
191        }
192    
193        //-----------------------------------------------------------------------
194        public void testPropertyGetMonth() {
195            YearMonthDay test = new YearMonthDay(1972, 6, 9);
196            assertSame(test.getChronology().monthOfYear(), test.monthOfYear().getField());
197            assertEquals("monthOfYear", test.monthOfYear().getName());
198            assertEquals("Property[monthOfYear]", test.monthOfYear().toString());
199            assertSame(test, test.monthOfYear().getReadablePartial());
200            assertSame(test, test.monthOfYear().getYearMonthDay());
201            assertEquals(6, test.monthOfYear().get());
202            assertEquals("6", test.monthOfYear().getAsString());
203            assertEquals("June", test.monthOfYear().getAsText());
204            assertEquals("juin", test.monthOfYear().getAsText(Locale.FRENCH));
205            assertEquals("Jun", test.monthOfYear().getAsShortText());
206            assertEquals("juin", test.monthOfYear().getAsShortText(Locale.FRENCH));
207            assertEquals(test.getChronology().months(), test.monthOfYear().getDurationField());
208            assertEquals(test.getChronology().years(), test.monthOfYear().getRangeDurationField());
209            assertEquals(9, test.monthOfYear().getMaximumTextLength(null));
210            assertEquals(3, test.monthOfYear().getMaximumShortTextLength(null));
211            test = new YearMonthDay(1972, 7, 9);
212            assertEquals("juillet", test.monthOfYear().getAsText(Locale.FRENCH));
213            assertEquals("juil.", test.monthOfYear().getAsShortText(Locale.FRENCH));
214        }
215    
216        public void testPropertyGetMaxMinValuesMonth() {
217            YearMonthDay test = new YearMonthDay(1972, 6, 9);
218            assertEquals(1, test.monthOfYear().getMinimumValue());
219            assertEquals(1, test.monthOfYear().getMinimumValueOverall());
220            assertEquals(12, test.monthOfYear().getMaximumValue());
221            assertEquals(12, test.monthOfYear().getMaximumValueOverall());
222        }
223    
224        public void testPropertyAddMonth() {
225            YearMonthDay test = new YearMonthDay(1972, 6, 9);
226            YearMonthDay copy = test.monthOfYear().addToCopy(6);
227            check(test, 1972, 6, 9);
228            check(copy, 1972, 12, 9);
229            
230            copy = test.monthOfYear().addToCopy(7);
231            check(copy, 1973, 1, 9);
232            
233            copy = test.monthOfYear().addToCopy(-5);
234            check(copy, 1972, 1, 9);
235            
236            copy = test.monthOfYear().addToCopy(-6);
237            check(copy, 1971, 12, 9);
238            
239            test = new YearMonthDay(1972, 1, 31);
240            copy = test.monthOfYear().addToCopy(1);
241            check(copy, 1972, 2, 29);
242            
243            copy = test.monthOfYear().addToCopy(2);
244            check(copy, 1972, 3, 31);
245            
246            copy = test.monthOfYear().addToCopy(3);
247            check(copy, 1972, 4, 30);
248            
249            test = new YearMonthDay(1971, 1, 31);
250            copy = test.monthOfYear().addToCopy(1);
251            check(copy, 1971, 2, 28);
252        }
253    
254        public void testPropertyAddWrapFieldMonth() {
255            YearMonthDay test = new YearMonthDay(1972, 6, 9);
256            YearMonthDay copy = test.monthOfYear().addWrapFieldToCopy(4);
257            check(test, 1972, 6, 9);
258            check(copy, 1972, 10, 9);
259            
260            copy = test.monthOfYear().addWrapFieldToCopy(8);
261            check(copy, 1972, 2, 9);
262            
263            copy = test.monthOfYear().addWrapFieldToCopy(-8);
264            check(copy, 1972, 10, 9);
265            
266            test = new YearMonthDay(1972, 1, 31);
267            copy = test.monthOfYear().addWrapFieldToCopy(1);
268            check(copy, 1972, 2, 29);
269            
270            copy = test.monthOfYear().addWrapFieldToCopy(2);
271            check(copy, 1972, 3, 31);
272            
273            copy = test.monthOfYear().addWrapFieldToCopy(3);
274            check(copy, 1972, 4, 30);
275            
276            test = new YearMonthDay(1971, 1, 31);
277            copy = test.monthOfYear().addWrapFieldToCopy(1);
278            check(copy, 1971, 2, 28);
279        }
280    
281        public void testPropertySetMonth() {
282            YearMonthDay test = new YearMonthDay(1972, 6, 9);
283            YearMonthDay copy = test.monthOfYear().setCopy(12);
284            check(test, 1972, 6, 9);
285            check(copy, 1972, 12, 9);
286            
287            test = new YearMonthDay(1972, 1, 31);
288            copy = test.monthOfYear().setCopy(2);
289            check(copy, 1972, 2, 29);
290            
291            try {
292                test.monthOfYear().setCopy(13);
293                fail();
294            } catch (IllegalArgumentException ex) {}
295            try {
296                test.monthOfYear().setCopy(0);
297                fail();
298            } catch (IllegalArgumentException ex) {}
299        }
300    
301        public void testPropertySetTextMonth() {
302            YearMonthDay test = new YearMonthDay(1972, 6, 9);
303            YearMonthDay copy = test.monthOfYear().setCopy("12");
304            check(test, 1972, 6, 9);
305            check(copy, 1972, 12, 9);
306            
307            copy = test.monthOfYear().setCopy("December");
308            check(test, 1972, 6, 9);
309            check(copy, 1972, 12, 9);
310            
311            copy = test.monthOfYear().setCopy("Dec");
312            check(test, 1972, 6, 9);
313            check(copy, 1972, 12, 9);
314        }
315    
316        public void testPropertyCompareToMonth() {
317            YearMonthDay test1 = new YearMonthDay(TEST_TIME1);
318            YearMonthDay test2 = new YearMonthDay(TEST_TIME2);
319            assertEquals(true, test1.monthOfYear().compareTo(test2) < 0);
320            assertEquals(true, test2.monthOfYear().compareTo(test1) > 0);
321            assertEquals(true, test1.monthOfYear().compareTo(test1) == 0);
322            try {
323                test1.monthOfYear().compareTo((ReadablePartial) null);
324                fail();
325            } catch (IllegalArgumentException ex) {}
326            
327            DateTime dt1 = new DateTime(TEST_TIME1);
328            DateTime dt2 = new DateTime(TEST_TIME2);
329            assertEquals(true, test1.monthOfYear().compareTo(dt2) < 0);
330            assertEquals(true, test2.monthOfYear().compareTo(dt1) > 0);
331            assertEquals(true, test1.monthOfYear().compareTo(dt1) == 0);
332            try {
333                test1.monthOfYear().compareTo((ReadableInstant) null);
334                fail();
335            } catch (IllegalArgumentException ex) {}
336        }
337    
338        //-----------------------------------------------------------------------
339        public void testPropertyGetDay() {
340            YearMonthDay test = new YearMonthDay(1972, 6, 9);
341            assertSame(test.getChronology().dayOfMonth(), test.dayOfMonth().getField());
342            assertEquals("dayOfMonth", test.dayOfMonth().getName());
343            assertEquals("Property[dayOfMonth]", test.dayOfMonth().toString());
344            assertSame(test, test.dayOfMonth().getReadablePartial());
345            assertSame(test, test.dayOfMonth().getYearMonthDay());
346            assertEquals(9, test.dayOfMonth().get());
347            assertEquals("9", test.dayOfMonth().getAsString());
348            assertEquals("9", test.dayOfMonth().getAsText());
349            assertEquals("9", test.dayOfMonth().getAsText(Locale.FRENCH));
350            assertEquals("9", test.dayOfMonth().getAsShortText());
351            assertEquals("9", test.dayOfMonth().getAsShortText(Locale.FRENCH));
352            assertEquals(test.getChronology().days(), test.dayOfMonth().getDurationField());
353            assertEquals(test.getChronology().months(), test.dayOfMonth().getRangeDurationField());
354            assertEquals(2, test.dayOfMonth().getMaximumTextLength(null));
355            assertEquals(2, test.dayOfMonth().getMaximumShortTextLength(null));
356        }
357    
358        public void testPropertyGetMaxMinValuesDay() {
359            YearMonthDay test = new YearMonthDay(1972, 6, 9);
360            assertEquals(1, test.dayOfMonth().getMinimumValue());
361            assertEquals(1, test.dayOfMonth().getMinimumValueOverall());
362            assertEquals(30, test.dayOfMonth().getMaximumValue());
363            assertEquals(31, test.dayOfMonth().getMaximumValueOverall());
364            test = new YearMonthDay(1972, 7, 9);
365            assertEquals(31, test.dayOfMonth().getMaximumValue());
366            test = new YearMonthDay(1972, 2, 9);
367            assertEquals(29, test.dayOfMonth().getMaximumValue());
368            test = new YearMonthDay(1971, 2, 9);
369            assertEquals(28, test.dayOfMonth().getMaximumValue());
370        }
371    
372        public void testPropertyAddDay() {
373            YearMonthDay test = new YearMonthDay(1972, 6, 9);
374            YearMonthDay copy = test.dayOfMonth().addToCopy(9);
375            check(test, 1972, 6, 9);
376            check(copy, 1972, 6, 18);
377            
378            copy = test.dayOfMonth().addToCopy(21);
379            check(copy, 1972, 6, 30);
380            
381            copy = test.dayOfMonth().addToCopy(22);
382            check(copy, 1972, 7, 1);
383            
384            copy = test.dayOfMonth().addToCopy(22 + 30);
385            check(copy, 1972, 7, 31);
386            
387            copy = test.dayOfMonth().addToCopy(22 + 31);
388            check(copy, 1972, 8, 1);
389    
390            copy = test.dayOfMonth().addToCopy(21 + 31 + 31 + 30 + 31 + 30 + 31);
391            check(copy, 1972, 12, 31);
392            
393            copy = test.dayOfMonth().addToCopy(22 + 31 + 31 + 30 + 31 + 30 + 31);
394            check(copy, 1973, 1, 1);
395            
396            copy = test.dayOfMonth().addToCopy(-8);
397            check(copy, 1972, 6, 1);
398            
399            copy = test.dayOfMonth().addToCopy(-9);
400            check(copy, 1972, 5, 31);
401            
402            copy = test.dayOfMonth().addToCopy(-8 - 31 - 30 - 31 - 29 - 31);
403            check(copy, 1972, 1, 1);
404            
405            copy = test.dayOfMonth().addToCopy(-9 - 31 - 30 - 31 - 29 - 31);
406            check(copy, 1971, 12, 31);
407        }
408    
409        public void testPropertyAddWrapFieldDay() {
410            YearMonthDay test = new YearMonthDay(1972, 6, 9);
411            YearMonthDay copy = test.dayOfMonth().addWrapFieldToCopy(21);
412            check(test, 1972, 6, 9);
413            check(copy, 1972, 6, 30);
414            
415            copy = test.dayOfMonth().addWrapFieldToCopy(22);
416            check(copy, 1972, 6, 1);
417            
418            copy = test.dayOfMonth().addWrapFieldToCopy(-12);
419            check(copy, 1972, 6, 27);
420            
421            test = new YearMonthDay(1972, 7, 9);
422            copy = test.dayOfMonth().addWrapFieldToCopy(21);
423            check(copy, 1972, 7, 30);
424        
425            copy = test.dayOfMonth().addWrapFieldToCopy(22);
426            check(copy, 1972, 7, 31);
427        
428            copy = test.dayOfMonth().addWrapFieldToCopy(23);
429            check(copy, 1972, 7, 1);
430        
431            copy = test.dayOfMonth().addWrapFieldToCopy(-12);
432            check(copy, 1972, 7, 28);
433        }
434    
435        public void testPropertySetDay() {
436            YearMonthDay test = new YearMonthDay(1972, 6, 9);
437            YearMonthDay copy = test.dayOfMonth().setCopy(12);
438            check(test, 1972, 6, 9);
439            check(copy, 1972, 6, 12);
440            
441            try {
442                test.dayOfMonth().setCopy(31);
443                fail();
444            } catch (IllegalArgumentException ex) {}
445            try {
446                test.dayOfMonth().setCopy(0);
447                fail();
448            } catch (IllegalArgumentException ex) {}
449        }
450    
451        public void testPropertySetTextDay() {
452            YearMonthDay test = new YearMonthDay(1972, 6, 9);
453            YearMonthDay copy = test.dayOfMonth().setCopy("12");
454            check(test, 1972, 6, 9);
455            check(copy, 1972, 6, 12);
456        }
457    
458        public void testPropertyWithMaximumValueDayOfMonth() {
459            YearMonthDay test = new YearMonthDay(1972, 6, 9);
460            YearMonthDay copy = test.dayOfMonth().withMaximumValue();
461            check(test, 1972, 6, 9);
462            check(copy, 1972, 6, 30);
463        }
464    
465        public void testPropertyWithMinimumValueDayOfMonth() {
466            YearMonthDay test = new YearMonthDay(1972, 6, 9);
467            YearMonthDay copy = test.dayOfMonth().withMinimumValue();
468            check(test, 1972, 6, 9);
469            check(copy, 1972, 6, 1);
470        }
471    
472        public void testPropertyCompareToDay() {
473            YearMonthDay test1 = new YearMonthDay(TEST_TIME1);
474            YearMonthDay test2 = new YearMonthDay(TEST_TIME2);
475            assertEquals(true, test1.dayOfMonth().compareTo(test2) < 0);
476            assertEquals(true, test2.dayOfMonth().compareTo(test1) > 0);
477            assertEquals(true, test1.dayOfMonth().compareTo(test1) == 0);
478            try {
479                test1.dayOfMonth().compareTo((ReadablePartial) null);
480                fail();
481            } catch (IllegalArgumentException ex) {}
482            
483            DateTime dt1 = new DateTime(TEST_TIME1);
484            DateTime dt2 = new DateTime(TEST_TIME2);
485            assertEquals(true, test1.dayOfMonth().compareTo(dt2) < 0);
486            assertEquals(true, test2.dayOfMonth().compareTo(dt1) > 0);
487            assertEquals(true, test1.dayOfMonth().compareTo(dt1) == 0);
488            try {
489                test1.dayOfMonth().compareTo((ReadableInstant) null);
490                fail();
491            } catch (IllegalArgumentException ex) {}
492        }
493    
494        public void testPropertyEquals() {
495            YearMonthDay test1 = new YearMonthDay(2005, 11, 8);
496            YearMonthDay test2 = new YearMonthDay(2005, 11, 9);
497            YearMonthDay test3 = new YearMonthDay(2005, 11, 8, CopticChronology.getInstanceUTC());
498            assertEquals(false, test1.dayOfMonth().equals(test1.year()));
499            assertEquals(false, test1.dayOfMonth().equals(test1.monthOfYear()));
500            assertEquals(true, test1.dayOfMonth().equals(test1.dayOfMonth()));
501            assertEquals(false, test1.dayOfMonth().equals(test2.year()));
502            assertEquals(false, test1.dayOfMonth().equals(test2.monthOfYear()));
503            assertEquals(false, test1.dayOfMonth().equals(test2.dayOfMonth()));
504            
505            assertEquals(false, test1.monthOfYear().equals(test1.year()));
506            assertEquals(true, test1.monthOfYear().equals(test1.monthOfYear()));
507            assertEquals(false, test1.monthOfYear().equals(test1.dayOfMonth()));
508            assertEquals(false, test1.monthOfYear().equals(test2.year()));
509            assertEquals(true, test1.monthOfYear().equals(test2.monthOfYear()));
510            assertEquals(false, test1.monthOfYear().equals(test2.dayOfMonth()));
511            
512            assertEquals(false, test1.dayOfMonth().equals(null));
513            assertEquals(false, test1.dayOfMonth().equals("any"));
514            
515            // chrono
516            assertEquals(false, test1.dayOfMonth().equals(test3.dayOfMonth()));
517        }
518    
519        public void testPropertyHashCode() {
520            YearMonthDay test1 = new YearMonthDay(2005, 11, 8);
521            YearMonthDay test2 = new YearMonthDay(2005, 11, 9);
522            assertEquals(true, test1.dayOfMonth().hashCode() == test1.dayOfMonth().hashCode());
523            assertEquals(false, test1.dayOfMonth().hashCode() == test2.dayOfMonth().hashCode());
524            assertEquals(true, test1.monthOfYear().hashCode() == test1.monthOfYear().hashCode());
525            assertEquals(true, test1.monthOfYear().hashCode() == test2.monthOfYear().hashCode());
526        }
527    
528        public void testPropertyEqualsHashCodeLenient() {
529            YearMonthDay test1 = new YearMonthDay(1970, 6, 9, LenientChronology.getInstance(COPTIC_PARIS));
530            YearMonthDay test2 = new YearMonthDay(1970, 6, 9, LenientChronology.getInstance(COPTIC_PARIS));
531            assertEquals(true, test1.dayOfMonth().equals(test2.dayOfMonth()));
532            assertEquals(true, test2.dayOfMonth().equals(test1.dayOfMonth()));
533            assertEquals(true, test1.dayOfMonth().equals(test1.dayOfMonth()));
534            assertEquals(true, test2.dayOfMonth().equals(test2.dayOfMonth()));
535            assertEquals(true, test1.dayOfMonth().hashCode() == test2.dayOfMonth().hashCode());
536            assertEquals(true, test1.dayOfMonth().hashCode() == test1.dayOfMonth().hashCode());
537            assertEquals(true, test2.dayOfMonth().hashCode() == test2.dayOfMonth().hashCode());
538        }
539    
540        public void testPropertyEqualsHashCodeStrict() {
541            YearMonthDay test1 = new YearMonthDay(1970, 6, 9, StrictChronology.getInstance(COPTIC_PARIS));
542            YearMonthDay test2 = new YearMonthDay(1970, 6, 9, StrictChronology.getInstance(COPTIC_PARIS));
543            assertEquals(true, test1.dayOfMonth().equals(test2.dayOfMonth()));
544            assertEquals(true, test2.dayOfMonth().equals(test1.dayOfMonth()));
545            assertEquals(true, test1.dayOfMonth().equals(test1.dayOfMonth()));
546            assertEquals(true, test2.dayOfMonth().equals(test2.dayOfMonth()));
547            assertEquals(true, test1.dayOfMonth().hashCode() == test2.dayOfMonth().hashCode());
548            assertEquals(true, test1.dayOfMonth().hashCode() == test1.dayOfMonth().hashCode());
549            assertEquals(true, test2.dayOfMonth().hashCode() == test2.dayOfMonth().hashCode());
550        }
551    
552        //-----------------------------------------------------------------------
553        private void check(YearMonthDay test, int year, int month, int day) {
554            assertEquals(year, test.getYear());
555            assertEquals(month, test.getMonthOfYear());
556            assertEquals(day, test.getDayOfMonth());
557        }
558    }