001: /*
002: * Copyright 2001-2006 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 TestLocalDate_Properties extends TestCase {
033:
034: private static final DateTimeZone PARIS = DateTimeZone
035: .forID("Europe/Paris");
036: private static final Chronology COPTIC_PARIS = CopticChronology
037: .getInstance(PARIS);
038:
039: private long TEST_TIME_NOW = (31L + 28L + 31L + 30L + 31L + 9L - 1L)
040: * DateTimeConstants.MILLIS_PER_DAY;
041:
042: private long TEST_TIME1 = (31L + 28L + 31L + 6L - 1L)
043: * DateTimeConstants.MILLIS_PER_DAY + 12L
044: * DateTimeConstants.MILLIS_PER_HOUR + 24L
045: * DateTimeConstants.MILLIS_PER_MINUTE;
046:
047: private long TEST_TIME2 = (365L + 31L + 28L + 31L + 30L + 7L - 1L)
048: * DateTimeConstants.MILLIS_PER_DAY + 14L
049: * DateTimeConstants.MILLIS_PER_HOUR + 28L
050: * DateTimeConstants.MILLIS_PER_MINUTE;
051:
052: private DateTimeZone zone = 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(TestLocalDate_Properties.class);
060: }
061:
062: public TestLocalDate_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: }
071:
072: protected void tearDown() throws Exception {
073: DateTimeUtils.setCurrentMillisSystem();
074: DateTimeZone.setDefault(zone);
075: zone = null;
076: }
077:
078: //-----------------------------------------------------------------------
079: public void testPropertyGetYear() {
080: LocalDate test = new LocalDate(1972, 6, 9);
081: assertSame(test.getChronology().year(), test.year().getField());
082: assertEquals("year", test.year().getName());
083: assertEquals("Property[year]", test.year().toString());
084: assertSame(test, test.year().getLocalDate());
085: assertEquals(1972, test.year().get());
086: assertEquals("1972", test.year().getAsString());
087: assertEquals("1972", test.year().getAsText());
088: assertEquals("1972", test.year().getAsText(Locale.FRENCH));
089: assertEquals("1972", test.year().getAsShortText());
090: assertEquals("1972", test.year().getAsShortText(Locale.FRENCH));
091: assertEquals(test.getChronology().years(), test.year()
092: .getDurationField());
093: assertEquals(null, test.year().getRangeDurationField());
094: assertEquals(9, test.year().getMaximumTextLength(null));
095: assertEquals(9, test.year().getMaximumShortTextLength(null));
096: }
097:
098: public void testPropertyGetMaxMinValuesYear() {
099: LocalDate test = new LocalDate(1972, 6, 9);
100: assertEquals(-292275054, test.year().getMinimumValue());
101: assertEquals(-292275054, test.year().getMinimumValueOverall());
102: assertEquals(292278993, test.year().getMaximumValue());
103: assertEquals(292278993, test.year().getMaximumValueOverall());
104: }
105:
106: public void testPropertyAddToCopyYear() {
107: LocalDate test = new LocalDate(1972, 6, 9);
108: LocalDate copy = test.year().addToCopy(9);
109: check(test, 1972, 6, 9);
110: check(copy, 1981, 6, 9);
111:
112: copy = test.year().addToCopy(0);
113: check(copy, 1972, 6, 9);
114:
115: copy = test.year().addToCopy(292278993 - 1972);
116: check(copy, 292278993, 6, 9);
117:
118: try {
119: test.year().addToCopy(292278993 - 1972 + 1);
120: fail();
121: } catch (IllegalArgumentException ex) {
122: }
123: check(test, 1972, 6, 9);
124:
125: copy = test.year().addToCopy(-1972);
126: check(copy, 0, 6, 9);
127:
128: copy = test.year().addToCopy(-1973);
129: check(copy, -1, 6, 9);
130:
131: try {
132: test.year().addToCopy(-292275054 - 1972 - 1);
133: fail();
134: } catch (IllegalArgumentException ex) {
135: }
136: check(test, 1972, 6, 9);
137: }
138:
139: public void testPropertyAddWrapFieldToCopyYear() {
140: LocalDate test = new LocalDate(1972, 6, 9);
141: LocalDate copy = test.year().addWrapFieldToCopy(9);
142: check(test, 1972, 6, 9);
143: check(copy, 1981, 6, 9);
144:
145: copy = test.year().addWrapFieldToCopy(0);
146: check(copy, 1972, 6, 9);
147:
148: copy = test.year().addWrapFieldToCopy(292278993 - 1972 + 1);
149: check(copy, -292275054, 6, 9);
150:
151: copy = test.year().addWrapFieldToCopy(-292275054 - 1972 - 1);
152: check(copy, 292278993, 6, 9);
153: }
154:
155: public void testPropertySetCopyYear() {
156: LocalDate test = new LocalDate(1972, 6, 9);
157: LocalDate copy = test.year().setCopy(12);
158: check(test, 1972, 6, 9);
159: check(copy, 12, 6, 9);
160: }
161:
162: public void testPropertySetCopyTextYear() {
163: LocalDate test = new LocalDate(1972, 6, 9);
164: LocalDate copy = test.year().setCopy("12");
165: check(test, 1972, 6, 9);
166: check(copy, 12, 6, 9);
167: }
168:
169: public void testPropertyCompareToYear() {
170: LocalDate test1 = new LocalDate(TEST_TIME1);
171: LocalDate test2 = new LocalDate(TEST_TIME2);
172: assertEquals(true, test1.year().compareTo(test2) < 0);
173: assertEquals(true, test2.year().compareTo(test1) > 0);
174: assertEquals(true, test1.year().compareTo(test1) == 0);
175: try {
176: test1.year().compareTo((ReadablePartial) null);
177: fail();
178: } catch (IllegalArgumentException ex) {
179: }
180:
181: DateTime dt1 = new DateTime(TEST_TIME1);
182: DateTime dt2 = new DateTime(TEST_TIME2);
183: assertEquals(true, test1.year().compareTo(dt2) < 0);
184: assertEquals(true, test2.year().compareTo(dt1) > 0);
185: assertEquals(true, test1.year().compareTo(dt1) == 0);
186: try {
187: test1.year().compareTo((ReadableInstant) null);
188: fail();
189: } catch (IllegalArgumentException ex) {
190: }
191: }
192:
193: //-----------------------------------------------------------------------
194: public void testPropertyGetMonth() {
195: LocalDate test = new LocalDate(1972, 6, 9);
196: assertSame(test.getChronology().monthOfYear(), test
197: .monthOfYear().getField());
198: assertEquals("monthOfYear", test.monthOfYear().getName());
199: assertEquals("Property[monthOfYear]", test.monthOfYear()
200: .toString());
201: assertSame(test, test.monthOfYear().getLocalDate());
202: assertEquals(6, test.monthOfYear().get());
203: assertEquals("6", test.monthOfYear().getAsString());
204: assertEquals("June", test.monthOfYear().getAsText());
205: assertEquals("juin", test.monthOfYear()
206: .getAsText(Locale.FRENCH));
207: assertEquals("Jun", test.monthOfYear().getAsShortText());
208: assertEquals("juin", test.monthOfYear().getAsShortText(
209: Locale.FRENCH));
210: assertEquals(test.getChronology().months(), test.monthOfYear()
211: .getDurationField());
212: assertEquals(test.getChronology().years(), test.monthOfYear()
213: .getRangeDurationField());
214: assertEquals(9, test.monthOfYear().getMaximumTextLength(null));
215: assertEquals(3, test.monthOfYear().getMaximumShortTextLength(
216: null));
217: test = new LocalDate(1972, 7, 9);
218: assertEquals("juillet", test.monthOfYear().getAsText(
219: Locale.FRENCH));
220: assertEquals("juil.", test.monthOfYear().getAsShortText(
221: Locale.FRENCH));
222: }
223:
224: public void testPropertyGetMaxMinValuesMonth() {
225: LocalDate test = new LocalDate(1972, 6, 9);
226: assertEquals(1, test.monthOfYear().getMinimumValue());
227: assertEquals(1, test.monthOfYear().getMinimumValueOverall());
228: assertEquals(12, test.monthOfYear().getMaximumValue());
229: assertEquals(12, test.monthOfYear().getMaximumValueOverall());
230: }
231:
232: public void testPropertyAddToCopyMonth() {
233: LocalDate test = new LocalDate(1972, 6, 9);
234: LocalDate copy = test.monthOfYear().addToCopy(6);
235: check(test, 1972, 6, 9);
236: check(copy, 1972, 12, 9);
237:
238: copy = test.monthOfYear().addToCopy(7);
239: check(copy, 1973, 1, 9);
240:
241: copy = test.monthOfYear().addToCopy(-5);
242: check(copy, 1972, 1, 9);
243:
244: copy = test.monthOfYear().addToCopy(-6);
245: check(copy, 1971, 12, 9);
246:
247: test = new LocalDate(1972, 1, 31);
248: copy = test.monthOfYear().addToCopy(1);
249: check(copy, 1972, 2, 29);
250:
251: copy = test.monthOfYear().addToCopy(2);
252: check(copy, 1972, 3, 31);
253:
254: copy = test.monthOfYear().addToCopy(3);
255: check(copy, 1972, 4, 30);
256:
257: test = new LocalDate(1971, 1, 31);
258: copy = test.monthOfYear().addToCopy(1);
259: check(copy, 1971, 2, 28);
260: }
261:
262: public void testPropertyAddWrapFieldToCopyMonth() {
263: LocalDate test = new LocalDate(1972, 6, 9);
264: LocalDate copy = test.monthOfYear().addWrapFieldToCopy(4);
265: check(test, 1972, 6, 9);
266: check(copy, 1972, 10, 9);
267:
268: copy = test.monthOfYear().addWrapFieldToCopy(8);
269: check(copy, 1972, 2, 9);
270:
271: copy = test.monthOfYear().addWrapFieldToCopy(-8);
272: check(copy, 1972, 10, 9);
273:
274: test = new LocalDate(1972, 1, 31);
275: copy = test.monthOfYear().addWrapFieldToCopy(1);
276: check(copy, 1972, 2, 29);
277:
278: copy = test.monthOfYear().addWrapFieldToCopy(2);
279: check(copy, 1972, 3, 31);
280:
281: copy = test.monthOfYear().addWrapFieldToCopy(3);
282: check(copy, 1972, 4, 30);
283:
284: test = new LocalDate(1971, 1, 31);
285: copy = test.monthOfYear().addWrapFieldToCopy(1);
286: check(copy, 1971, 2, 28);
287: }
288:
289: public void testPropertySetCopyMonth() {
290: LocalDate test = new LocalDate(1972, 6, 9);
291: LocalDate copy = test.monthOfYear().setCopy(12);
292: check(test, 1972, 6, 9);
293: check(copy, 1972, 12, 9);
294:
295: test = new LocalDate(1972, 1, 31);
296: copy = test.monthOfYear().setCopy(2);
297: check(copy, 1972, 2, 29);
298:
299: try {
300: test.monthOfYear().setCopy(13);
301: fail();
302: } catch (IllegalArgumentException ex) {
303: }
304: try {
305: test.monthOfYear().setCopy(0);
306: fail();
307: } catch (IllegalArgumentException ex) {
308: }
309: }
310:
311: public void testPropertySetCopyTextMonth() {
312: LocalDate test = new LocalDate(1972, 6, 9);
313: LocalDate copy = test.monthOfYear().setCopy("12");
314: check(test, 1972, 6, 9);
315: check(copy, 1972, 12, 9);
316:
317: copy = test.monthOfYear().setCopy("December");
318: check(test, 1972, 6, 9);
319: check(copy, 1972, 12, 9);
320:
321: copy = test.monthOfYear().setCopy("Dec");
322: check(test, 1972, 6, 9);
323: check(copy, 1972, 12, 9);
324: }
325:
326: public void testPropertyCompareToMonth() {
327: LocalDate test1 = new LocalDate(TEST_TIME1);
328: LocalDate test2 = new LocalDate(TEST_TIME2);
329: assertEquals(true, test1.monthOfYear().compareTo(test2) < 0);
330: assertEquals(true, test2.monthOfYear().compareTo(test1) > 0);
331: assertEquals(true, test1.monthOfYear().compareTo(test1) == 0);
332: try {
333: test1.monthOfYear().compareTo((ReadablePartial) null);
334: fail();
335: } catch (IllegalArgumentException ex) {
336: }
337:
338: DateTime dt1 = new DateTime(TEST_TIME1);
339: DateTime dt2 = new DateTime(TEST_TIME2);
340: assertEquals(true, test1.monthOfYear().compareTo(dt2) < 0);
341: assertEquals(true, test2.monthOfYear().compareTo(dt1) > 0);
342: assertEquals(true, test1.monthOfYear().compareTo(dt1) == 0);
343: try {
344: test1.monthOfYear().compareTo((ReadableInstant) null);
345: fail();
346: } catch (IllegalArgumentException ex) {
347: }
348: }
349:
350: //-----------------------------------------------------------------------
351: public void testPropertyGetDay() {
352: LocalDate test = new LocalDate(1972, 6, 9);
353: assertSame(test.getChronology().dayOfMonth(), test.dayOfMonth()
354: .getField());
355: assertEquals("dayOfMonth", test.dayOfMonth().getName());
356: assertEquals("Property[dayOfMonth]", test.dayOfMonth()
357: .toString());
358: assertSame(test, test.dayOfMonth().getLocalDate());
359: assertEquals(9, test.dayOfMonth().get());
360: assertEquals("9", test.dayOfMonth().getAsString());
361: assertEquals("9", test.dayOfMonth().getAsText());
362: assertEquals("9", test.dayOfMonth().getAsText(Locale.FRENCH));
363: assertEquals("9", test.dayOfMonth().getAsShortText());
364: assertEquals("9", test.dayOfMonth().getAsShortText(
365: Locale.FRENCH));
366: assertEquals(test.getChronology().days(), test.dayOfMonth()
367: .getDurationField());
368: assertEquals(test.getChronology().months(), test.dayOfMonth()
369: .getRangeDurationField());
370: assertEquals(2, test.dayOfMonth().getMaximumTextLength(null));
371: assertEquals(2, test.dayOfMonth().getMaximumShortTextLength(
372: null));
373: }
374:
375: public void testPropertyGetMaxMinValuesDay() {
376: LocalDate test = new LocalDate(1972, 6, 9);
377: assertEquals(1, test.dayOfMonth().getMinimumValue());
378: assertEquals(1, test.dayOfMonth().getMinimumValueOverall());
379: assertEquals(30, test.dayOfMonth().getMaximumValue());
380: assertEquals(31, test.dayOfMonth().getMaximumValueOverall());
381: test = new LocalDate(1972, 7, 9);
382: assertEquals(31, test.dayOfMonth().getMaximumValue());
383: test = new LocalDate(1972, 2, 9);
384: assertEquals(29, test.dayOfMonth().getMaximumValue());
385: test = new LocalDate(1971, 2, 9);
386: assertEquals(28, test.dayOfMonth().getMaximumValue());
387: }
388:
389: public void testPropertyAddToCopyDay() {
390: LocalDate test = new LocalDate(1972, 6, 9);
391: LocalDate copy = test.dayOfMonth().addToCopy(9);
392: check(test, 1972, 6, 9);
393: check(copy, 1972, 6, 18);
394:
395: copy = test.dayOfMonth().addToCopy(21);
396: check(copy, 1972, 6, 30);
397:
398: copy = test.dayOfMonth().addToCopy(22);
399: check(copy, 1972, 7, 1);
400:
401: copy = test.dayOfMonth().addToCopy(22 + 30);
402: check(copy, 1972, 7, 31);
403:
404: copy = test.dayOfMonth().addToCopy(22 + 31);
405: check(copy, 1972, 8, 1);
406:
407: copy = test.dayOfMonth().addToCopy(
408: 21 + 31 + 31 + 30 + 31 + 30 + 31);
409: check(copy, 1972, 12, 31);
410:
411: copy = test.dayOfMonth().addToCopy(
412: 22 + 31 + 31 + 30 + 31 + 30 + 31);
413: check(copy, 1973, 1, 1);
414:
415: copy = test.dayOfMonth().addToCopy(-8);
416: check(copy, 1972, 6, 1);
417:
418: copy = test.dayOfMonth().addToCopy(-9);
419: check(copy, 1972, 5, 31);
420:
421: copy = test.dayOfMonth().addToCopy(-8 - 31 - 30 - 31 - 29 - 31);
422: check(copy, 1972, 1, 1);
423:
424: copy = test.dayOfMonth().addToCopy(-9 - 31 - 30 - 31 - 29 - 31);
425: check(copy, 1971, 12, 31);
426: }
427:
428: public void testPropertyAddWrapFieldToCopyDay() {
429: LocalDate test = new LocalDate(1972, 6, 9);
430: LocalDate copy = test.dayOfMonth().addWrapFieldToCopy(21);
431: check(test, 1972, 6, 9);
432: check(copy, 1972, 6, 30);
433:
434: copy = test.dayOfMonth().addWrapFieldToCopy(22);
435: check(copy, 1972, 6, 1);
436:
437: copy = test.dayOfMonth().addWrapFieldToCopy(-12);
438: check(copy, 1972, 6, 27);
439:
440: test = new LocalDate(1972, 7, 9);
441: copy = test.dayOfMonth().addWrapFieldToCopy(21);
442: check(copy, 1972, 7, 30);
443:
444: copy = test.dayOfMonth().addWrapFieldToCopy(22);
445: check(copy, 1972, 7, 31);
446:
447: copy = test.dayOfMonth().addWrapFieldToCopy(23);
448: check(copy, 1972, 7, 1);
449:
450: copy = test.dayOfMonth().addWrapFieldToCopy(-12);
451: check(copy, 1972, 7, 28);
452: }
453:
454: public void testPropertySetCopyDay() {
455: LocalDate test = new LocalDate(1972, 6, 9);
456: LocalDate copy = test.dayOfMonth().setCopy(12);
457: check(test, 1972, 6, 9);
458: check(copy, 1972, 6, 12);
459:
460: try {
461: test.dayOfMonth().setCopy(31);
462: fail();
463: } catch (IllegalArgumentException ex) {
464: }
465: try {
466: test.dayOfMonth().setCopy(0);
467: fail();
468: } catch (IllegalArgumentException ex) {
469: }
470: }
471:
472: public void testPropertySetCopyTextDay() {
473: LocalDate test = new LocalDate(1972, 6, 9);
474: LocalDate copy = test.dayOfMonth().setCopy("12");
475: check(test, 1972, 6, 9);
476: check(copy, 1972, 6, 12);
477: }
478:
479: public void testPropertyWithMaximumValueDayOfMonth() {
480: LocalDate test = new LocalDate(1972, 6, 9);
481: LocalDate copy = test.dayOfMonth().withMaximumValue();
482: check(test, 1972, 6, 9);
483: check(copy, 1972, 6, 30);
484: }
485:
486: public void testPropertyWithMinimumValueDayOfMonth() {
487: LocalDate test = new LocalDate(1972, 6, 9);
488: LocalDate copy = test.dayOfMonth().withMinimumValue();
489: check(test, 1972, 6, 9);
490: check(copy, 1972, 6, 1);
491: }
492:
493: public void testPropertyCompareToDay() {
494: LocalDate test1 = new LocalDate(TEST_TIME1);
495: LocalDate test2 = new LocalDate(TEST_TIME2);
496: assertEquals(true, test1.dayOfMonth().compareTo(test2) < 0);
497: assertEquals(true, test2.dayOfMonth().compareTo(test1) > 0);
498: assertEquals(true, test1.dayOfMonth().compareTo(test1) == 0);
499: try {
500: test1.dayOfMonth().compareTo((ReadablePartial) null);
501: fail();
502: } catch (IllegalArgumentException ex) {
503: }
504:
505: DateTime dt1 = new DateTime(TEST_TIME1);
506: DateTime dt2 = new DateTime(TEST_TIME2);
507: assertEquals(true, test1.dayOfMonth().compareTo(dt2) < 0);
508: assertEquals(true, test2.dayOfMonth().compareTo(dt1) > 0);
509: assertEquals(true, test1.dayOfMonth().compareTo(dt1) == 0);
510: try {
511: test1.dayOfMonth().compareTo((ReadableInstant) null);
512: fail();
513: } catch (IllegalArgumentException ex) {
514: }
515: }
516:
517: public void testPropertyEquals() {
518: LocalDate test1 = new LocalDate(2005, 11, 8);
519: LocalDate test2 = new LocalDate(2005, 11, 9);
520: LocalDate test3 = new LocalDate(2005, 11, 8, CopticChronology
521: .getInstanceUTC());
522: assertEquals(false, test1.dayOfMonth().equals(test1.year()));
523: assertEquals(false, test1.dayOfMonth().equals(
524: test1.monthOfYear()));
525: assertEquals(true, test1.dayOfMonth()
526: .equals(test1.dayOfMonth()));
527: assertEquals(false, test1.dayOfMonth().equals(test2.year()));
528: assertEquals(false, test1.dayOfMonth().equals(
529: test2.monthOfYear()));
530: assertEquals(false, test1.dayOfMonth().equals(
531: test2.dayOfMonth()));
532:
533: assertEquals(false, test1.monthOfYear().equals(test1.year()));
534: assertEquals(true, test1.monthOfYear().equals(
535: test1.monthOfYear()));
536: assertEquals(false, test1.monthOfYear().equals(
537: test1.dayOfMonth()));
538: assertEquals(false, test1.monthOfYear().equals(test2.year()));
539: assertEquals(true, test1.monthOfYear().equals(
540: test2.monthOfYear()));
541: assertEquals(false, test1.monthOfYear().equals(
542: test2.dayOfMonth()));
543:
544: assertEquals(false, test1.dayOfMonth().equals(null));
545: assertEquals(false, test1.dayOfMonth().equals("any"));
546:
547: // chrono
548: assertEquals(false, test1.dayOfMonth().equals(
549: test3.dayOfMonth()));
550: }
551:
552: public void testPropertyHashCode() {
553: LocalDate test1 = new LocalDate(2005, 11, 8);
554: LocalDate test2 = new LocalDate(2005, 11, 9);
555: assertEquals(true, test1.dayOfMonth().hashCode() == test1
556: .dayOfMonth().hashCode());
557: assertEquals(false, test1.dayOfMonth().hashCode() == test2
558: .dayOfMonth().hashCode());
559: assertEquals(true, test1.monthOfYear().hashCode() == test1
560: .monthOfYear().hashCode());
561: assertEquals(true, test1.monthOfYear().hashCode() == test2
562: .monthOfYear().hashCode());
563: }
564:
565: public void testPropertyEqualsHashCodeLenient() {
566: LocalDate test1 = new LocalDate(1970, 6, 9, LenientChronology
567: .getInstance(COPTIC_PARIS));
568: LocalDate test2 = new LocalDate(1970, 6, 9, LenientChronology
569: .getInstance(COPTIC_PARIS));
570: assertEquals(true, test1.dayOfMonth()
571: .equals(test2.dayOfMonth()));
572: assertEquals(true, test2.dayOfMonth()
573: .equals(test1.dayOfMonth()));
574: assertEquals(true, test1.dayOfMonth()
575: .equals(test1.dayOfMonth()));
576: assertEquals(true, test2.dayOfMonth()
577: .equals(test2.dayOfMonth()));
578: assertEquals(true, test1.dayOfMonth().hashCode() == test2
579: .dayOfMonth().hashCode());
580: assertEquals(true, test1.dayOfMonth().hashCode() == test1
581: .dayOfMonth().hashCode());
582: assertEquals(true, test2.dayOfMonth().hashCode() == test2
583: .dayOfMonth().hashCode());
584: }
585:
586: public void testPropertyEqualsHashCodeStrict() {
587: LocalDate test1 = new LocalDate(1970, 6, 9, StrictChronology
588: .getInstance(COPTIC_PARIS));
589: LocalDate test2 = new LocalDate(1970, 6, 9, StrictChronology
590: .getInstance(COPTIC_PARIS));
591: assertEquals(true, test1.dayOfMonth()
592: .equals(test2.dayOfMonth()));
593: assertEquals(true, test2.dayOfMonth()
594: .equals(test1.dayOfMonth()));
595: assertEquals(true, test1.dayOfMonth()
596: .equals(test1.dayOfMonth()));
597: assertEquals(true, test2.dayOfMonth()
598: .equals(test2.dayOfMonth()));
599: assertEquals(true, test1.dayOfMonth().hashCode() == test2
600: .dayOfMonth().hashCode());
601: assertEquals(true, test1.dayOfMonth().hashCode() == test1
602: .dayOfMonth().hashCode());
603: assertEquals(true, test2.dayOfMonth().hashCode() == test2
604: .dayOfMonth().hashCode());
605: }
606:
607: //-----------------------------------------------------------------------
608: private void check(LocalDate test, int year, int month, int day) {
609: assertEquals(year, test.getYear());
610: assertEquals(month, test.getMonthOfYear());
611: assertEquals(day, test.getDayOfMonth());
612: }
613: }
|