KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > roller > util > UtilitiesTest


1 /*
2  * Created on Nov 2, 2003
3  */

4 package org.roller.util;
5
6 import org.roller.presentation.bookmarks.BookmarksActionTest;
7
8 import junit.framework.Test;
9 import junit.framework.TestCase;
10 import junit.framework.TestSuite;
11
12 /**
13  * @author lance
14  */

15 public class UtilitiesTest extends TestCase
16 {
17     /**
18      * Constructor for LinkbackExtractorTest.
19      * @param arg0
20      */

21     public UtilitiesTest(String JavaDoc arg0)
22     {
23         super(arg0);
24     }
25
26     public static void main(String JavaDoc[] args)
27     {
28     }
29
30     /**
31      * @see TestCase#setUp()
32      */

33     protected void setUp() throws Exception JavaDoc
34     {
35         super.setUp();
36     }
37
38     /**
39      * @see TestCase#tearDown()
40      */

41     protected void tearDown() throws Exception JavaDoc
42     {
43         super.tearDown();
44     }
45     
46     public void testExtractHTML()
47     {
48         String JavaDoc test = "<a>keep me</a>";
49         String JavaDoc expect = "<a></a>";
50         String JavaDoc result = Utilities.extractHTML(test);
51         assertEquals(expect, result);
52     }
53     
54     public void testRemoveHTML()
55     {
56         String JavaDoc test = "<br><br><p>a <b>bold</b> sentence with a <a HREF=\"http://example.com\">link</a></p>";
57         String JavaDoc expect = "a bold sentence with a link";
58         String JavaDoc result = Utilities.removeHTML(test, false);
59         assertEquals(expect, result);
60     }
61         
62     public void testTruncateNicely1()
63     {
64         String JavaDoc test = "blah blah blah blah blah";
65         String JavaDoc expect = "blah blah blah";
66         String JavaDoc result = Utilities.truncateNicely(test, 11, 15, "");
67         assertEquals(expect, result);
68     }
69     
70     public void testTruncateNicely2()
71     {
72         String JavaDoc test = "<p><b>blah1 blah2</b> <i>blah3 blah4 blah5</i></p>";
73         String JavaDoc expect = "<p><b>blah1 blah2</b> <i>blah3</i></p>";
74         String JavaDoc result = Utilities.truncateNicely(test, 15, 20, "");
75         //System.out.println(result);
76
assertEquals(expect, result);
77     }
78
79     public void testAddNoFollow() {
80         String JavaDoc test1 = "<p>this some text with a <a HREF=\"http://example.com\">link</a>";
81         String JavaDoc expect1 = "<p>this some text with a <a HREF=\"http://example.com\" rel=\"nofollow\">link</a>";
82         String JavaDoc result1 = Utilities.addNofollow(test1);
83         assertEquals(expect1, result1);
84
85         String JavaDoc test2 = "<p>this some text with a <A HREF=\"http://example.com\">link</a>";
86         String JavaDoc expect2 = "<p>this some text with a <A HREF=\"http://example.com\" rel=\"nofollow\">link</a>";
87         String JavaDoc result2 = Utilities.addNofollow(test2);
88         assertEquals(expect2, result2);
89
90     }
91
92     public static Test suite()
93     {
94         return new TestSuite(UtilitiesTest.class);
95     }
96 }
97
Popular Tags