1 18 19 package org.apache.strutsel.taglib.html; 20 21 import java.util.HashMap ; 22 import javax.servlet.ServletException ; 23 import javax.servlet.jsp.JspException ; 24 import junit.framework.Test; 25 import junit.framework.TestSuite; 26 import org.apache.struts.util.LabelValueBean; 27 import org.apache.strutsel.taglib.utils.JspTagTestCase; 28 import org.apache.strutsel.taglib.utils.TestHelper; 29 import org.apache.strutsel.taglib.utils.DOMHelper; 30 31 public class TestELHiddenTag 32 extends JspTagTestCase { 33 34 protected ELHiddenTag elHiddenTag = null; 35 36 public TestELHiddenTag(String theName) { 37 super(theName); 38 } 39 40 public static void main(String [] args) { 41 junit.awtui.TestRunner. 42 main(new String [] { TestELHiddenTag.class.getName() }); 43 } 44 45 public static Test suite() { 46 return new TestSuite(TestELHiddenTag.class); 47 } 48 49 public void setUp() { 50 elHiddenTag = new ELHiddenTag(); 51 elHiddenTag.setPageContext(pageContext); 52 } 53 54 public void tearDown() { 55 elHiddenTag = null; 56 } 57 58 public void testPlain() 59 throws ServletException , JspException { 60 61 LabelValueBean bean = new LabelValueBean("junk", "stuff"); 62 pageContext.setAttribute("testFormBean", bean); 63 64 elHiddenTag.setNameExpr("testFormBean"); 65 elHiddenTag.setPropertyExpr("value"); 66 67 int startTagReturn = elHiddenTag.doStartTag(); 68 int afterBodyReturn = elHiddenTag.doAfterBody(); 69 int endTagReturn = elHiddenTag.doEndTag(); 70 } 71 72 public void endPlain(com.meterware.httpunit.WebResponse testResponse) { 73 try { 74 TestHelper.printResponse(testResponse); 75 76 org.w3c.dom.Document document = testResponse.getDOM(); 77 DOMHelper.printNode(document.getDocumentElement()); 78 79 HashMap attrMap = new HashMap (); 80 DOMHelper.recordFoundAttributes(testResponse.getDOM(), 81 "/html/body/input", attrMap); 82 DOMHelper. 83 verifyAttributesPresent(attrMap, 84 new String [] { "type", "name", 85 "value" }, 86 false); 87 } catch (Exception ex) { 88 ex.printStackTrace(); 89 fail(); 90 } 91 } 92 } 93 | Popular Tags |