1 7 package com.inversoft.verge.mvc.view.jsp.html.test; 8 9 10 import javax.servlet.jsp.JspException ; 11 import javax.servlet.jsp.tagext.Tag ; 12 13 import com.inversoft.junit.JspTestCase; 14 import com.inversoft.verge.mvc.view.jsp.html.FormTag; 15 import com.inversoft.verge.mvc.view.jsp.html.PasswordTag; 16 17 18 27 public class PasswordTagTest extends JspTestCase { 28 29 33 public PasswordTagTest(String name) { 34 super(name); 35 setLocal(true); 36 } 37 38 39 42 public void testAll() { 43 FormTag parent = new FormTag(); 44 PasswordTag tag = new PasswordTag(); 45 tag.setParent(parent); 46 tag.setPageContext(pageContext); 47 tag.setId("test"); 48 tag.setName("test"); 49 50 try { 51 assertEquals("Should return EVAL_PAGE", runTag(tag), Tag.EVAL_PAGE); 52 String tagStr = getPageContext().getMockOut().getText(); 53 54 System.out.println("Password tag: " + tagStr); 55 assertEquals("Should be password tag", tagStr, 56 "<input type=\"password\" id=\"test\" name=\"test\"/>"); 57 } catch (JspException e) { 58 fail(e.toString()); 59 } 60 } 61 62 65 public void testValueSupression() { 66 FormTag parent = new FormTag(); 67 PasswordTag tag = new PasswordTag(); 68 tag.setParent(parent); 69 tag.setPageContext(pageContext); 70 tag.setId("test"); 71 tag.setName("test"); 72 tag.setValue("test"); 73 74 try { 75 assertEquals("Should return EVAL_PAGE", runTag(tag), Tag.EVAL_PAGE); 76 String tagStr = getPageContext().getMockOut().getText(); 77 78 System.out.println("Password tag: " + tagStr); 79 assertEquals("Should be password tag", tagStr, 80 "<input type=\"password\" id=\"test\" name=\"test\"/>"); 81 } catch (JspException e) { 82 fail(e.toString()); 83 } 84 } 85 86 89 public void testValue() { 90 FormTag parent = new FormTag(); 91 PasswordTag tag = new PasswordTag(); 92 tag.setParent(parent); 93 tag.setPageContext(pageContext); 94 tag.setId("test"); 95 tag.setName("test"); 96 tag.setValue("test"); 97 tag.setShowPassword(true); 98 99 try { 100 assertEquals("Should return EVAL_PAGE", runTag(tag), Tag.EVAL_PAGE); 101 String tagStr = getPageContext().getMockOut().getText(); 102 103 System.out.println("Password tag: " + tagStr); 104 assertEquals("Should be password tag", tagStr, 105 "<input type=\"password\" id=\"test\" name=\"test\" value=\"test\"/>"); 106 } catch (JspException e) { 107 fail(e.toString()); 108 } 109 } 110 111 114 public void testValueObject() { 115 FormTag parent = new FormTag(); 116 PasswordTag tag = new PasswordTag(); 117 tag.setParent(parent); 118 tag.setPageContext(pageContext); 119 tag.setId("test"); 120 tag.setName("test"); 121 tag.setValue(new Bean("test2", "test2")); 122 tag.setShowPassword(true); 123 124 try { 125 assertEquals("Should return EVAL_PAGE", runTag(tag), Tag.EVAL_PAGE); 126 String tagStr = getPageContext().getMockOut().getText(); 127 128 System.out.println("Password tag: " + tagStr); 129 assertEquals("Should be password tag", tagStr, 130 "<input type=\"password\" id=\"test\" name=\"test\" value=\"test2\"/>"); 131 } catch (JspException e) { 132 fail(e.toString()); 133 } 134 } 135 } | Popular Tags |