1 16 17 package org.apache.struts.taglib; 18 19 import junit.framework.Test; 20 import junit.framework.TestCase; 21 import junit.framework.TestSuite; 22 import org.apache.commons.logging.LogFactory; 23 import org.apache.commons.logging.Log; 24 25 26 29 public class TestTagUtils extends TestCase { 30 31 32 private static Log log = LogFactory.getLog(TestTagUtils.class); 33 34 protected TagUtils tagutils = TagUtils.getInstance(); 35 36 41 public TestTagUtils(String theName) { 42 super(theName); 43 } 44 45 50 public static void main(String [] theArgs) { 51 junit.awtui.TestRunner.main( 52 new String [] {TestTagUtils.class.getName()}); 53 } 54 55 59 public static Test suite() { 60 return new TestSuite(TestTagUtils.class); 62 } 63 64 public void setUp() { 65 } 66 67 public void tearDown() { 68 } 69 70 73 public void testFilter() { 74 75 assertNull("Filter Test 1", tagutils.filter(null)); 77 78 assertEquals("Filter Test 2", "", tagutils.filter("")); 80 81 assertEquals("Filter Test 3", "a", tagutils.filter("a")); 83 84 assertEquals("Filter Test 4", "adhdfhdfhadhf", tagutils.filter("adhdfhdfhadhf")); 86 87 assertEquals("Filter Test 5", "<", tagutils.filter("<")); 89 assertEquals("Filter Test 6", ">", tagutils.filter(">")); 90 assertEquals("Filter Test 7", "&", tagutils.filter("&")); 91 assertEquals("Filter Test 8", """, tagutils.filter("\"")); 92 assertEquals("Filter Test 9", "'", tagutils.filter("'")); 93 94 assertEquals("Filter Test 10", "a<", tagutils.filter("a<")); 96 assertEquals("Filter Test 11", "<a", tagutils.filter("<a")); 97 assertEquals("Filter Test 12", "a<a", tagutils.filter("a<a")); 98 99 assertEquals("Filter Test 13", "abc<", tagutils.filter("abc<")); 101 assertEquals("Filter Test 14", "<abc", tagutils.filter("<abc")); 102 assertEquals("Filter Test 15", "abc<abc", tagutils.filter("abc<abc")); 103 104 assertEquals("Filter Test 16", "<input type="text" value='Me & You'>", 106 tagutils.filter("<input type=\"text\" value='Me & You'>")); 107 } 108 109 } 110 | Popular Tags |