1 7 package com.inversoft.verge.mvc.view.jsp.actionflow.test; 8 9 10 import javax.servlet.jsp.JspException ; 11 import javax.servlet.jsp.tagext.Tag ; 12 13 import com.inversoft.junit.JspTestCase; 14 import com.inversoft.verge.mvc.controller.actionflow.ActionFlowURLTools; 15 import com.inversoft.verge.mvc.view.jsp.actionflow.FormTag; 16 import com.inversoft.verge.mvc.view.jsp.actionflow.SubmitTag; 17 18 19 28 public class SubmitTagTest extends JspTestCase { 29 30 34 public SubmitTagTest(String name) { 35 super(name); 36 setLocal(true); 37 } 38 39 40 43 public void testAction() { 44 FormTag parent = new FormTag(); 45 parent.setPageContext(pageContext); 46 parent.setNamespace("ns"); 47 48 SubmitTag tag = new SubmitTag(); 49 tag.setParent(parent); 50 tag.setPageContext(pageContext); 51 tag.setId("test"); 52 tag.setName("test"); 53 tag.setAction("testAction"); 54 55 try { 56 runTag(parent); 57 getPageContext().clearMockOut(); 58 59 assertEquals("Should return EVAL_PAGE", runTag(tag), Tag.EVAL_PAGE); 60 String tagStr = getPageContext().getMockOut().getText(); 61 62 String expected = "<input type=\"submit\" id=\"test\" name=\"test\"/>" + 63 "<input type=\"hidden\" name=\"" + 64 ActionFlowURLTools.SUBMIT_PARAMETER + "\"" + 65 " value=\"" + ActionFlowURLTools.generateSubmitParameter("test", 66 "testAction", null, null) + "\"/>"; 67 System.out.println("Expected: " + expected); 68 System.out.println("Actual: " + tagStr); 69 assertEquals("Should start with input", expected, tagStr); 70 } catch (JspException e) { 71 fail(e.toString()); 72 } 73 } 74 75 78 public void testEntry() { 79 FormTag parent = new FormTag(); 80 parent.setPageContext(pageContext); 81 parent.setNamespace("ns"); 82 83 SubmitTag tag = new SubmitTag(); 84 tag.setParent(parent); 85 tag.setPageContext(pageContext); 86 tag.setId("test"); 87 tag.setName("test"); 88 tag.setEntry("testEntry"); 89 tag.setAction("testAction"); 90 91 try { 92 runTag(parent); 93 getPageContext().clearMockOut(); 94 95 assertEquals("Should return EVAL_PAGE", runTag(tag), Tag.EVAL_PAGE); 96 String tagStr = getPageContext().getMockOut().getText(); 97 98 String expected = "<input type=\"submit\" id=\"test\" name=\"test\"/>" + 99 "<input type=\"hidden\" name=\"" + 100 ActionFlowURLTools.SUBMIT_PARAMETER + "\"" + 101 " value=\"" + ActionFlowURLTools.generateSubmitParameter("test", 102 "testAction", "testEntry", null) + "\"/>"; 103 System.out.println("Expected: " + expected); 104 System.out.println("Actual: " + tagStr); 105 assertEquals("Should start with input", expected, tagStr); 106 } catch (JspException e) { 107 fail(e.toString()); 108 } 109 } 110 } | Popular Tags |