1 5 package com.opensymphony.webwork.views.jsp.ui; 6 7 import com.opensymphony.webwork.TestAction; 8 import com.opensymphony.webwork.views.jsp.AbstractUITagTest; 9 import com.opensymphony.webwork.views.freemarker.tags.TextFieldModel; 10 11 import java.util.HashMap ; 12 13 import freemarker.template.TransformControl; 14 15 16 20 public class TextfieldTest extends AbstractUITagTest { 21 23 public void testErrors() throws Exception { 24 TestAction testAction = (TestAction) action; 25 testAction.setFoo("bar"); 26 27 TextFieldTag tag = new TextFieldTag(); 28 tag.setPageContext(pageContext); 29 tag.setId("myId"); 30 tag.setLabel("mylabel"); 31 tag.setName("foo"); 32 tag.setValue("bar"); 33 34 testAction.addFieldError("foo", "bar error message"); 35 tag.doStartTag(); 36 tag.doEndTag(); 37 38 verify(TextFieldTag.class.getResource("Textfield-2.txt")); 39 } 40 41 public void testNoLabelJsp() throws Exception { 42 TestAction testAction = (TestAction) action; 43 testAction.setFoo("bar"); 44 45 TextFieldTag tag = new TextFieldTag(); 46 tag.setPageContext(pageContext); 47 tag.setName("myname"); 48 tag.setValue("%{foo}"); 49 tag.setSize("10"); 50 tag.setOnblur("blahescape('somevalue');"); 51 52 tag.doStartTag(); 53 tag.doEndTag(); 54 55 verify(TextFieldTag.class.getResource("Textfield-3.txt")); 56 } 57 58 public void testNoLabelFtl() throws Exception { 59 TestAction testAction = (TestAction) action; 60 testAction.setFoo("bar"); 61 62 TextFieldModel model = new TextFieldModel(stack, request, response); 63 HashMap params = new HashMap (); 64 params.put("name", "myname"); 65 params.put("value", "%{foo}"); 66 params.put("size", "10"); 67 params.put("onblur", "blahescape('somevalue');"); 68 TransformControl control = (TransformControl) model.getWriter(writer, params); 69 control.onStart(); 70 control.afterBody(); 71 72 verify(TextFieldTag.class.getResource("Textfield-3.txt")); 73 } 74 75 public void testSimple() throws Exception { 76 TestAction testAction = (TestAction) action; 77 testAction.setFoo("bar"); 78 79 TextFieldTag tag = new TextFieldTag(); 80 tag.setPageContext(pageContext); 81 tag.setLabel("mylabel"); 82 tag.setName("myname"); 83 tag.setValue("%{foo}"); 84 tag.setSize("10"); 85 86 tag.doStartTag(); 87 tag.doEndTag(); 88 89 verify(TextFieldTag.class.getResource("Textfield-1.txt")); 90 } 91 } 92 | Popular Tags |