1 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 15 public class UtilitiesTest extends TestCase 16 { 17 21 public UtilitiesTest(String arg0) 22 { 23 super(arg0); 24 } 25 26 public static void main(String [] args) 27 { 28 } 29 30 33 protected void setUp() throws Exception 34 { 35 super.setUp(); 36 } 37 38 41 protected void tearDown() throws Exception 42 { 43 super.tearDown(); 44 } 45 46 public void testExtractHTML() 47 { 48 String test = "<a>keep me</a>"; 49 String expect = "<a></a>"; 50 String result = Utilities.extractHTML(test); 51 assertEquals(expect, result); 52 } 53 54 public void testRemoveHTML() 55 { 56 String test = "<br><br><p>a <b>bold</b> sentence with a <a HREF=\"http://example.com\">link</a></p>"; 57 String expect = "a bold sentence with a link"; 58 String result = Utilities.removeHTML(test, false); 59 assertEquals(expect, result); 60 } 61 62 public void testTruncateNicely1() 63 { 64 String test = "blah blah blah blah blah"; 65 String expect = "blah blah blah"; 66 String result = Utilities.truncateNicely(test, 11, 15, ""); 67 assertEquals(expect, result); 68 } 69 70 public void testTruncateNicely2() 71 { 72 String test = "<p><b>blah1 blah2</b> <i>blah3 blah4 blah5</i></p>"; 73 String expect = "<p><b>blah1 blah2</b> <i>blah3</i></p>"; 74 String result = Utilities.truncateNicely(test, 15, 20, ""); 75 assertEquals(expect, result); 77 } 78 79 public void testAddNoFollow() { 80 String test1 = "<p>this some text with a <a HREF=\"http://example.com\">link</a>"; 81 String expect1 = "<p>this some text with a <a HREF=\"http://example.com\" rel=\"nofollow\">link</a>"; 82 String result1 = Utilities.addNofollow(test1); 83 assertEquals(expect1, result1); 84 85 String test2 = "<p>this some text with a <A HREF=\"http://example.com\">link</a>"; 86 String expect2 = "<p>this some text with a <A HREF=\"http://example.com\" rel=\"nofollow\">link</a>"; 87 String 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 |