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.WebResponse; 28 import org.apache.struts.taglib.TaglibTestBase; 29 30 35 public class TestStrutsTag extends TaglibTestBase { 36 protected final static String TEST_VAL = "Test Value"; 37 protected final static String REQUEST_KEY = "REQUEST_KEY"; 38 39 44 public TestStrutsTag(String theName) { 45 super(theName); 46 } 47 48 53 public static void main(String [] theArgs) { 54 junit.awtui.TestRunner.main(new String [] {TestStrutsTag.class.getName()}); 55 } 56 57 61 public static Test suite() { 62 return new TestSuite(TestStrutsTag.class); 64 } 65 66 private void formatAndTest(String compare, String output) { 67 output = replace(output,"\r",""); 69 output = replace(output,"\n",""); 70 output = output.trim(); 71 assertEquals(compare, output); 73 } 74 75 76 77 public void testStrutsTagFormBean() throws IOException , ServletException { 78 request.setAttribute("runTest", "testStrutsTagFormBean"); 79 pageContext.forward("/test/org/apache/struts/taglib/bean/TestStrutsTag.jsp"); 80 } 81 public void endStrutsTagFormBean(WebResponse response){ 82 formatAndTest("testFormBean", response.getText()); 83 } 84 85 public void testStrutsTagDynaFormBean() throws IOException , ServletException { 86 request.setAttribute("runTest", "testStrutsTagDynaFormBean"); 87 pageContext.forward("/test/org/apache/struts/taglib/bean/TestStrutsTag.jsp"); 88 } 89 public void endStrutsTagDynaFormBean(WebResponse response){ 90 formatAndTest("testDynaFormBean", response.getText()); 91 } 92 93 public void testStrutsTagForward() throws IOException , ServletException { 94 request.setAttribute("runTest", "testStrutsTagForward"); 95 pageContext.forward("/test/org/apache/struts/taglib/bean/TestStrutsTag.jsp"); 96 } 97 public void endStrutsTagForward(WebResponse response){ 98 formatAndTest("testIncludeTagForward", response.getText()); 99 } 100 101 public void testStrutsTagMapping() throws IOException , ServletException { 102 request.setAttribute("runTest", "testStrutsTagMapping"); 103 pageContext.forward("/test/org/apache/struts/taglib/bean/TestStrutsTag.jsp"); 104 } 105 public void endStrutsTagMapping(WebResponse response){ 106 formatAndTest("/testIncludeTagTransaction", response.getText()); 107 } 108 109 110 } 111 | Popular Tags |