Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
35   93   6   5.83
0   53   0.17   6
6     1  
1    
 
  DateUtilityTest       Line # 25 35 6 100% 1.0
 
  (4)
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2013, Michael Meyling <mime@qedeq.org>.
4    *
5    * "Hilbert II" is free software; you can redistribute
6    * it and/or modify it under the terms of the GNU General Public
7    * License as published by the Free Software Foundation; either
8    * version 2 of the License, or (at your option) any later version.
9    *
10    * This program is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13    * GNU General Public License for more details.
14    */
15   
16    package org.qedeq.base.utility;
17   
18    import org.qedeq.base.test.QedeqTestCase;
19   
20    /**
21    * Test {@link DateUtility}.
22    *
23    * @author Michael Meyling
24    */
 
25    public class DateUtilityTest extends QedeqTestCase {
26   
27    /*
28    * @see TestCase#setUp()
29    */
 
30  4 toggle protected void setUp() throws Exception {
31  4 super.setUp();
32    }
33   
34    /*
35    * @see TestCase#tearDown()
36    */
 
37  4 toggle protected void tearDown() throws Exception {
38  4 super.tearDown();
39    }
40   
41    /**
42    * Test getDuration(final int duration).
43    *
44    * @throws Exception
45    */
 
46  1 toggle public void testGetDuration() throws Exception {
47  1 assertEquals("00:00:00.000", DateUtility.getDuration(0));
48  1 assertEquals("00:00:00.001", DateUtility.getDuration(1));
49  1 assertEquals("23:59:59.999", DateUtility.getDuration(1000 * 60 * 60 * 24 - 1));
50  1 assertEquals("1 day 00:00:00.000", DateUtility.getDuration(1000 * 60 * 60 * 24));
51  1 assertEquals("1 day 23:59:59.999", DateUtility.getDuration(1000 * 60 * 60 * 24 * 2 - 1));
52  1 assertEquals("2 days 00:00:00.000", DateUtility.getDuration(1000 * 60 * 60 * 24 * 2));
53  1 assertEquals("365 days 00:00:00.000", DateUtility.getDuration(1000L * 60 * 60 * 24 * 365));
54  1 assertEquals("22:59:59.999", DateUtility.getDuration(1000 * 60 * 60 * 24 - 1 - 60 * 60
55    * 1000));
56  1 assertEquals("23:00:59.999", DateUtility.getDuration(1000 * 60 * 60 * 24 - 1 - 60 * 60
57    * 1000 + 60 * 1000));
58    }
59   
 
60  1 toggle public void testGetIsoTimestamp() throws Exception {
61  1 final String ts = DateUtility.getIsoTimestamp();
62  1 assertEquals("2009-06-07T02:10:12.000".length(), ts.length());
63  1 assertEquals("-", ts.substring(4, 5));
64  1 assertEquals("-", ts.substring(7, 8));
65  1 assertEquals("T", ts.substring(10, 11));
66  1 assertEquals(":", ts.substring(13, 14));
67  1 assertEquals(":", ts.substring(16, 17));
68  1 assertEquals(".", ts.substring(19, 20));
69    }
70   
 
71  1 toggle public void testGmtTimestamp() throws Exception {
72  1 final String ts = DateUtility.getGmtTimestamp();
73  1 assertEquals("2009-06-07 02:10:12.000".length(), ts.length());
74  1 assertEquals("-", ts.substring(4, 5));
75  1 assertEquals("-", ts.substring(7, 8));
76  1 assertEquals(" ", ts.substring(10, 11));
77  1 assertEquals(":", ts.substring(13, 14));
78  1 assertEquals(":", ts.substring(16, 17));
79  1 assertEquals(".", ts.substring(19, 20));
80    }
81   
 
82  1 toggle public void testTimestamp() throws Exception {
83  1 final String ts = DateUtility.getTimestamp();
84  1 assertEquals("2009-06-07 02:10:12.000".length(), ts.length());
85  1 assertEquals("-", ts.substring(4, 5));
86  1 assertEquals("-", ts.substring(7, 8));
87  1 assertEquals(" ", ts.substring(10, 11));
88  1 assertEquals(":", ts.substring(13, 14));
89  1 assertEquals(":", ts.substring(16, 17));
90  1 assertEquals(".", ts.substring(19, 20));
91    }
92   
93    }