1
|
|
/* Generated by AspectJ version 1.0.5 */
|
2
|
|
package org.apache.cactus.server;
|
3
|
|
import java.lang.reflect.Field;
|
4
|
|
import java.io.Writer;
|
5
|
|
import java.io.IOException;
|
6
|
|
import javax.servlet.http.HttpServletRequest;
|
7
|
|
import org.apache.cactus.AbstractTestCase;
|
8
|
|
import org.apache.cactus.JspTestCase;
|
9
|
|
import org.apache.cactus.ServletURL;
|
10
|
|
|
11
|
|
/**
|
12
|
|
* Call the test method on the server side after assigning the JSP implicit
|
13
|
|
* objects using reflection.
|
14
|
|
*
|
15
|
|
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
|
16
|
|
*
|
17
|
|
* @version $Id: JspTestCaller.java,v 1.3 2002/05/06 17:38:23 vmassol Exp $
|
18
|
|
*/
|
19
|
|
public class JspTestCaller extends ServletTestCaller {
|
20
|
|
/**
|
21
|
|
* @param theObjects the implicit objects coming from the redirector
|
22
|
|
*/
|
23
|
36
|
public JspTestCaller(JspImplicitObjects theObjects) {
|
24
|
36
|
super(theObjects);
|
25
|
|
;
|
26
|
|
}
|
27
|
|
/**
|
28
|
|
* @see AbstractWebTestCaller#setTestCaseFields(AbstractTestCase)
|
29
|
|
*/
|
30
|
18
|
protected void setTestCaseFields(AbstractTestCase theTestInstance) throws Exception {
|
31
|
18
|
JspTestCase jspInstance = (JspTestCase)theTestInstance;
|
32
|
18
|
JspImplicitObjects jspImplicitObjects = (JspImplicitObjects)this.webImplicitObjects;
|
33
|
18
|
super.setTestCaseFields(jspInstance);
|
34
|
18
|
HttpServletRequest request = jspImplicitObjects.getHttpServletRequest();
|
35
|
18
|
ServletURL url = ServletURL.loadFromRequest(request);
|
36
|
18
|
Field pageContextField = jspInstance.getClass().getField("pageContext");
|
37
|
18
|
pageContextField.set(jspInstance, new PageContextWrapper(jspImplicitObjects.getPageContext(),
|
38
|
|
url));
|
39
|
18
|
Field outField = jspInstance.getClass().getField("out");
|
40
|
18
|
outField.set(jspInstance, jspImplicitObjects.getJspWriter());
|
41
|
|
}
|
42
|
|
|
43
|
|
/**
|
44
|
|
* @see AbstractWebTestCaller#getResponseWriter()
|
45
|
|
*/
|
46
|
18
|
protected Writer getResponseWriter() throws IOException {
|
47
|
18
|
JspImplicitObjects jspImplicitObjects = (JspImplicitObjects)this.webImplicitObjects;
|
48
|
18
|
return jspImplicitObjects.getJspWriter();
|
49
|
|
}
|
50
|
|
|
51
|
|
}
|