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