Coverage details for com.topcoder.testframework.web.TCJspTestCase

LineHitsSource
1 /*
2  * Copyright (C) 2006 TopCoder Inc., All Rights Reserved.
3  */
4 package com.topcoder.testframework.web;
5  
6 import org.apache.cactus.JspTestCase;
7  
8 import javax.servlet.ServletConfig;
9 import javax.servlet.http.HttpServletRequest;
10 import javax.servlet.http.HttpServletResponse;
11 import javax.servlet.http.HttpSession;
12 import javax.servlet.jsp.JspWriter;
13 import javax.servlet.jsp.PageContext;
14  
15  
16 /**
17  * This class represents JUnit test case to unit test code that needs an access to valid JSP implicit objects (such as
18  * the page context, the output jsp writer, the HTTP request, ...) This implementation of the class is derived from
19  * Cactus JspTestCase, and just adds more high level access to Jsp objects. Jsp objects should be accessed by the
20  * derived classes using the getter methods provided by this class. Derived classes should not use directly methods and
21  * fields defined by the Cactus framework.
22  * <p/>
23  * This class is mutable, i.e. not thread-safe.
24  * <p/>
25  * For each XXX test case, you can define a corresponding beginXXX() method(optional). It will be run on the client
26  * side. It can be used to initialize HTTP related parameters (HTTP parameters, cookies, HTTP headers, URL to simulate,
27  * ...). One will be able to retrieve these values in your testXXX() by calling the different API of HttpServletRequest
28  * (like getQueryString(), getCookies(), getHeader(), ...).
29  * <p/>
30  * The signature of the begin method is:
31  * <p/>
32  * <pre>
33  * public void beginXXX(org.apache.cactus.WebRequest theRequest) {
34  * [...]
35  * }
36  * </pre>
37  * <p/>
38  * where theRequest is the object that you use to set all the HTTP related parameters.
39  * <p/>
40  * For each XXX test case, you can define a corresponding endXXX() method. This method is called on the client side. You
41  * will use this method to verify the returned HTTP related parameters from your test case (like the returned content of
42  * the HTTP response, any returned cookies, returned HTTP headers, ...).
43  * <p/>
44  * The signature of the end method is:
45  * <pre>
46  * public void endXXX(org.apache.cactus.WebResponse theResponse) {
47  * [...]
48  * }
49  * </pre>
50  *
51  * @author real_vg, TCSDEVELOPER
52  * @version 1.0
53  */
54 public class TCJspTestCase extends JspTestCase {
55  
56     /**
57      * Default constructor defined in order to allow creating Test Case without needing to define constructor (new
58      * feature in JUnit 3.8.1).
59      */
60     public TCJspTestCase() {
619        super();
629    }
63  
64     /**
65      * Constructs a TCJspTestCase with the given name.
66      *
67      * @param name the name of the test case
68      */
69     public TCJspTestCase(final String name) {
701        super(name);
711    }
72  
73     /**
74      * This method returns a valid {@link javax.servlet.ServletConfig} object that can be accessed from the
75      * <tt>testXXX()</tt>, {@link #setUp()} and {@link #tearDown()} methods.
76      * <p/>
77      * <b>Note:</b> Calling this method from either the <tt>beginXXX()</tt> or <tt>endXXX()</tt> methods will return
78      * <tt>null</tt>.
79      *
80      * @return the {@link javax.servlet.ServletConfig} object currently in scope
81      */
82     public ServletConfig getConfig() {
834        return config;
84     }
85  
86     /**
87      * This method returns a valid {@link HttpServletRequest} object that can be accessed from the <tt>testXXX()</tt>,
88      * {@link #setUp()} and {@link #tearDown()} methods.
89      * <p/>
90      * <b>Note:</b> Calling this method from either the <tt>beginXXX()</tt> or <tt>endXXX()</tt> methods will return
91      * <tt>null</tt>.
92      *
93      * @return the {@link HttpServletRequest} object currently in scope
94      */
95     public HttpServletRequest getRequest() {
964        return request;
97     }
98  
99     /**
100      * This method returns a valid {@link HttpServletResponse} object that can be accessed from the <tt>testXXX()</tt>,
101      * {@link #setUp()} and {@link #tearDown()} methods.
102      * <p/>
103      * <b>Note:</b> Calling this method from either the <tt>beginXXX()</tt> or <tt>endXXX()</tt> methods will return
104      * <tt>null</tt>.
105      *
106      * @return the {@link HttpServletResponse} object currently in scope
107      */
108     public HttpServletResponse getResponse() {
1094        return response;
110     }
111  
112     /**
113      * This method returns a valid {@link HttpSession} object that can be accessed from the <tt>testXXX()</tt>, {@link
114      * #setUp()} and {@link #tearDown()} methods.
115      * <p/>
116      * <b>Note:</b> Calling this method from either the <tt>beginXXX()</tt> or <tt>endXXX()</tt> methods will return
117      * <tt>null</tt>.
118      *
119      * @return the {@link HttpSession} object currently in scope
120      */
121     public HttpSession getSession() {
1224        return session;
123     }
124  
125     /**
126      * This method returns a valid {@link JspWriter} object that can be accessed from the <tt>testXXX()</tt>, {@link
127      * #setUp()} and {@link #tearDown()} methods.
128      * <p/>
129      * <b>Note:</b> Calling this method from either the <tt>beginXXX()</tt> or <tt>endXXX()</tt> methods will return
130      * <tt>null</tt>.
131      *
132      * @return the {@link JspWriter} object currently in scope
133      */
134     public JspWriter getOut() {
1355        return out;
136     }
137  
138     /**
139      * This method returns a valid {@link PageContext} object that can be accessed from the <tt>testXXX()</tt>, {@link
140      * #setUp()} and {@link #tearDown()} methods.
141      * <p/>
142      * <b>Note:</b> Calling this method from either the <tt>beginXXX()</tt> or <tt>endXXX()</tt> methods will return
143      * <tt>null</tt>.
144      *
145      * @return the {@link PageContext} object currently in scope
146      */
147     public PageContext getPageContext() {
1483        return pageContext;
149     }
150 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.