1 20 package org.apache.cactus.internal.server; 21 22 import java.io.IOException ; 23 import java.io.Writer ; 24 25 import java.lang.reflect.Field ; 26 27 import javax.servlet.http.HttpServletRequest ; 28 29 import junit.framework.TestCase; 30 31 import org.apache.cactus.JspTestCase; 32 import org.apache.cactus.ServletURL; 33 import org.apache.cactus.server.PageContextWrapper; 34 35 41 public class JspTestCaller extends ServletTestCaller 42 { 43 46 public JspTestCaller(JspImplicitObjects theObjects) 47 { 48 super(theObjects); 49 } 50 51 54 protected void setTestCaseFields(TestCase theTestInstance) 55 throws Exception 56 { 57 if (!(theTestInstance instanceof JspTestCase)) 58 { 59 return; 60 } 61 62 JspTestCase jspInstance = (JspTestCase) theTestInstance; 63 JspImplicitObjects jspImplicitObjects = 64 (JspImplicitObjects) this.webImplicitObjects; 65 66 super.setTestCaseFields(jspInstance); 69 70 HttpServletRequest request = jspImplicitObjects.getHttpServletRequest(); 74 75 ServletURL url = ServletURL.loadFromRequest(request); 76 77 Field pageContextField = jspInstance.getClass().getField("pageContext"); 78 79 pageContextField.set(jspInstance, 80 new PageContextWrapper(jspImplicitObjects.getPageContext(), url)); 81 82 Field outField = jspInstance.getClass().getField("out"); 85 86 outField.set(jspInstance, jspImplicitObjects.getJspWriter()); 87 } 88 89 92 protected Writer getResponseWriter() throws IOException 93 { 94 JspImplicitObjects jspImplicitObjects = 95 (JspImplicitObjects) this.webImplicitObjects; 96 97 return jspImplicitObjects.getJspWriter(); 98 } 99 } 100 | Popular Tags |