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 10 11 15 public class CheckboxTest extends AbstractUITagTest { 16 18 public CheckboxTest() { 19 } 20 21 23 public void testChecked() throws Exception { 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 { 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 { 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 |