KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > webwork > views > jsp > ui > TextfieldTest


1 /*
2  * Copyright (c) 2002-2003 by OpenSymphony
3  * All rights reserved.
4  */

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 JavaDoc;
12
13 import freemarker.template.TransformControl;
14
15
16 /**
17  * @author Matt Ho <a HREF="mailto:matt@enginegreen.com">&lt;matt@enginegreen.com&gt;</a>
18  * @version $Id: TextfieldTest.java,v 1.15 2005/07/20 14:49:15 plightbo Exp $
19  */

20 public class TextfieldTest extends AbstractUITagTest {
21     //~ Methods ////////////////////////////////////////////////////////////////
22

23     public void testErrors() throws Exception JavaDoc {
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 JavaDoc {
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 JavaDoc {
59         TestAction testAction = (TestAction) action;
60         testAction.setFoo("bar");
61
62         TextFieldModel model = new TextFieldModel(stack, request, response);
63         HashMap JavaDoc params = new HashMap JavaDoc();
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 JavaDoc {
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