1 18 package org.apache.struts.taglib.bean; 19 20 import java.io.IOException ; 21 22 import javax.servlet.ServletException ; 23 24 import junit.framework.Test; 25 import junit.framework.TestSuite; 26 27 import org.apache.cactus.WebRequest; 28 import org.apache.cactus.WebResponse; 29 import org.apache.struts.taglib.TaglibTestBase; 30 31 36 public class TestParameterTag extends TaglibTestBase { 37 38 protected final static String PARAMETERTAG_KEY = "PARAMETERTAG_KEY"; 39 protected final static String PARAMETERTAG_VAL = "PARAMETERTAG_VAL"; 40 41 46 public TestParameterTag(String theName) { 47 super(theName); 48 } 49 50 55 public static void main(String [] theArgs) { 56 junit.awtui.TestRunner.main(new String [] {TestParameterTag.class.getName()}); 57 } 58 59 63 public static Test suite() { 64 return new TestSuite(TestParameterTag.class); 66 } 67 68 69 private void formatAndTest(String compare, String output) { 70 output = replace(output,"\r",""); 72 output = replace(output,"\n",""); 73 output = output.trim(); 74 assertEquals(compare, output); 76 } 77 78 public void beginParameterTag(WebRequest webRequest) { 79 webRequest.addParameter("testParam", "Test Value"); 80 } 81 public void testParameterTag() throws IOException , ServletException { 82 request.setAttribute("runTest", "testParameterTag"); 83 pageContext.forward("/test/org/apache/struts/taglib/bean/TestParameterTag.jsp"); 84 } 85 public void endParameterTag(WebResponse response){ 86 formatAndTest("Test Value", response.getText()); 87 } 88 89 public void testParameterTagValue() throws IOException , ServletException { 90 request.setAttribute("runTest", "testParameterTagValue"); 91 pageContext.forward("/test/org/apache/struts/taglib/bean/TestParameterTag.jsp"); 92 } 93 public void endParameterTagValue(WebResponse response){ 94 formatAndTest("Test Value", response.getText()); 95 } 96 97 98 } 99 | Popular Tags |