KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > joda > time > TestYearMonthDay_Properties


1 /*
2  * Copyright 2001-2005 Stephen Colebourne
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.joda.time;
17
18 import java.util.Locale JavaDoc;
19
20 import junit.framework.TestCase;
21 import junit.framework.TestSuite;
22
23 import org.joda.time.chrono.CopticChronology;
24 import org.joda.time.chrono.LenientChronology;
25 import org.joda.time.chrono.StrictChronology;
26
27 /**
28  * This class is a Junit unit test for YearMonthDay.
29  *
30  * @author Stephen Colebourne
31  */

32 public class TestYearMonthDay_Properties extends TestCase {
33
34     private static final DateTimeZone PARIS = DateTimeZone.forID("Europe/Paris");
35     private static final Chronology COPTIC_PARIS = CopticChronology.getInstance(PARIS);
36
37     private long TEST_TIME_NOW =
38             (31L + 28L + 31L + 30L + 31L + 9L -1L) * DateTimeConstants.MILLIS_PER_DAY;
39             
40     private long TEST_TIME1 =
41         (31L + 28L + 31L + 6L -1L) * DateTimeConstants.MILLIS_PER_DAY
42         + 12L * DateTimeConstants.MILLIS_PER_HOUR
43         + 24L * DateTimeConstants.MILLIS_PER_MINUTE;
44         
45     private long TEST_TIME2 =
46         (365L + 31L + 28L + 31L + 30L + 7L -1L) * DateTimeConstants.MILLIS_PER_DAY
47         + 14L * DateTimeConstants.MILLIS_PER_HOUR
48         + 28L * DateTimeConstants.MILLIS_PER_MINUTE;
49         
50     private DateTimeZone zone = null;
51
52     public static void main(String JavaDoc[] args) {
53         junit.textui.TestRunner.run(suite());
54     }
55
56     public static TestSuite suite() {
57         return new TestSuite(TestYearMonthDay_Properties.class);
58     }
59
60     public TestYearMonthDay_Properties(String JavaDoc name) {
61         super(name);
62     }
63
64     protected void setUp() throws Exception JavaDoc {
65         DateTimeUtils.setCurrentMillisFixed(TEST_TIME_NOW);
66         zone = DateTimeZone.getDefault();
67         DateTimeZone.setDefault(DateTimeZone.UTC);
68     }
69
70     protected void tearDown() throws Exception JavaDoc {
71         DateTimeUtils.setCurrentMillisSystem();
72         DateTimeZone.setDefault(zone);
73         zone = null;
74     }
75
76     //-----------------------------------------------------------------------
77
public void testPropertyGetYear() {
78         YearMonthDay test = new YearMonthDay(1972, 6, 9);
79         assertSame(test.getChronology().year(), test.year().getField());
80         assertEquals("year", test.year().getName());
81         assertEquals("Property[year]", test.year().toString());
82         assertSame(test, test.year().getReadablePartial());
83         assertSame(test, test.year().getYearMonthDay());
84         assertEquals(1972, test.year().get());
85         assertEquals("1972", test.year().getAsString());
86         assertEquals("1972", test.year().getAsText());
87         assertEquals("1972", test.year().getAsText(Locale.FRENCH));
88         assertEquals("1972", test.year().getAsShortText());
89         assertEquals("1972", test.year().getAsShortText(Locale.FRENCH));
90         assertEquals(test.getChronology().years(), test.year().getDurationField());
91         assertEquals(null, test.year().getRangeDurationField());
92         assertEquals(9, test.year().getMaximumTextLength(null));
93         assertEquals(9, test.year().getMaximumShortTextLength(null));
94     }
95
96     public void testPropertyGetMaxMinValuesYear() {
97         YearMonthDay test = new YearMonthDay(1972, 6, 9);
98         assertEquals(-292275054, test.year().getMinimumValue());
99         assertEquals(-292275054, test.year().getMinimumValueOverall());
100         assertEquals(292278993, test.year().getMaximumValue());
101         assertEquals(292278993, test.year().getMaximumValueOverall());
102     }
103
104     public void testPropertyAddYear() {
105         YearMonthDay test = new YearMonthDay(1972, 6, 9);
106         YearMonthDay copy = test.year().addToCopy(9);
107         check(test, 1972, 6, 9);
108         check(copy, 1981, 6, 9);
109         
110         copy = test.year().addToCopy(0);
111         check(copy, 1972, 6, 9);
112         
113         copy = test.year().addToCopy(292277023 - 1972);
114         check(copy, 292277023, 6, 9);
115         
116         try {
117             test.year().addToCopy(292278993 - 1972 + 1);
118             fail();
119         } catch (IllegalArgumentException JavaDoc ex) {}
120         check(test, 1972, 6, 9);
121         
122         copy = test.year().addToCopy(-1972);
123         check(copy, 0, 6, 9);
124         
125         copy = test.year().addToCopy(-1973);
126         check(copy, -1, 6, 9);
127         
128         try {
129             test.year().addToCopy(-292275054 - 1972 - 1);
130             fail();
131         } catch (IllegalArgumentException JavaDoc ex) {}
132         check(test, 1972, 6, 9);
133     }
134
135     public void testPropertyAddWrapFieldYear() {
136         YearMonthDay test = new YearMonthDay(1972, 6, 9);
137         YearMonthDay copy = test.year().addWrapFieldToCopy(9);
138         check(test, 1972, 6, 9);
139         check(copy, 1981, 6, 9);
140         
141         copy = test.year().addWrapFieldToCopy(0);
142         check(copy, 1972, 6, 9);
143         
144         copy = test.year().addWrapFieldToCopy(292278993 - 1972 + 1);
145         check(copy, -292275054, 6, 9);
146         
147         copy = test.year().addWrapFieldToCopy(-292275054 - 1972 - 1);
148         check(copy, 292278993, 6, 9);
149     }
150
151     public void testPropertySetYear() {
152         YearMonthDay test = new YearMonthDay(1972, 6, 9);
153         YearMonthDay copy = test.year().setCopy(12);
154         check(test, 1972, 6, 9);
155         check(copy, 12, 6, 9);
156     }
157
158     public void testPropertySetTextYear() {
159         YearMonthDay test = new YearMonthDay(1972, 6, 9);
160         YearMonthDay copy = test.year().setCopy("12");
161         check(test, 1972, 6, 9);
162         check(copy, 12, 6, 9);
163     }
164
165     public void testPropertyCompareToYear() {
166         YearMonthDay test1 = new YearMonthDay(TEST_TIME1);
167         YearMonthDay test2 = new YearMonthDay(TEST_TIME2);
168         assertEquals(true, test1.year().compareTo(test2) < 0);
169         assertEquals(true, test2.year().compareTo(test1) > 0);
170         assertEquals(true, test1.year().compareTo(test1) == 0);
171         try {
172             test1.year().compareTo((ReadablePartial) null);
173             fail();
174         } catch (IllegalArgumentException JavaDoc ex) {}
175         
176         DateTime dt1 = new DateTime(TEST_TIME1);
177         DateTime dt2 = new DateTime(TEST_TIME2);
178         assertEquals(true, test1.year().compareTo(dt2) < 0);
179         assertEquals(true, test2.year().compareTo(dt1) > 0);
180         assertEquals(true, test1.year().compareTo(dt1) == 0);
181         try {
182             test1.year().compareTo((ReadableInstant) null);
183             fail();
184         } catch (IllegalArgumentException JavaDoc ex) {}
185     }
186
187     //-----------------------------------------------------------------------
188
public void testPropertyGetMonth() {
189         YearMonthDay test = new YearMonthDay(1972, 6, 9);
190         assertSame(test.getChronology().monthOfYear(), test.monthOfYear().getField());
191         assertEquals("monthOfYear", test.monthOfYear().getName());
192         assertEquals("Property[monthOfYear]", test.monthOfYear().toString());
193         assertSame(test, test.monthOfYear().getReadablePartial());
194         assertSame(test, test.monthOfYear().getYearMonthDay());
195         assertEquals(6, test.monthOfYear().get());
196         assertEquals("6", test.monthOfYear().getAsString());
197         assertEquals("June", test.monthOfYear().getAsText());
198         assertEquals("juin", test.monthOfYear().getAsText(Locale.FRENCH));
199         assertEquals("Jun", test.monthOfYear().getAsShortText());
200         assertEquals("juin", test.monthOfYear().getAsShortText(Locale.FRENCH));
201         assertEquals(test.getChronology().months(), test.monthOfYear().getDurationField());
202         assertEquals(test.getChronology().years(), test.monthOfYear().getRangeDurationField());
203         assertEquals(9, test.monthOfYear().getMaximumTextLength(null));
204         assertEquals(3, test.monthOfYear().getMaximumShortTextLength(null));
205         test = new YearMonthDay(1972, 7, 9);
206         assertEquals("juillet", test.monthOfYear().getAsText(Locale.FRENCH));
207         assertEquals("juil.", test.monthOfYear().getAsShortText(Locale.FRENCH));
208     }
209
210     public void testPropertyGetMaxMinValuesMonth() {
211         YearMonthDay test = new YearMonthDay(1972, 6, 9);
212         assertEquals(1, test.monthOfYear().getMinimumValue());
213         assertEquals(1, test.monthOfYear().getMinimumValueOverall());
214         assertEquals(12, test.monthOfYear().getMaximumValue());
215         assertEquals(12, test.monthOfYear().getMaximumValueOverall());
216     }
217
218     public void testPropertyAddMonth() {
219         YearMonthDay test = new YearMonthDay(1972, 6, 9);
220         YearMonthDay copy = test.monthOfYear().addToCopy(6);
221         check(test, 1972, 6, 9);
222         check(copy, 1972, 12, 9);
223         
224         copy = test.monthOfYear().addToCopy(7);
225         check(copy, 1973, 1, 9);
226         
227         copy = test.monthOfYear().addToCopy(-5);
228         check(copy, 1972, 1, 9);
229         
230         copy = test.monthOfYear().addToCopy(-6);
231         check(copy, 1971, 12, 9);
232         
233         test = new YearMonthDay(1972, 1, 31);
234         copy = test.monthOfYear().addToCopy(1);
235         check(copy, 1972, 2, 29);
236         
237         copy = test.monthOfYear().addToCopy(2);
238         check(copy, 1972, 3, 31);
239         
240         copy = test.monthOfYear().addToCopy(3);
241         check(copy, 1972, 4, 30);
242         
243         test = new YearMonthDay(1971, 1, 31);
244         copy = test.monthOfYear().addToCopy(1);
245         check(copy, 1971, 2, 28);
246     }
247
248     public void testPropertyAddWrapFieldMonth() {
249         YearMonthDay test = new YearMonthDay(1972, 6, 9);
250         YearMonthDay copy = test.monthOfYear().addWrapFieldToCopy(4);
251         check(test, 1972, 6, 9);
252         check(copy, 1972, 10, 9);
253         
254         copy = test.monthOfYear().addWrapFieldToCopy(8);
255         check(copy, 1972, 2, 9);
256         
257         copy = test.monthOfYear().addWrapFieldToCopy(-8);
258         check(copy, 1972, 10, 9);
259         
260         test = new YearMonthDay(1972, 1, 31);
261         copy = test.monthOfYear().addWrapFieldToCopy(1);
262         check(copy, 1972, 2, 29);
263         
264         copy = test.monthOfYear().addWrapFieldToCopy(2);
265         check(copy, 1972, 3, 31);
266         
267         copy = test.monthOfYear().addWrapFieldToCopy(3);
268         check(copy, 1972, 4, 30);
269         
270         test = new YearMonthDay(1971, 1, 31);
271         copy = test.monthOfYear().addWrapFieldToCopy(1);
272         check(copy, 1971, 2, 28);
273     }
274
275     public void testPropertySetMonth() {
276         YearMonthDay test = new YearMonthDay(1972, 6, 9);
277         YearMonthDay copy = test.monthOfYear().setCopy(12);
278         check(test, 1972, 6, 9);
279         check(copy, 1972, 12, 9);
280         
281         test = new YearMonthDay(1972, 1, 31);
282         copy = test.monthOfYear().setCopy(2);
283         check(copy, 1972, 2, 29);
284         
285         try {
286             test.monthOfYear().setCopy(13);
287             fail();
288         } catch (IllegalArgumentException JavaDoc ex) {}
289         try {
290             test.monthOfYear().setCopy(0);
291             fail();
292         } catch (IllegalArgumentException JavaDoc ex) {}
293     }
294
295     public void testPropertySetTextMonth() {
296         YearMonthDay test = new YearMonthDay(1972, 6, 9);
297         YearMonthDay copy = test.monthOfYear().setCopy("12");
298         check(test, 1972, 6, 9);
299         check(copy, 1972, 12, 9);
300         
301         copy = test.monthOfYear().setCopy("December");
302         check(test, 1972, 6, 9);
303         check(copy, 1972, 12, 9);
304         
305         copy = test.monthOfYear().setCopy("Dec");
306         check(test, 1972, 6, 9);
307         check(copy, 1972, 12, 9);
308     }
309
310     public void testPropertyCompareToMonth() {
311         YearMonthDay test1 = new YearMonthDay(TEST_TIME1);
312         YearMonthDay test2 = new YearMonthDay(TEST_TIME2);
313         assertEquals(true, test1.monthOfYear().compareTo(test2) < 0);
314         assertEquals(true, test2.monthOfYear().compareTo(test1) > 0);
315         assertEquals(true, test1.monthOfYear().compareTo(test1) == 0);
316         try {
317             test1.monthOfYear().compareTo((ReadablePartial) null);
318             fail();
319         } catch (IllegalArgumentException JavaDoc ex) {}
320         
321         DateTime dt1 = new DateTime(TEST_TIME1);
322         DateTime dt2 = new DateTime(TEST_TIME2);
323         assertEquals(true, test1.monthOfYear().compareTo(dt2) < 0);
324         assertEquals(true, test2.monthOfYear().compareTo(dt1) > 0);
325         assertEquals(true, test1.monthOfYear().compareTo(dt1) == 0);
326         try {
327             test1.monthOfYear().compareTo((ReadableInstant) null);
328             fail();
329         } catch (IllegalArgumentException JavaDoc ex) {}
330     }
331
332     //-----------------------------------------------------------------------
333
public void testPropertyGetDay() {
334         YearMonthDay test = new YearMonthDay(1972, 6, 9);
335         assertSame(test.getChronology().dayOfMonth(), test.dayOfMonth().getField());
336         assertEquals("dayOfMonth", test.dayOfMonth().getName());
337         assertEquals("Property[dayOfMonth]", test.dayOfMonth().toString());
338         assertSame(test, test.dayOfMonth().getReadablePartial());
339         assertSame(test, test.dayOfMonth().getYearMonthDay());
340         assertEquals(9, test.dayOfMonth().get());
341         assertEquals("9", test.dayOfMonth().getAsString());
342         assertEquals("9", test.dayOfMonth().getAsText());
343         assertEquals("9", test.dayOfMonth().getAsText(Locale.FRENCH));
344         assertEquals("9", test.dayOfMonth().getAsShortText());
345         assertEquals("9", test.dayOfMonth().getAsShortText(Locale.FRENCH));
346         assertEquals(test.getChronology().days(), test.dayOfMonth().getDurationField());
347         assertEquals(test.getChronology().months(), test.dayOfMonth().getRangeDurationField());
348         assertEquals(2, test.dayOfMonth().getMaximumTextLength(null));
349         assertEquals(2, test.dayOfMonth().getMaximumShortTextLength(null));
350     }
351
352     public void testPropertyGetMaxMinValuesDay() {
353         YearMonthDay test = new YearMonthDay(1972, 6, 9);
354         assertEquals(1, test.dayOfMonth().getMinimumValue());
355         assertEquals(1, test.dayOfMonth().getMinimumValueOverall());
356         assertEquals(30, test.dayOfMonth().getMaximumValue());
357         assertEquals(31, test.dayOfMonth().getMaximumValueOverall());
358         test = new YearMonthDay(1972, 7, 9);
359         assertEquals(31, test.dayOfMonth().getMaximumValue());
360         test = new YearMonthDay(1972, 2, 9);
361         assertEquals(29, test.dayOfMonth().getMaximumValue());
362         test = new YearMonthDay(1971, 2, 9);
363         assertEquals(28, test.dayOfMonth().getMaximumValue());
364     }
365
366     public void testPropertyAddDay() {
367         YearMonthDay test = new YearMonthDay(1972, 6, 9);
368         YearMonthDay copy = test.dayOfMonth().addToCopy(9);
369         check(test, 1972, 6, 9);
370         check(copy, 1972, 6, 18);
371         
372         copy = test.dayOfMonth().addToCopy(21);
373         check(copy, 1972, 6, 30);
374         
375         copy = test.dayOfMonth().addToCopy(22);
376         check(copy, 1972, 7, 1);
377         
378         copy = test.dayOfMonth().addToCopy(22 + 30);
379         check(copy, 1972, 7, 31);
380         
381         copy = test.dayOfMonth().addToCopy(22 + 31);
382         check(copy, 1972, 8, 1);
383
384         copy = test.dayOfMonth().addToCopy(21 + 31 + 31 + 30 + 31 + 30 + 31);
385         check(copy, 1972, 12, 31);
386         
387         copy = test.dayOfMonth().addToCopy(22 + 31 + 31 + 30 + 31 + 30 + 31);
388         check(copy, 1973, 1, 1);
389         
390         copy = test.dayOfMonth().addToCopy(-8);
391         check(copy, 1972, 6, 1);
392         
393         copy = test.dayOfMonth().addToCopy(-9);
394         check(copy, 1972, 5, 31);
395         
396         copy = test.dayOfMonth().addToCopy(-8 - 31 - 30 - 31 - 29 - 31);
397         check(copy, 1972, 1, 1);
398         
399         copy = test.dayOfMonth().addToCopy(-9 - 31 - 30 - 31 - 29 - 31);
400         check(copy, 1971, 12, 31);
401     }
402
403     public void testPropertyAddWrapFieldDay() {
404         YearMonthDay test = new YearMonthDay(1972, 6, 9);
405         YearMonthDay copy = test.dayOfMonth().addWrapFieldToCopy(21);
406         check(test, 1972, 6, 9);
407         check(copy, 1972, 6, 30);
408         
409         copy = test.dayOfMonth().addWrapFieldToCopy(22);
410         check(copy, 1972, 6, 1);
411         
412         copy = test.dayOfMonth().addWrapFieldToCopy(-12);
413         check(copy, 1972, 6, 27);
414         
415         test = new YearMonthDay(1972, 7, 9);
416         copy = test.dayOfMonth().addWrapFieldToCopy(21);
417         check(copy, 1972, 7, 30);
418     
419         copy = test.dayOfMonth().addWrapFieldToCopy(22);
420         check(copy, 1972, 7, 31);
421     
422         copy = test.dayOfMonth().addWrapFieldToCopy(23);
423         check(copy, 1972, 7, 1);
424     
425         copy = test.dayOfMonth().addWrapFieldToCopy(-12);
426         check(copy, 1972, 7, 28);
427     }
428
429     public void testPropertySetDay() {
430         YearMonthDay test = new YearMonthDay(1972, 6, 9);
431         YearMonthDay copy = test.dayOfMonth().setCopy(12);
432         check(test, 1972, 6, 9);
433         check(copy, 1972, 6, 12);
434         
435         try {
436             test.dayOfMonth().setCopy(31);
437             fail();
438         } catch (IllegalArgumentException JavaDoc ex) {}
439         try {
440             test.dayOfMonth().setCopy(0);
441             fail();
442         } catch (IllegalArgumentException JavaDoc ex) {}
443     }
444
445     public void testPropertySetTextDay() {
446         YearMonthDay test = new YearMonthDay(1972, 6, 9);
447         YearMonthDay copy = test.dayOfMonth().setCopy("12");
448         check(test, 1972, 6, 9);
449         check(copy, 1972, 6, 12);
450     }
451
452     public void testPropertyWithMaximumValueDayOfMonth() {
453         YearMonthDay test = new YearMonthDay(1972, 6, 9);
454         YearMonthDay copy = test.dayOfMonth().withMaximumValue();
455         check(test, 1972, 6, 9);
456         check(copy, 1972, 6, 30);
457     }
458
459     public void testPropertyWithMinimumValueDayOfMonth() {
460         YearMonthDay test = new YearMonthDay(1972, 6, 9);
461         YearMonthDay copy = test.dayOfMonth().withMinimumValue();
462         check(test, 1972, 6, 9);
463         check(copy, 1972, 6, 1);
464     }
465
466     public void testPropertyCompareToDay() {
467         YearMonthDay test1 = new YearMonthDay(TEST_TIME1);
468         YearMonthDay test2 = new YearMonthDay(TEST_TIME2);
469         assertEquals(true, test1.dayOfMonth().compareTo(test2) < 0);
470         assertEquals(true, test2.dayOfMonth().compareTo(test1) > 0);
471         assertEquals(true, test1.dayOfMonth().compareTo(test1) == 0);
472         try {
473             test1.dayOfMonth().compareTo((ReadablePartial) null);
474             fail();
475         } catch (IllegalArgumentException JavaDoc ex) {}
476         
477         DateTime dt1 = new DateTime(TEST_TIME1);
478         DateTime dt2 = new DateTime(TEST_TIME2);
479         assertEquals(true, test1.dayOfMonth().compareTo(dt2) < 0);
480         assertEquals(true, test2.dayOfMonth().compareTo(dt1) > 0);
481         assertEquals(true, test1.dayOfMonth().compareTo(dt1) == 0);
482         try {
483             test1.dayOfMonth().compareTo((ReadableInstant) null);
484             fail();
485         } catch (IllegalArgumentException JavaDoc ex) {}
486     }
487
488     public void testPropertyEquals() {
489         YearMonthDay test1 = new YearMonthDay(2005, 11, 8);
490         YearMonthDay test2 = new YearMonthDay(2005, 11, 9);
491         YearMonthDay test3 = new YearMonthDay(2005, 11, 8, CopticChronology.getInstanceUTC());
492         assertEquals(false, test1.dayOfMonth().equals(test1.year()));
493         assertEquals(false, test1.dayOfMonth().equals(test1.monthOfYear()));
494         assertEquals(true, test1.dayOfMonth().equals(test1.dayOfMonth()));
495         assertEquals(false, test1.dayOfMonth().equals(test2.year()));
496         assertEquals(false, test1.dayOfMonth().equals(test2.monthOfYear()));
497         assertEquals(false, test1.dayOfMonth().equals(test2.dayOfMonth()));
498         
499         assertEquals(false, test1.monthOfYear().equals(test1.year()));
500         assertEquals(true, test1.monthOfYear().equals(test1.monthOfYear()));
501         assertEquals(false, test1.monthOfYear().equals(test1.dayOfMonth()));
502         assertEquals(false, test1.monthOfYear().equals(test2.year()));
503         assertEquals(true, test1.monthOfYear().equals(test2.monthOfYear()));
504         assertEquals(false, test1.monthOfYear().equals(test2.dayOfMonth()));
505         
506         assertEquals(false, test1.dayOfMonth().equals(null));
507         assertEquals(false, test1.dayOfMonth().equals("any"));
508         
509         // chrono
510
assertEquals(false, test1.dayOfMonth().equals(test3.dayOfMonth()));
511     }
512
513     public void testPropertyHashCode() {
514         YearMonthDay test1 = new YearMonthDay(2005, 11, 8);
515         YearMonthDay test2 = new YearMonthDay(2005, 11, 9);
516         assertEquals(true, test1.dayOfMonth().hashCode() == test1.dayOfMonth().hashCode());
517         assertEquals(false, test1.dayOfMonth().hashCode() == test2.dayOfMonth().hashCode());
518         assertEquals(true, test1.monthOfYear().hashCode() == test1.monthOfYear().hashCode());
519         assertEquals(true, test1.monthOfYear().hashCode() == test2.monthOfYear().hashCode());
520     }
521
522     public void testPropertyEqualsHashCodeLenient() {
523         YearMonthDay test1 = new YearMonthDay(1970, 6, 9, LenientChronology.getInstance(COPTIC_PARIS));
524         YearMonthDay test2 = new YearMonthDay(1970, 6, 9, LenientChronology.getInstance(COPTIC_PARIS));
525         assertEquals(true, test1.dayOfMonth().equals(test2.dayOfMonth()));
526         assertEquals(true, test2.dayOfMonth().equals(test1.dayOfMonth()));
527         assertEquals(true, test1.dayOfMonth().equals(test1.dayOfMonth()));
528         assertEquals(true, test2.dayOfMonth().equals(test2.dayOfMonth()));
529         assertEquals(true, test1.dayOfMonth().hashCode() == test2.dayOfMonth().hashCode());
530         assertEquals(true, test1.dayOfMonth().hashCode() == test1.dayOfMonth().hashCode());
531         assertEquals(true, test2.dayOfMonth().hashCode() == test2.dayOfMonth().hashCode());
532     }
533
534     public void testPropertyEqualsHashCodeStrict() {
535         YearMonthDay test1 = new YearMonthDay(1970, 6, 9, StrictChronology.getInstance(COPTIC_PARIS));
536         YearMonthDay test2 = new YearMonthDay(1970, 6, 9, StrictChronology.getInstance(COPTIC_PARIS));
537         assertEquals(true, test1.dayOfMonth().equals(test2.dayOfMonth()));
538         assertEquals(true, test2.dayOfMonth().equals(test1.dayOfMonth()));
539         assertEquals(true, test1.dayOfMonth().equals(test1.dayOfMonth()));
540         assertEquals(true, test2.dayOfMonth().equals(test2.dayOfMonth()));
541         assertEquals(true, test1.dayOfMonth().hashCode() == test2.dayOfMonth().hashCode());
542         assertEquals(true, test1.dayOfMonth().hashCode() == test1.dayOfMonth().hashCode());
543         assertEquals(true, test2.dayOfMonth().hashCode() == test2.dayOfMonth().hashCode());
544     }
545
546     //-----------------------------------------------------------------------
547
private void check(YearMonthDay test, int year, int month, int day) {
548         assertEquals(year, test.getYear());
549         assertEquals(month, test.getMonthOfYear());
550         assertEquals(day, test.getDayOfMonth());
551     }
552 }
553
Popular Tags