Clover Coverage Report - Pebble 2.5-SNAPSHOT
Coverage timestamp: Sat Jun 12 2010 09:39:29 EST
23   52   8   3,29
2   43   0,35   7
7     1,14  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  PostToTwitterBlogEntryListenerTest       Line # 5 23 0% 8 0 100% 1.0
 
  (12)
 
1    package net.sourceforge.pebble.event.blogentry;
2   
3    import junit.framework.TestCase;
4   
 
5    public class PostToTwitterBlogEntryListenerTest extends TestCase {
6    PostToTwitterBlogEntryListener listener = new PostToTwitterBlogEntryListener();
7   
 
8  2 toggle public void testRejectLocalhostUrl() throws Exception {
9  2 assertFalse(listener.checkUrl("http://localhost:8080/pebble/somewhere"));
10  2 assertFalse(listener.checkUrl("http://localhost/pebble/somewhere"));
11  2 assertFalse(listener.checkUrl("https://localhost:8443/pebble/somewhere"));
12  2 assertFalse(listener.checkUrl("https://localhost/pebble/somewhere"));
13    }
14   
 
15  2 toggle public void testDontBeTrickedByLocalhost() throws Exception {
16  2 assertTrue(listener.checkUrl("http://localhost.example.com/pebble/something/"));
17  2 assertTrue(listener.checkUrl("https://localhost.example.com/pebble/something/"));
18    }
19   
 
20  2 toggle public void testComposeMessageWithLongUrl() throws Exception {
21  2 String title = text(100);
22  2 assertEquals(text(100) + " longUrl", listener.composeMessage(title, "longUrl", "tiny"));
23    }
24   
 
25  2 toggle public void testComposeMessageWithShortUrl() throws Exception {
26  2 String title = text(120);
27  2 String longUrl = "longUrl-that-doesn't-fit-into-the-message"; // more than 20 characters
28  2 String tinyUrl = "myTinyUrl-fits";
29  2 assertEquals(text(120) + " myTinyUrl-fits", listener.composeMessage(title, longUrl, tinyUrl));
30    }
31   
 
32  2 toggle public void testShortenMessageTitle() throws Exception {
33  2 String title = text(135);
34  2 String longUrl = "longUrl-that-doesn't-fit-into-the-message"; // more than 20 characters
35  2 String tinyUrl = "myTinyUrl-doesn't-fit-either";
36  2 String message = listener.composeMessage(title, longUrl, tinyUrl);
37  2 assertTrue(message.length() <= 140);
38  2 assertEquals(text(111) + " myTinyUrl-doesn't-fit-either", message);
39    }
40   
 
41  2 toggle public void testHelperMethod() throws Exception {
42  2 assertEquals("123456789012", text(12));
43    }
44   
 
45  14 toggle private String text(int count) {
46  14 StringBuilder result = new StringBuilder();
47  1410 for(int i = 1; i <= count; i++ ) {
48  1396 result.append(String.valueOf(i%10));
49    }
50  14 return result.toString();
51    }
52    }