1 18 21 package org.apache.roller.util; 22 23 24 import junit.framework.Test; 25 import junit.framework.TestCase; 26 import junit.framework.TestSuite; 27 import org.apache.roller.ui.rendering.model.UtilitiesModel; 28 29 32 public class UtilitiesTest extends TestCase 33 { 34 38 public UtilitiesTest(String arg0) 39 { 40 super(arg0); 41 } 42 43 public static void main(String [] args) 44 { 45 } 46 47 50 protected void setUp() throws Exception 51 { 52 super.setUp(); 53 } 54 55 58 protected void tearDown() throws Exception 59 { 60 super.tearDown(); 61 } 62 63 public void testExtractHTML() 64 { 65 String test = "<a>keep me</a>"; 66 String expect = "<a></a>"; 67 String result = Utilities.extractHTML(test); 68 assertEquals(expect, result); 69 } 70 71 public void testRemoveHTML() 72 { 73 String test = "<br><br><p>a <b>bold</b> sentence with a <a HREF=\"http://example.com\">link</a></p>"; 74 String expect = "a bold sentence with a link"; 75 String result = Utilities.removeHTML(test, false); 76 assertEquals(expect, result); 77 } 78 79 public void testTruncateNicely1() 80 { 81 String test = "blah blah blah blah blah"; 82 String expect = "blah blah blah"; 83 String result = Utilities.truncateNicely(test, 11, 15, ""); 84 assertEquals(expect, result); 85 } 86 87 public void testTruncateNicely2() 88 { 89 String test = "<p><b>blah1 blah2</b> <i>blah3 blah4 blah5</i></p>"; 90 String expect = "<p><b>blah1 blah2</b> <i>blah3</i></p>"; 91 String result = Utilities.truncateNicely(test, 15, 20, ""); 92 assertEquals(expect, result); 94 } 95 96 public void testAddNoFollow() { 97 String test1 = "<p>this some text with a <a HREF=\"http://example.com\">link</a>"; 98 String expect1 = "<p>this some text with a <a HREF=\"http://example.com\" rel=\"nofollow\">link</a>"; 99 String result1 = UtilitiesModel.addNofollow(test1); 100 assertEquals(expect1, result1); 101 102 String test2 = "<p>this some text with a <A HREF=\"http://example.com\">link</a>"; 103 String expect2 = "<p>this some text with a <A HREF=\"http://example.com\" rel=\"nofollow\">link</a>"; 104 String result2 = UtilitiesModel.addNofollow(test2); 105 assertEquals(expect2, result2); 106 107 } 108 109 public static Test suite() 110 { 111 return new TestSuite(UtilitiesTest.class); 112 } 113 } 114 | Popular Tags |