View Javadoc

1   /*
2    *  Copyright 2001-2006 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.Calendar;
19  import java.util.Date;
20  import java.util.GregorianCalendar;
21  
22  import junit.framework.TestCase;
23  import junit.framework.TestSuite;
24  
25  import org.joda.time.chrono.CopticChronology;
26  import org.joda.time.chrono.GJChronology;
27  import org.joda.time.chrono.ISOChronology;
28  import org.joda.time.chrono.JulianChronology;
29  
30  /**
31   * This class is a Junit unit test for TimeOfDay.
32   *
33   * @author Stephen Colebourne
34   */
35  public class TestTimeOfDay_Constructors extends TestCase {
36  
37      private static final DateTimeZone LONDON = DateTimeZone.forID("Europe/London");
38      private static final DateTimeZone PARIS = DateTimeZone.forID("Europe/Paris");
39      private static final ISOChronology ISO_UTC = ISOChronology.getInstanceUTC();
40      private static final int OFFSET = 1;
41      
42      private long TEST_TIME_NOW =
43              10L * DateTimeConstants.MILLIS_PER_HOUR
44              + 20L * DateTimeConstants.MILLIS_PER_MINUTE
45              + 30L * DateTimeConstants.MILLIS_PER_SECOND
46              + 40L;
47              
48      private long TEST_TIME1 =
49          1L * DateTimeConstants.MILLIS_PER_HOUR
50          + 2L * DateTimeConstants.MILLIS_PER_MINUTE
51          + 3L * DateTimeConstants.MILLIS_PER_SECOND
52          + 4L;
53          
54      private long TEST_TIME2 =
55          1L * DateTimeConstants.MILLIS_PER_DAY
56          + 5L * DateTimeConstants.MILLIS_PER_HOUR
57          + 6L * DateTimeConstants.MILLIS_PER_MINUTE
58          + 7L * DateTimeConstants.MILLIS_PER_SECOND
59          + 8L;
60          
61      private DateTimeZone zone = null;
62  
63      public static void main(String[] args) {
64          junit.textui.TestRunner.run(suite());
65      }
66  
67      public static TestSuite suite() {
68          return new TestSuite(TestTimeOfDay_Constructors.class);
69      }
70  
71      public TestTimeOfDay_Constructors(String name) {
72          super(name);
73      }
74  
75      protected void setUp() throws Exception {
76          DateTimeUtils.setCurrentMillisFixed(TEST_TIME_NOW);
77          zone = DateTimeZone.getDefault();
78          DateTimeZone.setDefault(LONDON);
79          java.util.TimeZone.setDefault(LONDON.toTimeZone());
80      }
81  
82      protected void tearDown() throws Exception {
83          DateTimeUtils.setCurrentMillisSystem();
84          DateTimeZone.setDefault(zone);
85          java.util.TimeZone.setDefault(zone.toTimeZone());
86          zone = null;
87      }
88  
89      //-----------------------------------------------------------------------
90      /**
91       * Test constructor ()
92       */
93      public void testConstantMidnight() throws Throwable {
94          TimeOfDay test = TimeOfDay.MIDNIGHT;
95          assertEquals(ISO_UTC, test.getChronology());
96          assertEquals(0, test.getHourOfDay());
97          assertEquals(0, test.getMinuteOfHour());
98          assertEquals(0, test.getSecondOfMinute());
99          assertEquals(0, test.getMillisOfSecond());
100     }
101 
102     //-----------------------------------------------------------------------
103     public void testFactory_FromCalendarFields() throws Exception {
104         GregorianCalendar cal = new GregorianCalendar(1970, 1, 3, 4, 5, 6);
105         cal.set(Calendar.MILLISECOND, 7);
106         TimeOfDay expected = new TimeOfDay(4, 5, 6, 7);
107         assertEquals(expected, TimeOfDay.fromCalendarFields(cal));
108         try {
109             TimeOfDay.fromCalendarFields(null);
110             fail();
111         } catch (IllegalArgumentException ex) {}
112     }
113 
114     //-----------------------------------------------------------------------
115     public void testFactory_FromDateFields_after1970() throws Exception {
116         GregorianCalendar cal = new GregorianCalendar(1970, 1, 3, 4, 5, 6);
117         cal.set(Calendar.MILLISECOND, 7);
118         TimeOfDay expected = new TimeOfDay(4, 5, 6, 7);
119         assertEquals(expected, TimeOfDay.fromDateFields(cal.getTime()));
120     }
121 
122     public void testFactory_FromDateFields_before1970() throws Exception {
123         GregorianCalendar cal = new GregorianCalendar(1969, 1, 3, 4, 5, 6);
124         cal.set(Calendar.MILLISECOND, 7);
125         TimeOfDay expected = new TimeOfDay(4, 5, 6, 7);
126         assertEquals(expected, TimeOfDay.fromDateFields(cal.getTime()));
127     }
128 
129     public void testFactory_FromDateFields_null() throws Exception {
130         try {
131             TimeOfDay.fromDateFields(null);
132             fail();
133         } catch (IllegalArgumentException ex) {}
134     }
135 
136     //-----------------------------------------------------------------------
137     /**
138      * Test factory (long)
139      */
140     public void testFactoryMillisOfDay_long1() throws Throwable {
141         TimeOfDay test = TimeOfDay.fromMillisOfDay(TEST_TIME1);
142         assertEquals(ISO_UTC, test.getChronology());
143         assertEquals(1, test.getHourOfDay());
144         assertEquals(2, test.getMinuteOfHour());
145         assertEquals(3, test.getSecondOfMinute());
146         assertEquals(4, test.getMillisOfSecond());
147     }
148 
149     /**
150      * Test factory (long, Chronology)
151      */
152     public void testFactoryMillisOfDay_long1_Chronology() throws Throwable {
153         TimeOfDay test = TimeOfDay.fromMillisOfDay(TEST_TIME1, JulianChronology.getInstance());
154         assertEquals(JulianChronology.getInstanceUTC(), test.getChronology());
155         assertEquals(1, test.getHourOfDay());
156         assertEquals(2, test.getMinuteOfHour());
157         assertEquals(3, test.getSecondOfMinute());
158         assertEquals(4, test.getMillisOfSecond());
159     }
160 
161     /**
162      * Test factory (long, Chronology=null)
163      */
164     public void testFactoryMillisOfDay_long_nullChronology() throws Throwable {
165         TimeOfDay test = TimeOfDay.fromMillisOfDay(TEST_TIME1, null);
166         assertEquals(ISO_UTC, test.getChronology());
167         assertEquals(1, test.getHourOfDay());
168         assertEquals(2, test.getMinuteOfHour());
169         assertEquals(3, test.getSecondOfMinute());
170         assertEquals(4, test.getMillisOfSecond());
171     }
172 
173     //-----------------------------------------------------------------------
174     /**
175      * Test constructor ()
176      */
177     public void testConstructor() throws Throwable {
178         TimeOfDay test = new TimeOfDay();
179         assertEquals(ISO_UTC, test.getChronology());
180         assertEquals(10 + OFFSET, test.getHourOfDay());
181         assertEquals(20, test.getMinuteOfHour());
182         assertEquals(30, test.getSecondOfMinute());
183         assertEquals(40, test.getMillisOfSecond());
184     }
185 
186     /**
187      * Test constructor (DateTimeZone)
188      */
189     public void testConstructor_DateTimeZone() throws Throwable {
190         DateTime dt = new DateTime(2005, 6, 8, 23, 59, 30, 40, LONDON);
191         DateTimeUtils.setCurrentMillisFixed(dt.getMillis());
192         // 23:59 in London is 00:59 the following day in Paris
193         
194         TimeOfDay test = new TimeOfDay(LONDON);
195         assertEquals(ISO_UTC, test.getChronology());
196         assertEquals(23, test.getHourOfDay());
197         assertEquals(59, test.getMinuteOfHour());
198         assertEquals(30, test.getSecondOfMinute());
199         assertEquals(40, test.getMillisOfSecond());
200         
201         test = new TimeOfDay(PARIS);
202         assertEquals(ISO_UTC, test.getChronology());
203         assertEquals(0, test.getHourOfDay());
204         assertEquals(59, test.getMinuteOfHour());
205         assertEquals(30, test.getSecondOfMinute());
206         assertEquals(40, test.getMillisOfSecond());
207     }
208 
209     /**
210      * Test constructor (DateTimeZone=null)
211      */
212     public void testConstructor_nullDateTimeZone() throws Throwable {
213         DateTime dt = new DateTime(2005, 6, 8, 23, 59, 30, 40, LONDON);
214         DateTimeUtils.setCurrentMillisFixed(dt.getMillis());
215         // 23:59 in London is 00:59 the following day in Paris
216         
217         TimeOfDay test = new TimeOfDay((DateTimeZone) null);
218         assertEquals(ISO_UTC, test.getChronology());
219         assertEquals(23, test.getHourOfDay());
220         assertEquals(59, test.getMinuteOfHour());
221         assertEquals(30, test.getSecondOfMinute());
222         assertEquals(40, test.getMillisOfSecond());
223     }
224 
225     /**
226      * Test constructor (Chronology)
227      */
228     public void testConstructor_Chronology() throws Throwable {
229         TimeOfDay test = new TimeOfDay(JulianChronology.getInstance());
230         assertEquals(JulianChronology.getInstanceUTC(), test.getChronology());
231         assertEquals(10 + OFFSET, test.getHourOfDay());
232         assertEquals(20, test.getMinuteOfHour());
233         assertEquals(30, test.getSecondOfMinute());
234         assertEquals(40, test.getMillisOfSecond());
235     }
236 
237     /**
238      * Test constructor (Chronology=null)
239      */
240     public void testConstructor_nullChronology() throws Throwable {
241         TimeOfDay test = new TimeOfDay((Chronology) null);
242         assertEquals(ISO_UTC, test.getChronology());
243         assertEquals(10 + OFFSET, test.getHourOfDay());
244         assertEquals(20, test.getMinuteOfHour());
245         assertEquals(30, test.getSecondOfMinute());
246         assertEquals(40, test.getMillisOfSecond());
247     }
248 
249     //-----------------------------------------------------------------------
250     /**
251      * Test constructor (long)
252      */
253     public void testConstructor_long1() throws Throwable {
254         TimeOfDay test = new TimeOfDay(TEST_TIME1);
255         assertEquals(ISO_UTC, test.getChronology());
256         assertEquals(1 + OFFSET, test.getHourOfDay());
257         assertEquals(2, test.getMinuteOfHour());
258         assertEquals(3, test.getSecondOfMinute());
259         assertEquals(4, test.getMillisOfSecond());
260     }
261 
262     /**
263      * Test constructor (long)
264      */
265     public void testConstructor_long2() throws Throwable {
266         TimeOfDay test = new TimeOfDay(TEST_TIME2);
267         assertEquals(ISO_UTC, test.getChronology());
268         assertEquals(5 + OFFSET, test.getHourOfDay());
269         assertEquals(6, test.getMinuteOfHour());
270         assertEquals(7, test.getSecondOfMinute());
271         assertEquals(8, test.getMillisOfSecond());
272     }
273 
274     /**
275      * Test constructor (long, Chronology)
276      */
277     public void testConstructor_long1_Chronology() throws Throwable {
278         TimeOfDay test = new TimeOfDay(TEST_TIME1, JulianChronology.getInstance());
279         assertEquals(JulianChronology.getInstanceUTC(), test.getChronology());
280         assertEquals(1 + OFFSET, test.getHourOfDay());
281         assertEquals(2, test.getMinuteOfHour());
282         assertEquals(3, test.getSecondOfMinute());
283         assertEquals(4, test.getMillisOfSecond());
284     }
285 
286     /**
287      * Test constructor (long, Chronology)
288      */
289     public void testConstructor_long2_Chronology() throws Throwable {
290         TimeOfDay test = new TimeOfDay(TEST_TIME2, JulianChronology.getInstance());
291         assertEquals(JulianChronology.getInstanceUTC(), test.getChronology());
292         assertEquals(5 + OFFSET, test.getHourOfDay());
293         assertEquals(6, test.getMinuteOfHour());
294         assertEquals(7, test.getSecondOfMinute());
295         assertEquals(8, test.getMillisOfSecond());
296     }
297 
298     /**
299      * Test constructor (long, Chronology=null)
300      */
301     public void testConstructor_long_nullChronology() throws Throwable {
302         TimeOfDay test = new TimeOfDay(TEST_TIME1, null);
303         assertEquals(ISO_UTC, test.getChronology());
304         assertEquals(1 + OFFSET, test.getHourOfDay());
305         assertEquals(2, test.getMinuteOfHour());
306         assertEquals(3, test.getSecondOfMinute());
307         assertEquals(4, test.getMillisOfSecond());
308     }
309 
310     //-----------------------------------------------------------------------
311     /**
312      * Test constructor (Object)
313      */
314     public void testConstructor_Object1() throws Throwable {
315         Date date = new Date(TEST_TIME1);
316         TimeOfDay test = new TimeOfDay(date);
317         assertEquals(ISO_UTC, test.getChronology());
318         assertEquals(1 + OFFSET, test.getHourOfDay());
319         assertEquals(2, test.getMinuteOfHour());
320         assertEquals(3, test.getSecondOfMinute());
321         assertEquals(4, test.getMillisOfSecond());
322     }
323 
324     /**
325      * Test constructor (Object)
326      */
327     public void testConstructor_Object2() throws Throwable {
328         Calendar cal = new GregorianCalendar();
329         cal.setTime(new Date(TEST_TIME1));
330         TimeOfDay test = new TimeOfDay(cal);
331         assertEquals(GJChronology.getInstanceUTC(), test.getChronology());
332         assertEquals(1 + OFFSET, test.getHourOfDay());
333         assertEquals(2, test.getMinuteOfHour());
334         assertEquals(3, test.getSecondOfMinute());
335         assertEquals(4, test.getMillisOfSecond());
336     }
337 
338     /**
339      * Test constructor (Object=null)
340      */
341     public void testConstructor_nullObject() throws Throwable {
342         TimeOfDay test = new TimeOfDay((Object) null);
343         assertEquals(ISO_UTC, test.getChronology());
344         assertEquals(10 + OFFSET, test.getHourOfDay());
345         assertEquals(20, test.getMinuteOfHour());
346         assertEquals(30, test.getSecondOfMinute());
347         assertEquals(40, test.getMillisOfSecond());
348     }
349 
350     /**
351      * Test constructor (Object)
352      */
353     public void testConstructor_todObject() throws Throwable {
354         TimeOfDay base = new TimeOfDay(10, 20, 30, 40, CopticChronology.getInstance(PARIS));
355         TimeOfDay test = new TimeOfDay(base);
356         assertEquals(CopticChronology.getInstanceUTC(), test.getChronology());
357         assertEquals(10, test.getHourOfDay());
358         assertEquals(20, test.getMinuteOfHour());
359         assertEquals(30, test.getSecondOfMinute());
360         assertEquals(40, test.getMillisOfSecond());
361     }
362 
363     public void testConstructor_ObjectString1() throws Throwable {
364         TimeOfDay test = new TimeOfDay("10:20:30.040");
365         assertEquals(ISO_UTC, test.getChronology());
366         assertEquals(10, test.getHourOfDay());
367         assertEquals(20, test.getMinuteOfHour());
368         assertEquals(30, test.getSecondOfMinute());
369         assertEquals(40, test.getMillisOfSecond());
370     }
371 
372     public void testConstructor_ObjectString2() throws Throwable {
373         TimeOfDay test = new TimeOfDay("10:20:30.040+04:00");
374         assertEquals(ISO_UTC, test.getChronology());
375         assertEquals(10 + OFFSET - 4, test.getHourOfDay());
376         assertEquals(20, test.getMinuteOfHour());
377         assertEquals(30, test.getSecondOfMinute());
378         assertEquals(40, test.getMillisOfSecond());
379     }
380 
381     public void testConstructor_ObjectString3() throws Throwable {
382         TimeOfDay test = new TimeOfDay("T10:20:30.040");
383         assertEquals(ISO_UTC, test.getChronology());
384         assertEquals(10, test.getHourOfDay());
385         assertEquals(20, test.getMinuteOfHour());
386         assertEquals(30, test.getSecondOfMinute());
387         assertEquals(40, test.getMillisOfSecond());
388     }
389 
390     public void testConstructor_ObjectString4() throws Throwable {
391         TimeOfDay test = new TimeOfDay("T10:20:30.040+04:00");
392         assertEquals(ISO_UTC, test.getChronology());
393         assertEquals(10 + OFFSET - 4, test.getHourOfDay());
394         assertEquals(20, test.getMinuteOfHour());
395         assertEquals(30, test.getSecondOfMinute());
396         assertEquals(40, test.getMillisOfSecond());
397     }
398 
399     public void testConstructor_ObjectString5() throws Throwable {
400         TimeOfDay test = new TimeOfDay("10:20");
401         assertEquals(ISO_UTC, test.getChronology());
402         assertEquals(10, test.getHourOfDay());
403         assertEquals(20, test.getMinuteOfHour());
404         assertEquals(0, test.getSecondOfMinute());
405         assertEquals(0, test.getMillisOfSecond());
406     }
407 
408     public void testConstructor_ObjectString6() throws Throwable {
409         TimeOfDay test = new TimeOfDay("10");
410         assertEquals(ISO_UTC, test.getChronology());
411         assertEquals(10, test.getHourOfDay());
412         assertEquals(0, test.getMinuteOfHour());
413         assertEquals(0, test.getSecondOfMinute());
414         assertEquals(0, test.getMillisOfSecond());
415     }
416 
417     public void testConstructor_ObjectStringEx1() throws Throwable {
418         try {
419             new TimeOfDay("1970-04-06");
420             fail();
421         } catch (IllegalArgumentException ex) {}
422     }
423 
424     public void testConstructor_ObjectStringEx2() throws Throwable {
425         try {
426             new TimeOfDay("1970-04-06T+14:00");
427             fail();
428         } catch (IllegalArgumentException ex) {}
429     }
430 
431     public void testConstructor_ObjectStringEx3() throws Throwable {
432         try {
433             new TimeOfDay("1970-04-06T10:20:30.040");
434             fail();
435         } catch (IllegalArgumentException ex) {}
436     }
437 
438     public void testConstructor_ObjectStringEx4() throws Throwable {
439         try {
440             new TimeOfDay("1970-04-06T10:20:30.040+14:00");
441             fail();
442         } catch (IllegalArgumentException ex) {}
443     }
444 
445     //-----------------------------------------------------------------------
446     /**
447      * Test constructor (Object, Chronology)
448      */
449     public void testConstructor_Object_Chronology() throws Throwable {
450         Date date = new Date(TEST_TIME1);
451         TimeOfDay test = new TimeOfDay(date, JulianChronology.getInstance());
452         assertEquals(JulianChronology.getInstanceUTC(), test.getChronology());
453         assertEquals(1 + OFFSET, test.getHourOfDay());
454         assertEquals(2, test.getMinuteOfHour());
455         assertEquals(3, test.getSecondOfMinute());
456         assertEquals(4, test.getMillisOfSecond());
457     }
458 
459     /**
460      * Test constructor (Object, Chronology)
461      */
462     public void testConstructor2_Object_Chronology() throws Throwable {
463         TimeOfDay test = new TimeOfDay("T10:20");
464         assertEquals(10, test.getHourOfDay());
465         assertEquals(20, test.getMinuteOfHour());
466         assertEquals(0, test.getSecondOfMinute());
467         assertEquals(0, test.getMillisOfSecond());
468         
469         try {
470             new TimeOfDay("T1020");
471             fail();
472         } catch (IllegalArgumentException ex) {}
473     }
474 
475     /**
476      * Test constructor (Object=null, Chronology)
477      */
478     public void testConstructor_nullObject_Chronology() throws Throwable {
479         TimeOfDay test = new TimeOfDay((Object) null, JulianChronology.getInstance());
480         assertEquals(JulianChronology.getInstanceUTC(), test.getChronology());
481         assertEquals(10 + OFFSET, test.getHourOfDay());
482         assertEquals(20, test.getMinuteOfHour());
483         assertEquals(30, test.getSecondOfMinute());
484         assertEquals(40, test.getMillisOfSecond());
485     }
486 
487     /**
488      * Test constructor (Object, Chronology=null)
489      */
490     public void testConstructor_Object_nullChronology() throws Throwable {
491         Date date = new Date(TEST_TIME1);
492         TimeOfDay test = new TimeOfDay(date, null);
493         assertEquals(ISO_UTC, test.getChronology());
494         assertEquals(1 + OFFSET, test.getHourOfDay());
495         assertEquals(2, test.getMinuteOfHour());
496         assertEquals(3, test.getSecondOfMinute());
497         assertEquals(4, test.getMillisOfSecond());
498     }
499 
500     /**
501      * Test constructor (Object=null, Chronology=null)
502      */
503     public void testConstructor_nullObject_nullChronology() throws Throwable {
504         TimeOfDay test = new TimeOfDay((Object) null, null);
505         assertEquals(ISO_UTC, test.getChronology());
506         assertEquals(10 + OFFSET, test.getHourOfDay());
507         assertEquals(20, test.getMinuteOfHour());
508         assertEquals(30, test.getSecondOfMinute());
509         assertEquals(40, test.getMillisOfSecond());
510     }
511 
512     //-----------------------------------------------------------------------
513     /**
514      * Test constructor (int, int)
515      */
516     public void testConstructor_int_int() throws Throwable {
517         TimeOfDay test = new TimeOfDay(10, 20);
518         assertEquals(ISO_UTC, test.getChronology());
519         assertEquals(10, test.getHourOfDay());
520         assertEquals(20, test.getMinuteOfHour());
521         assertEquals(0, test.getSecondOfMinute());
522         assertEquals(0, test.getMillisOfSecond());
523         try {
524             new TimeOfDay(-1, 20);
525             fail();
526         } catch (IllegalArgumentException ex) {}
527         try {
528             new TimeOfDay(24, 20);
529             fail();
530         } catch (IllegalArgumentException ex) {}
531         try {
532             new TimeOfDay(10, -1);
533             fail();
534         } catch (IllegalArgumentException ex) {}
535         try {
536             new TimeOfDay(10, 60);
537             fail();
538         } catch (IllegalArgumentException ex) {}
539     }
540 
541     /**
542      * Test constructor (int, int, int, Chronology)
543      */
544     public void testConstructor_int_int_Chronology() throws Throwable {
545         TimeOfDay test = new TimeOfDay(10, 20, JulianChronology.getInstance());
546         assertEquals(JulianChronology.getInstanceUTC(), test.getChronology());
547         assertEquals(10, test.getHourOfDay());
548         assertEquals(20, test.getMinuteOfHour());
549         assertEquals(0, test.getSecondOfMinute());
550         assertEquals(0, test.getMillisOfSecond());
551         try {
552             new TimeOfDay(-1, 20, JulianChronology.getInstance());
553             fail();
554         } catch (IllegalArgumentException ex) {}
555         try {
556             new TimeOfDay(24, 20, JulianChronology.getInstance());
557             fail();
558         } catch (IllegalArgumentException ex) {}
559         try {
560             new TimeOfDay(10, -1, JulianChronology.getInstance());
561             fail();
562         } catch (IllegalArgumentException ex) {}
563         try {
564             new TimeOfDay(10, 60, JulianChronology.getInstance());
565             fail();
566         } catch (IllegalArgumentException ex) {}
567     }
568 
569     /**
570      * Test constructor (int, int, int, Chronology=null)
571      */
572     public void testConstructor_int_int_nullChronology() throws Throwable {
573         TimeOfDay test = new TimeOfDay(10, 20, null);
574         assertEquals(ISO_UTC, test.getChronology());
575         assertEquals(10, test.getHourOfDay());
576         assertEquals(20, test.getMinuteOfHour());
577         assertEquals(0, test.getSecondOfMinute());
578         assertEquals(0, test.getMillisOfSecond());
579     }
580 
581     /**
582      * Test constructor (int, int, int)
583      */
584     public void testConstructor_int_int_int() throws Throwable {
585         TimeOfDay test = new TimeOfDay(10, 20, 30);
586         assertEquals(ISO_UTC, test.getChronology());
587         assertEquals(10, test.getHourOfDay());
588         assertEquals(20, test.getMinuteOfHour());
589         assertEquals(30, test.getSecondOfMinute());
590         assertEquals(0, test.getMillisOfSecond());
591         try {
592             new TimeOfDay(-1, 20, 30);
593             fail();
594         } catch (IllegalArgumentException ex) {}
595         try {
596             new TimeOfDay(24, 20, 30);
597             fail();
598         } catch (IllegalArgumentException ex) {}
599         try {
600             new TimeOfDay(10, -1, 30);
601             fail();
602         } catch (IllegalArgumentException ex) {}
603         try {
604             new TimeOfDay(10, 60, 30);
605             fail();
606         } catch (IllegalArgumentException ex) {}
607         try {
608             new TimeOfDay(10, 20, -1);
609             fail();
610         } catch (IllegalArgumentException ex) {}
611         try {
612             new TimeOfDay(10, 20, 60);
613             fail();
614         } catch (IllegalArgumentException ex) {}
615     }
616 
617     /**
618      * Test constructor (int, int, int, Chronology)
619      */
620     public void testConstructor_int_int_int_Chronology() throws Throwable {
621         TimeOfDay test = new TimeOfDay(10, 20, 30, JulianChronology.getInstance());
622         assertEquals(JulianChronology.getInstanceUTC(), test.getChronology());
623         assertEquals(10, test.getHourOfDay());
624         assertEquals(20, test.getMinuteOfHour());
625         assertEquals(30, test.getSecondOfMinute());
626         assertEquals(0, test.getMillisOfSecond());
627         try {
628             new TimeOfDay(-1, 20, 30, JulianChronology.getInstance());
629             fail();
630         } catch (IllegalArgumentException ex) {}
631         try {
632             new TimeOfDay(24, 20, 30, JulianChronology.getInstance());
633             fail();
634         } catch (IllegalArgumentException ex) {}
635         try {
636             new TimeOfDay(10, -1, 30, JulianChronology.getInstance());
637             fail();
638         } catch (IllegalArgumentException ex) {}
639         try {
640             new TimeOfDay(10, 60, 30, JulianChronology.getInstance());
641             fail();
642         } catch (IllegalArgumentException ex) {}
643         try {
644             new TimeOfDay(10, 20, -1, JulianChronology.getInstance());
645             fail();
646         } catch (IllegalArgumentException ex) {}
647         try {
648             new TimeOfDay(10, 20, 60, JulianChronology.getInstance());
649             fail();
650         } catch (IllegalArgumentException ex) {}
651     }
652 
653     /**
654      * Test constructor (int, int, int, Chronology=null)
655      */
656     public void testConstructor_int_int_int_nullChronology() throws Throwable {
657         TimeOfDay test = new TimeOfDay(10, 20, 30, null);
658         assertEquals(ISO_UTC, test.getChronology());
659         assertEquals(10, test.getHourOfDay());
660         assertEquals(20, test.getMinuteOfHour());
661         assertEquals(30, test.getSecondOfMinute());
662         assertEquals(0, test.getMillisOfSecond());
663     }
664 
665     /**
666      * Test constructor (int, int, int, int)
667      */
668     public void testConstructor_int_int_int_int() throws Throwable {
669         TimeOfDay test = new TimeOfDay(10, 20, 30, 40);
670         assertEquals(ISO_UTC, test.getChronology());
671         assertEquals(10, test.getHourOfDay());
672         assertEquals(20, test.getMinuteOfHour());
673         assertEquals(30, test.getSecondOfMinute());
674         assertEquals(40, test.getMillisOfSecond());
675         try {
676             new TimeOfDay(-1, 20, 30, 40);
677             fail();
678         } catch (IllegalArgumentException ex) {}
679         try {
680             new TimeOfDay(24, 20, 30, 40);
681             fail();
682         } catch (IllegalArgumentException ex) {}
683         try {
684             new TimeOfDay(10, -1, 30, 40);
685             fail();
686         } catch (IllegalArgumentException ex) {}
687         try {
688             new TimeOfDay(10, 60, 30, 40);
689             fail();
690         } catch (IllegalArgumentException ex) {}
691         try {
692             new TimeOfDay(10, 20, -1, 40);
693             fail();
694         } catch (IllegalArgumentException ex) {}
695         try {
696             new TimeOfDay(10, 20, 60, 40);
697             fail();
698         } catch (IllegalArgumentException ex) {}
699         try {
700             new TimeOfDay(10, 20, 30, -1);
701             fail();
702         } catch (IllegalArgumentException ex) {}
703         try {
704             new TimeOfDay(10, 20, 30, 1000);
705             fail();
706         } catch (IllegalArgumentException ex) {}
707     }
708 
709     /**
710      * Test constructor (int, int, int, int, Chronology)
711      */
712     public void testConstructor_int_int_int_int_Chronology() throws Throwable {
713         TimeOfDay test = new TimeOfDay(10, 20, 30, 40, JulianChronology.getInstance());
714         assertEquals(JulianChronology.getInstanceUTC(), test.getChronology());
715         assertEquals(10, test.getHourOfDay());
716         assertEquals(20, test.getMinuteOfHour());
717         assertEquals(30, test.getSecondOfMinute());
718         assertEquals(40, test.getMillisOfSecond());
719         try {
720             new TimeOfDay(-1, 20, 30, 40, JulianChronology.getInstance());
721             fail();
722         } catch (IllegalArgumentException ex) {}
723         try {
724             new TimeOfDay(24, 20, 30, 40, JulianChronology.getInstance());
725             fail();
726         } catch (IllegalArgumentException ex) {}
727         try {
728             new TimeOfDay(10, -1, 30, 40, JulianChronology.getInstance());
729             fail();
730         } catch (IllegalArgumentException ex) {}
731         try {
732             new TimeOfDay(10, 60, 30, 40, JulianChronology.getInstance());
733             fail();
734         } catch (IllegalArgumentException ex) {}
735         try {
736             new TimeOfDay(10, 20, -1, 40, JulianChronology.getInstance());
737             fail();
738         } catch (IllegalArgumentException ex) {}
739         try {
740             new TimeOfDay(10, 20, 60, 40, JulianChronology.getInstance());
741             fail();
742         } catch (IllegalArgumentException ex) {}
743         try {
744             new TimeOfDay(10, 20, 30, -1, JulianChronology.getInstance());
745             fail();
746         } catch (IllegalArgumentException ex) {}
747         try {
748             new TimeOfDay(10, 20, 30, 1000, JulianChronology.getInstance());
749             fail();
750         } catch (IllegalArgumentException ex) {}
751     }
752 
753     /**
754      * Test constructor (int, int, int, int, Chronology=null)
755      */
756     public void testConstructor_int_int_int_int_nullChronology() throws Throwable {
757         TimeOfDay test = new TimeOfDay(10, 20, 30, 40, null);
758         assertEquals(ISO_UTC, test.getChronology());
759         assertEquals(10, test.getHourOfDay());
760         assertEquals(20, test.getMinuteOfHour());
761         assertEquals(30, test.getSecondOfMinute());
762         assertEquals(40, test.getMillisOfSecond());
763     }
764 
765 }