KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.util.TimeZone JavaDoc;
20
21 import junit.framework.TestCase;
22 import junit.framework.TestSuite;
23
24 import org.joda.time.chrono.BuddhistChronology;
25 import org.joda.time.chrono.GregorianChronology;
26 import org.joda.time.chrono.ISOChronology;
27
28 /**
29  * This class is a JUnit test for MutableDateTime.
30  *
31  * @author Stephen Colebourne
32  */

33 public class TestMutableDateTime_Sets extends TestCase {
34     // Test in 2002/03 as time zones are more well known
35
// (before the late 90's they were all over the place)
36

37     private static final DateTimeZone PARIS = DateTimeZone.forID("Europe/Paris");
38     private static final DateTimeZone LONDON = DateTimeZone.forID("Europe/London");
39     
40     long y2002days = 365 + 365 + 366 + 365 + 365 + 365 + 366 + 365 + 365 + 365 +
41                      366 + 365 + 365 + 365 + 366 + 365 + 365 + 365 + 366 + 365 +
42                      365 + 365 + 366 + 365 + 365 + 365 + 366 + 365 + 365 + 365 +
43                      366 + 365;
44     long y2003days = 365 + 365 + 366 + 365 + 365 + 365 + 366 + 365 + 365 + 365 +
45                      366 + 365 + 365 + 365 + 366 + 365 + 365 + 365 + 366 + 365 +
46                      365 + 365 + 366 + 365 + 365 + 365 + 366 + 365 + 365 + 365 +
47                      366 + 365 + 365;
48     
49     // 2002-06-09
50
private long TEST_TIME_NOW =
51             (y2002days + 31L + 28L + 31L + 30L + 31L + 9L -1L) * DateTimeConstants.MILLIS_PER_DAY;
52             
53     // 2002-04-05
54
private long TEST_TIME1 =
55             (y2002days + 31L + 28L + 31L + 5L -1L) * DateTimeConstants.MILLIS_PER_DAY
56             + 12L * DateTimeConstants.MILLIS_PER_HOUR
57             + 24L * DateTimeConstants.MILLIS_PER_MINUTE;
58         
59     // 2003-05-06
60
private long TEST_TIME2 =
61             (y2003days + 31L + 28L + 31L + 30L + 6L -1L) * DateTimeConstants.MILLIS_PER_DAY
62             + 14L * DateTimeConstants.MILLIS_PER_HOUR
63             + 28L * DateTimeConstants.MILLIS_PER_MINUTE;
64     
65     private DateTimeZone originalDateTimeZone = null;
66     private TimeZone JavaDoc originalTimeZone = null;
67     private Locale JavaDoc originalLocale = null;
68
69     public static void main(String JavaDoc[] args) {
70         junit.textui.TestRunner.run(suite());
71     }
72
73     public static TestSuite suite() {
74         return new TestSuite(TestMutableDateTime_Sets.class);
75     }
76
77     public TestMutableDateTime_Sets(String JavaDoc name) {
78         super(name);
79     }
80
81     protected void setUp() throws Exception JavaDoc {
82         DateTimeUtils.setCurrentMillisFixed(TEST_TIME_NOW);
83         originalDateTimeZone = DateTimeZone.getDefault();
84         originalTimeZone = TimeZone.getDefault();
85         originalLocale = Locale.getDefault();
86         DateTimeZone.setDefault(LONDON);
87         TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
88         Locale.setDefault(Locale.UK);
89     }
90
91     protected void tearDown() throws Exception JavaDoc {
92         DateTimeUtils.setCurrentMillisSystem();
93         DateTimeZone.setDefault(originalDateTimeZone);
94         TimeZone.setDefault(originalTimeZone);
95         Locale.setDefault(originalLocale);
96         originalDateTimeZone = null;
97         originalTimeZone = null;
98         originalLocale = null;
99     }
100
101     //-----------------------------------------------------------------------
102
public void testTest() {
103         assertEquals("2002-06-09T00:00:00.000Z", new Instant(TEST_TIME_NOW).toString());
104         assertEquals("2002-04-05T12:24:00.000Z", new Instant(TEST_TIME1).toString());
105         assertEquals("2003-05-06T14:28:00.000Z", new Instant(TEST_TIME2).toString());
106     }
107
108     //-----------------------------------------------------------------------
109
public void testSetMillis_long1() {
110         MutableDateTime test = new MutableDateTime(TEST_TIME1);
111         test.setMillis(TEST_TIME2);
112         assertEquals(TEST_TIME2, test.getMillis());
113         assertEquals(ISOChronology.getInstance(), test.getChronology());
114     }
115
116     //-----------------------------------------------------------------------
117
public void testSetChronology_Chronology1() {
118         MutableDateTime test = new MutableDateTime(TEST_TIME1);
119         test.setChronology(GregorianChronology.getInstance(PARIS));
120         assertEquals(TEST_TIME1, test.getMillis());
121         assertEquals(GregorianChronology.getInstance(PARIS), test.getChronology());
122     }
123
124     public void testSetChronology_Chronology2() {
125         MutableDateTime test = new MutableDateTime(TEST_TIME1);
126         test.setChronology(null);
127         assertEquals(TEST_TIME1, test.getMillis());
128         assertEquals(ISOChronology.getInstance(), test.getChronology());
129     }
130
131     //-----------------------------------------------------------------------
132
public void testSetZone_DateTimeZone1() {
133         MutableDateTime test = new MutableDateTime(TEST_TIME1);
134         test.setZone(PARIS);
135         assertEquals(TEST_TIME1, test.getMillis());
136         assertEquals(ISOChronology.getInstance(PARIS), test.getChronology());
137     }
138
139     public void testSetZone_DateTimeZone2() {
140         MutableDateTime test = new MutableDateTime(TEST_TIME1);
141         test.setZone(null);
142         assertEquals(TEST_TIME1, test.getMillis());
143         assertEquals(ISOChronology.getInstance(), test.getChronology());
144     }
145
146     //-----------------------------------------------------------------------
147
public void testSetZoneRetainFields_DateTimeZone1() {
148         MutableDateTime test = new MutableDateTime(TEST_TIME1);
149         test.setZoneRetainFields(PARIS);
150         assertEquals(TEST_TIME1 - DateTimeConstants.MILLIS_PER_HOUR, test.getMillis());
151         assertEquals(ISOChronology.getInstance(PARIS), test.getChronology());
152     }
153
154     public void testSetZoneRetainFields_DateTimeZone2() {
155         MutableDateTime test = new MutableDateTime(TEST_TIME1);
156         test.setZoneRetainFields(null);
157         assertEquals(TEST_TIME1, test.getMillis());
158         assertEquals(ISOChronology.getInstance(), test.getChronology());
159     }
160
161     public void testSetZoneRetainFields_DateTimeZone3() {
162         MutableDateTime test = new MutableDateTime(TEST_TIME1, GregorianChronology.getInstance(PARIS));
163         test.setZoneRetainFields(null);
164         assertEquals(TEST_TIME1 + DateTimeConstants.MILLIS_PER_HOUR, test.getMillis());
165         assertEquals(GregorianChronology.getInstance(), test.getChronology());
166     }
167
168     public void testSetZoneRetainFields_DateTimeZone4() {
169         Chronology chrono = new MockNullZoneChronology();
170         MutableDateTime test = new MutableDateTime(TEST_TIME1, chrono);
171         test.setZoneRetainFields(PARIS);
172         assertEquals(TEST_TIME1 - DateTimeConstants.MILLIS_PER_HOUR, test.getMillis());
173         assertSame(chrono, test.getChronology());
174     }
175
176     //-----------------------------------------------------------------------
177
public void testSetMillis_RI1() {
178         MutableDateTime test = new MutableDateTime(TEST_TIME1, BuddhistChronology.getInstance());
179         test.setMillis(new Instant(TEST_TIME2));
180         assertEquals(TEST_TIME2, test.getMillis());
181         assertEquals(BuddhistChronology.getInstance(), test.getChronology());
182     }
183
184     public void testSetMillis_RI2() {
185         MutableDateTime test = new MutableDateTime(TEST_TIME1, BuddhistChronology.getInstance());
186         test.setMillis(null);
187         assertEquals(TEST_TIME_NOW, test.getMillis());
188         assertEquals(BuddhistChronology.getInstance(), test.getChronology());
189     }
190
191     //-----------------------------------------------------------------------
192
public void testSet_DateTimeFieldType_int1() {
193         MutableDateTime test = new MutableDateTime(TEST_TIME1);
194         test.set(DateTimeFieldType.year(), 2010);
195         assertEquals(2010, test.getYear());
196     }
197
198     public void testSet_DateTimeFieldType_int2() {
199         MutableDateTime test = new MutableDateTime(TEST_TIME1);
200         try {
201             test.set(null, 0);
202             fail();
203         } catch (IllegalArgumentException JavaDoc ex) {}
204         assertEquals(TEST_TIME1, test.getMillis());
205     }
206
207     public void testSet_DateTimeFieldType_int3() {
208         MutableDateTime test = new MutableDateTime(TEST_TIME1);
209         try {
210             test.set(DateTimeFieldType.monthOfYear(), 13);
211             fail();
212         } catch (IllegalArgumentException JavaDoc ex) {}
213         assertEquals(TEST_TIME1, test.getMillis());
214     }
215
216     //-----------------------------------------------------------------------
217
public void testSetDate_int_int_int1() {
218         MutableDateTime test = new MutableDateTime(2002, 6, 9, 12, 24, 48, 501);
219         test.setDate(2010, 12, 3);
220         assertEquals(2010, test.getYear());
221         assertEquals(12, test.getMonthOfYear());
222         assertEquals(3, test.getDayOfMonth());
223         assertEquals(12, test.getHourOfDay());
224         assertEquals(24, test.getMinuteOfHour());
225         assertEquals(48, test.getSecondOfMinute());
226         assertEquals(501, test.getMillisOfSecond());
227     }
228
229     public void testSetDate_int_int_int2() {
230         MutableDateTime test = new MutableDateTime(TEST_TIME1);
231         try {
232             test.setDate(2010, 13, 3);
233             fail();
234         } catch (IllegalArgumentException JavaDoc ex) {}
235         assertEquals(TEST_TIME1, test.getMillis());
236     }
237
238     //-----------------------------------------------------------------------
239
public void testSetDate_long1() {
240         long setter = new DateTime(2010, 12, 3, 5, 7, 9, 501).getMillis();
241         MutableDateTime test = new MutableDateTime(2002, 6, 9, 12, 24, 48, 501);
242         test.setDate(setter);
243         assertEquals(2010, test.getYear());
244         assertEquals(12, test.getMonthOfYear());
245         assertEquals(3, test.getDayOfMonth());
246         assertEquals(12, test.getHourOfDay());
247         assertEquals(24, test.getMinuteOfHour());
248         assertEquals(48, test.getSecondOfMinute());
249         assertEquals(501, test.getMillisOfSecond());
250     }
251
252     //-----------------------------------------------------------------------
253
public void testSetDate_RI1() {
254         DateTime setter = new DateTime(2010, 12, 3, 5, 7, 9, 501);
255         MutableDateTime test = new MutableDateTime(2002, 6, 9, 12, 24, 48, 501);
256         test.setDate(setter);
257         assertEquals(2010, test.getYear());
258         assertEquals(12, test.getMonthOfYear());
259         assertEquals(3, test.getDayOfMonth());
260         assertEquals(12, test.getHourOfDay());
261         assertEquals(24, test.getMinuteOfHour());
262         assertEquals(48, test.getSecondOfMinute());
263         assertEquals(501, test.getMillisOfSecond());
264     }
265
266     public void testSetDate_RI2() {
267         MutableDateTime test = new MutableDateTime(2010, 7, 8, 12, 24, 48, 501);
268         test.setDate(null); // sets to TEST_TIME_NOW
269
assertEquals(2002, test.getYear());
270         assertEquals(6, test.getMonthOfYear());
271         assertEquals(9, test.getDayOfMonth());
272         assertEquals(12, test.getHourOfDay());
273         assertEquals(24, test.getMinuteOfHour());
274         assertEquals(48, test.getSecondOfMinute());
275         assertEquals(501, test.getMillisOfSecond());
276     }
277
278     //-----------------------------------------------------------------------
279
public void testSetTime_int_int_int_int1() {
280         MutableDateTime test = new MutableDateTime(2002, 6, 9, 12, 24, 48, 501);
281         test.setTime(5, 6, 7, 8);
282         assertEquals(2002, test.getYear());
283         assertEquals(6, test.getMonthOfYear());
284         assertEquals(9, test.getDayOfMonth());
285         assertEquals(5, test.getHourOfDay());
286         assertEquals(6, test.getMinuteOfHour());
287         assertEquals(7, test.getSecondOfMinute());
288         assertEquals(8, test.getMillisOfSecond());
289     }
290
291     public void testSetTime_int_int_int2() {
292         MutableDateTime test = new MutableDateTime(TEST_TIME1);
293         try {
294             test.setTime(60, 6, 7, 8);
295             fail();
296         } catch (IllegalArgumentException JavaDoc ex) {}
297         assertEquals(TEST_TIME1, test.getMillis());
298     }
299
300     //-----------------------------------------------------------------------
301
public void testSetTime_long1() {
302         long setter = new DateTime(2010, 12, 3, 5, 7, 9, 11).getMillis();
303         MutableDateTime test = new MutableDateTime(2002, 6, 9, 12, 24, 48, 501);
304         test.setTime(setter);
305         assertEquals(2002, test.getYear());
306         assertEquals(6, test.getMonthOfYear());
307         assertEquals(9, test.getDayOfMonth());
308         assertEquals(5, test.getHourOfDay());
309         assertEquals(7, test.getMinuteOfHour());
310         assertEquals(9, test.getSecondOfMinute());
311         assertEquals(11, test.getMillisOfSecond());
312     }
313
314     //-----------------------------------------------------------------------
315
public void testSetTime_RI1() {
316         DateTime setter = new DateTime(2010, 12, 3, 5, 7, 9, 11);
317         MutableDateTime test = new MutableDateTime(2002, 6, 9, 12, 24, 48, 501);
318         test.setTime(setter);
319         assertEquals(2002, test.getYear());
320         assertEquals(6, test.getMonthOfYear());
321         assertEquals(9, test.getDayOfMonth());
322         assertEquals(5, test.getHourOfDay());
323         assertEquals(7, test.getMinuteOfHour());
324         assertEquals(9, test.getSecondOfMinute());
325         assertEquals(11, test.getMillisOfSecond());
326     }
327
328     public void testSetTime_RI2() {
329         MutableDateTime test = new MutableDateTime(2010, 7, 8, 12, 24, 48, 501);
330         test.setTime(null); // sets to TEST_TIME_NOW, which has no time part
331
assertEquals(2010, test.getYear());
332         assertEquals(7, test.getMonthOfYear());
333         assertEquals(8, test.getDayOfMonth());
334         assertEquals(new DateTime(TEST_TIME_NOW).getHourOfDay(), test.getHourOfDay());
335         assertEquals(new DateTime(TEST_TIME_NOW).getMinuteOfHour(), test.getMinuteOfHour());
336         assertEquals(new DateTime(TEST_TIME_NOW).getSecondOfMinute(), test.getSecondOfMinute());
337         assertEquals(new DateTime(TEST_TIME_NOW).getMillisOfSecond(), test.getMillisOfSecond());
338     }
339
340     public void testSetTime_Object3() {
341         DateTime temp = new DateTime(2010, 12, 3, 5, 7, 9, 11);
342         DateTime setter = new DateTime(temp.getMillis(), new MockNullZoneChronology());
343         MutableDateTime test = new MutableDateTime(2002, 6, 9, 12, 24, 48, 501);
344         test.setTime(setter);
345         assertEquals(2002, test.getYear());
346         assertEquals(6, test.getMonthOfYear());
347         assertEquals(9, test.getDayOfMonth());
348         assertEquals(5, test.getHourOfDay());
349         assertEquals(7, test.getMinuteOfHour());
350         assertEquals(9, test.getSecondOfMinute());
351         assertEquals(11, test.getMillisOfSecond());
352     }
353
354     //-----------------------------------------------------------------------
355
public void testSetDateTime_int_int_int_int_int_int_int1() {
356         MutableDateTime test = new MutableDateTime(2002, 6, 9, 12, 24, 48, 501);
357         test.setDateTime(2010, 12, 3, 5, 6, 7, 8);
358         assertEquals(2010, test.getYear());
359         assertEquals(12, test.getMonthOfYear());
360         assertEquals(3, test.getDayOfMonth());
361         assertEquals(5, test.getHourOfDay());
362         assertEquals(6, test.getMinuteOfHour());
363         assertEquals(7, test.getSecondOfMinute());
364         assertEquals(8, test.getMillisOfSecond());
365     }
366     
367     public void testSetDateTime_int_int_int_int_int_int_int2() {
368         MutableDateTime test = new MutableDateTime(TEST_TIME1);
369         try {
370             test.setDateTime(2010, 13, 3, 5, 6, 7, 8);
371             fail();
372         } catch (IllegalArgumentException JavaDoc ex) {
373         }
374         assertEquals(TEST_TIME1, test.getMillis());
375     }
376
377     //-----------------------------------------------------------------------
378
public void testSetYear_int1() {
379         MutableDateTime test = new MutableDateTime(2002, 6, 9, 5, 6, 7, 8);
380         test.setYear(2010);
381         assertEquals("2010-06-09T05:06:07.008+01:00", test.toString());
382     }
383
384     //-----------------------------------------------------------------------
385
public void testSetMonthOfYear_int1() {
386         MutableDateTime test = new MutableDateTime(2002, 6, 9, 5, 6, 7, 8);
387         test.setMonthOfYear(12);
388         assertEquals("2002-12-09T05:06:07.008Z", test.toString());
389     }
390
391     public void testSetMonthOfYear_int2() {
392         MutableDateTime test = new MutableDateTime(2002, 6, 9, 5, 6, 7, 8);
393         try {
394             test.setMonthOfYear(13);
395             fail();
396         } catch (IllegalArgumentException JavaDoc ex) {}
397         assertEquals("2002-06-09T05:06:07.008+01:00", test.toString());
398     }
399
400     //-----------------------------------------------------------------------
401
public void testSetDayOfMonth_int1() {
402         MutableDateTime test = new MutableDateTime(2002, 6, 9, 5, 6, 7, 8);
403         test.setDayOfMonth(17);
404         assertEquals("2002-06-17T05:06:07.008+01:00", test.toString());
405     }
406
407     public void testSetDayOfMonth_int2() {
408         MutableDateTime test = new MutableDateTime(2002, 6, 9, 5, 6, 7, 8);
409         try {
410             test.setDayOfMonth(31);
411             fail();
412         } catch (IllegalArgumentException JavaDoc ex) {}
413         assertEquals("2002-06-09T05:06:07.008+01:00", test.toString());
414     }
415
416     //-----------------------------------------------------------------------
417
public void testSetDayOfYear_int1() {
418         MutableDateTime test = new MutableDateTime(2002, 6, 9, 5, 6, 7, 8);
419         test.setDayOfYear(3);
420         assertEquals("2002-01-03T05:06:07.008Z", test.toString());
421     }
422
423     public void testSetDayOfYear_int2() {
424         MutableDateTime test = new MutableDateTime(2002, 6, 9, 5, 6, 7, 8);
425         try {
426             test.setDayOfYear(366);
427             fail();
428         } catch (IllegalArgumentException JavaDoc ex) {}
429         assertEquals("2002-06-09T05:06:07.008+01:00", test.toString());
430     }
431
432     //-----------------------------------------------------------------------
433
public void testSetWeekyear_int1() {
434         MutableDateTime test = new MutableDateTime(2002, 6, 9, 5, 6, 7, 8);
435         test.setWeekyear(2001);
436         assertEquals("2001-06-10T05:06:07.008+01:00", test.toString());
437     }
438
439     //-----------------------------------------------------------------------
440
public void testSetWeekOfWeekyear_int1() {
441         MutableDateTime test = new MutableDateTime(2002, 6, 9, 5, 6, 7, 8);
442         test.setWeekOfWeekyear(2);
443         assertEquals("2002-01-13T05:06:07.008Z", test.toString());
444     }
445
446     public void testSetWeekOfWeekyear_int2() {
447         MutableDateTime test = new MutableDateTime(2002, 6, 9, 5, 6, 7, 8);
448         try {
449             test.setWeekOfWeekyear(53);
450             fail();
451         } catch (IllegalArgumentException JavaDoc ex) {}
452         assertEquals("2002-06-09T05:06:07.008+01:00", test.toString());
453     }
454
455     //-----------------------------------------------------------------------
456
public void testSetDayOfWeek_int1() {
457         MutableDateTime test = new MutableDateTime(2002, 6, 9, 5, 6, 7, 8);
458         test.setDayOfWeek(5);
459         assertEquals("2002-06-07T05:06:07.008+01:00", test.toString());
460     }
461
462     public void testSetDayOfWeek_int2() {
463         MutableDateTime test = new MutableDateTime(2002, 6, 9, 5, 6, 7, 8);
464         try {
465             test.setDayOfWeek(8);
466             fail();
467         } catch (IllegalArgumentException JavaDoc ex) {}
468         assertEquals("2002-06-09T05:06:07.008+01:00", test.toString());
469     }
470
471     //-----------------------------------------------------------------------
472
public void testSetHourOfDay_int1() {
473         MutableDateTime test = new MutableDateTime(2002, 6, 9, 5, 6, 7, 8);
474         test.setHourOfDay(13);
475         assertEquals("2002-06-09T13:06:07.008+01:00", test.toString());
476     }
477
478     public void testSetHourOfDay_int2() {
479         MutableDateTime test = new MutableDateTime(2002, 6, 9, 5, 6, 7, 8);
480         try {
481             test.setHourOfDay(24);
482             fail();
483         } catch (IllegalArgumentException JavaDoc ex) {}
484         assertEquals("2002-06-09T05:06:07.008+01:00", test.toString());
485     }
486
487     //-----------------------------------------------------------------------
488
public void testSetMinuteOfHour_int1() {
489         MutableDateTime test = new MutableDateTime(2002, 6, 9, 5, 6, 7, 8);
490         test.setMinuteOfHour(13);
491         assertEquals("2002-06-09T05:13:07.008+01:00", test.toString());
492     }
493
494     public void testSetMinuteOfHour_int2() {
495         MutableDateTime test = new MutableDateTime(2002, 6, 9, 5, 6, 7, 8);
496         try {
497             test.setMinuteOfHour(60);
498             fail();
499         } catch (IllegalArgumentException JavaDoc ex) {}
500         assertEquals("2002-06-09T05:06:07.008+01:00", test.toString());
501     }
502
503     //-----------------------------------------------------------------------
504
public void testSetMinuteOfDay_int1() {
505         MutableDateTime test = new MutableDateTime(2002, 6, 9, 5, 6, 7, 8);
506         test.setMinuteOfDay(13);
507         assertEquals("2002-06-09T00:13:07.008+01:00", test.toString());
508     }
509
510     public void testSetMinuteOfDay_int2() {
511         MutableDateTime test = new MutableDateTime(2002, 6, 9, 5, 6, 7, 8);
512         try {
513             test.setMinuteOfDay(24 * 60);
514             fail();
515         } catch (IllegalArgumentException JavaDoc ex) {}
516         assertEquals("2002-06-09T05:06:07.008+01:00", test.toString());
517     }
518
519     //-----------------------------------------------------------------------
520
public void testSetSecondOfMinute_int1() {
521         MutableDateTime test = new MutableDateTime(2002, 6, 9, 5, 6, 7, 8);
522         test.setSecondOfMinute(13);
523         assertEquals("2002-06-09T05:06:13.008+01:00", test.toString());
524     }
525
526     public void testSetSecondOfMinute_int2() {
527         MutableDateTime test = new MutableDateTime(2002, 6, 9, 5, 6, 7, 8);
528         try {
529             test.setSecondOfMinute(60);
530             fail();
531         } catch (IllegalArgumentException JavaDoc ex) {}
532         assertEquals("2002-06-09T05:06:07.008+01:00", test.toString());
533     }
534
535     //-----------------------------------------------------------------------
536
public void testSetSecondOfDay_int1() {
537         MutableDateTime test = new MutableDateTime(2002, 6, 9, 5, 6, 7, 8);
538         test.setSecondOfDay(13);
539         assertEquals("2002-06-09T00:00:13.008+01:00", test.toString());
540     }
541
542     public void testSetSecondOfDay_int2() {
543         MutableDateTime test = new MutableDateTime(2002, 6, 9, 5, 6, 7, 8);
544         try {
545             test.setSecondOfDay(24 * 60 * 60);
546             fail();
547         } catch (IllegalArgumentException JavaDoc ex) {}
548         assertEquals("2002-06-09T05:06:07.008+01:00", test.toString());
549     }
550
551     //-----------------------------------------------------------------------
552
public void testSetMilliOfSecond_int1() {
553         MutableDateTime test = new MutableDateTime(2002, 6, 9, 5, 6, 7, 8);
554         test.setMillisOfSecond(13);
555         assertEquals("2002-06-09T05:06:07.013+01:00", test.toString());
556     }
557
558     public void testSetMilliOfSecond_int2() {
559         MutableDateTime test = new MutableDateTime(2002, 6, 9, 5, 6, 7, 8);
560         try {
561             test.setMillisOfSecond(1000);
562             fail();
563         } catch (IllegalArgumentException JavaDoc ex) {}
564         assertEquals("2002-06-09T05:06:07.008+01:00", test.toString());
565     }
566
567     //-----------------------------------------------------------------------
568
public void testSetMilliOfDay_int1() {
569         MutableDateTime test = new MutableDateTime(2002, 6, 9, 5, 6, 7, 8);
570         test.setMillisOfDay(13);
571         assertEquals("2002-06-09T00:00:00.013+01:00", test.toString());
572     }
573
574     public void testSetMilliOfDay_int2() {
575         MutableDateTime test = new MutableDateTime(2002, 6, 9, 5, 6, 7, 8);
576         try {
577             test.setMillisOfDay(24 * 60 * 60 * 1000);
578             fail();
579         } catch (IllegalArgumentException JavaDoc ex) {}
580         assertEquals("2002-06-09T05:06:07.008+01:00", test.toString());
581     }
582
583 }
584
Popular Tags