Clover Coverage Report - Pebble 2.5-SNAPSHOT
Coverage timestamp: Sat Jun 12 2010 09:39:29 EST
27   119   10   3,86
0   50   0,37   7
7     1,43  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  YearTest       Line # 39 27 0% 10 3 91,2% 0.9117647
 
  (12)
 
1    /*
2    * Copyright (c) 2003-2006, Simon Brown
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions are met:
7    *
8    * - Redistributions of source code must retain the above copyright
9    * notice, this list of conditions and the following disclaimer.
10    *
11    * - Redistributions in binary form must reproduce the above copyright
12    * notice, this list of conditions and the following disclaimer in
13    * the documentation and/or other materials provided with the
14    * distribution.
15    *
16    * - Neither the name of Pebble nor the names of its contributors may
17    * be used to endorse or promote products derived from this software
18    * without specific prior written permission.
19    *
20    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21    * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22    * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23    * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24    * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25    * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26    * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27    * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28    * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29    * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30    * POSSIBILITY OF SUCH DAMAGE.
31    */
32    package net.sourceforge.pebble.domain;
33   
34    /**
35    * Tests for the Year class.
36    *
37    * @author Simon Brown
38    */
 
39    public class YearTest extends SingleBlogTestCase {
40   
41    private Year year;
42   
 
43  12 toggle protected void setUp() throws Exception {
44  12 super.setUp();
45  12 year = new Year(blog, 2003);
46    }
47   
48    /**
49    * Tests that the root blog is setup correctly.
50    */
 
51  2 toggle public void testGetRootBlog() {
52  2 assertEquals(blog, year.getBlog());
53    }
54   
55    /**
56    * Tests the getter for the year property.
57    */
 
58  2 toggle public void testGetYear() {
59  2 assertEquals(2003, year.getYear());
60    }
61   
62    /**
63    * Tests that we can get the first month containing blog entries.
64    */
 
65  2 toggle public void testFirstMonth() {
66  2 assertEquals(1, year.getBlogForFirstMonth().getMonth());
67    }
68   
69    /**
70    * Tests that we can get a specific month from a year.
71    */
 
72  2 toggle public void testGetMonth() {
73  2 Month month = year.getBlogForMonth(1);
74  2 assertEquals(year, month.getYear());
75  2 assertEquals(1, month.getMonth());
76   
77  2 month = year.getBlogForMonth(12);
78  2 assertEquals(year, month.getYear());
79  2 assertEquals(12, month.getMonth());
80   
81  2 try {
82  2 month = year.getBlogForMonth(-1);
83  0 fail();
84    } catch (IllegalArgumentException iae) {
85    }
86   
87  2 try {
88  2 month = year.getBlogForMonth(0);
89  0 fail();
90    } catch (IllegalArgumentException iae) {
91    }
92   
93  2 try {
94  2 month = year.getBlogForMonth(13);
95  0 fail();
96    } catch (IllegalArgumentException iae) {
97    }
98    }
99   
100    /**
101    * Tests that toString() works.
102    */
 
103  2 toggle public void testToString() {
104  2 assertEquals("2003", year.toString());
105    }
106   
107    /**
108    * Tests the compareTo method.
109    */
 
110  2 toggle public void testCompareTo() {
111  2 Year y1 = new Year(blog, 2004);
112  2 Year y2 = new Year(blog, 2005);
113  2 assertTrue(y1.compareTo(y1) == 0);
114  2 assertTrue(y1.compareTo(y2) < 0);
115  2 assertTrue(y1.compareTo(y2) < 0);
116  2 assertTrue(y2.compareTo(y1) > 0);
117    }
118   
119    }