KickJava   Java API By Example, From Geeks To Geeks.

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


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
10
11 /**
12  * @author Matt Ho <a HREF="mailto:matt@enginegreen.com">&lt;matt@enginegreen.com&gt;</a>
13  * @version $Id: CheckboxTest.java,v 1.12 2005/07/20 14:49:13 plightbo Exp $
14  */

15 public class CheckboxTest extends AbstractUITagTest {
16     //~ Constructors ///////////////////////////////////////////////////////////
17

18     public CheckboxTest() {
19     }
20
21     //~ Methods ////////////////////////////////////////////////////////////////
22

23     public void testChecked() throws Exception JavaDoc {
24         TestAction testAction = (TestAction) action;
25         testAction.setFoo("true");
26
27         CheckboxTag tag = new CheckboxTag();
28         tag.setPageContext(pageContext);
29         tag.setId("someId");
30         tag.setLabel("mylabel");
31         tag.setName("foo");
32         tag.setFieldValue("baz");
33         tag.setOnfocus("test();");
34
35         tag.doStartTag();
36         tag.doEndTag();
37
38         verify(CheckboxTag.class.getResource("Checkbox-1.txt"));
39     }
40
41     public void testCheckedWithError() throws Exception JavaDoc {
42         TestAction testAction = (TestAction) action;
43         testAction.setFoo("true");
44         testAction.addFieldError("foo", "Some Foo Error");
45         testAction.addFieldError("foo", "Another Foo Error");
46
47         CheckboxTag tag = new CheckboxTag();
48         tag.setPageContext(pageContext);
49         tag.setLabel("mylabel");
50         tag.setName("foo");
51         tag.setFieldValue("baz");
52         tag.setOndblclick("test();");
53         tag.setOnclick("test();");
54
55         tag.doStartTag();
56         tag.doEndTag();
57
58         verify(CheckboxTag.class.getResource("Checkbox-3.txt"));
59     }
60
61     public void testUnchecked() throws Exception JavaDoc {
62         TestAction testAction = (TestAction) action;
63         testAction.setFoo("false");
64
65         CheckboxTag tag = new CheckboxTag();
66         tag.setPageContext(pageContext);
67         tag.setLabel("mylabel");
68         tag.setName("foo");
69         tag.setFieldValue("baz");
70
71         tag.doStartTag();
72         tag.doEndTag();
73
74         verify(CheckboxTag.class.getResource("Checkbox-2.txt"));
75     }
76 }
77
Popular Tags