Clover Coverage Report - Pebble 2.5-SNAPSHOT
Coverage timestamp: Sat Jun 12 2010 09:39:29 EST
24   119   7   3,43
0   47   0,29   7
7     1  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  PermalinkProviderSupportTestCase       Line # 44 24 0% 7 0 100% 1.0
 
  (36)
 
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.permalink;
33   
34    import net.sourceforge.pebble.domain.Day;
35    import net.sourceforge.pebble.domain.Month;
36    import net.sourceforge.pebble.domain.SingleBlogTestCase;
37    import net.sourceforge.pebble.api.permalink.PermalinkProvider;
38   
39    /**
40    * Tests for the DefaultPermalinkProvider class.
41    *
42    * @author Simon Brown
43    */
 
44    public abstract class PermalinkProviderSupportTestCase extends SingleBlogTestCase {
45   
46    protected PermalinkProvider permalinkProvider;
47   
 
48  60 toggle protected void setUp() throws Exception {
49  60 super.setUp();
50   
51  60 permalinkProvider = getPermalinkProvider();
52  60 blog.setPermalinkProvider(permalinkProvider);
53    }
54   
55    /**
56    * Gets a PermalinkProvider instance.
57    *
58    * @return a PermalinkProvider instance
59    */
60    protected abstract PermalinkProvider getPermalinkProvider();
61   
62    /**
63    * Tests that a monthly blog permalink can be generated.
64    */
 
65  6 toggle public void testGetPermalinkForMonth() {
66  6 Month month = blog.getBlogForMonth(2004, 01);
67  6 assertEquals("/2004/01.html", permalinkProvider.getPermalink(month));
68    }
69   
70    /**
71    * Tests that a monthly blog permalink is recognised.
72    */
 
73  6 toggle public void testMonthPermalink() {
74  6 assertTrue(permalinkProvider.isMonthPermalink("/2004/01.html"));
75  6 assertFalse(permalinkProvider.isMonthPermalink("/2004/01/01.html"));
76  6 assertFalse(permalinkProvider.isMonthPermalink("/someotherpage.html"));
77  6 assertFalse(permalinkProvider.isMonthPermalink(""));
78  6 assertFalse(permalinkProvider.isMonthPermalink(null));
79    }
80   
81    /**
82    * Tests thet the correct monthly blog can be found from a permalink.
83    */
 
84  6 toggle public void testGetMonth() {
85  6 Month month = permalinkProvider.getMonth("/2004/07.html");
86  6 assertEquals(2004, month.getYear().getYear());
87  6 assertEquals(7, month.getMonth());
88    }
89   
90    /**
91    * Tests that a day permalink can be generated.
92    */
 
93  6 toggle public void testGetPermalinkForDay() {
94  6 Day day = blog.getBlogForDay(2004, 07, 14);
95  6 assertEquals("/2004/07/14.html", permalinkProvider.getPermalink(day));
96    }
97   
98    /**
99    * Tests that a day permalink is recognised.
100    */
 
101  6 toggle public void testDayPermalink() {
102  6 assertTrue(permalinkProvider.isDayPermalink("/2004/01/01.html"));
103  6 assertFalse(permalinkProvider.isDayPermalink("/2004/01.html"));
104  6 assertFalse(permalinkProvider.isDayPermalink("/someotherpage.html"));
105  6 assertFalse(permalinkProvider.isDayPermalink(""));
106  6 assertFalse(permalinkProvider.isDayPermalink(null));
107    }
108   
109    /**
110    * Tests thet the correct day can be found from a permalink.
111    */
 
112  6 toggle public void testGetDay() {
113  6 Day day = permalinkProvider.getDay("/2004/07/14.html");
114  6 assertEquals(2004, day.getMonth().getYear().getYear());
115  6 assertEquals(7, day.getMonth().getMonth());
116  6 assertEquals(14, day.getDay());
117    }
118   
119    }