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

LineHitsSource
1 /*
2  * Copyright (C) 2006 TopCoder Inc., All Rights Reserved.
3  */
4 package com.topcoder.testframework.web;
5  
6 import org.apache.cactus.ServletTestCase;
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  
13  
14 /**
15  * This class represents JUnit test case to unit test code that needs an access to valid Servlet implicit objects (such
16  * as the HTTP request, the HTTP response, the servlet config, ...) This implementation of the class is derived from
17  * Cactus ServletTestCase, and just adds more high level access to Servlet objects. Servlet objects should be accessed
18  * by the derived classes using the getter methods provided by this class. Derived classes should not use directly
19  * methods and fields defined by the Cactus framework.
20  * <p/>
21  * This class is mutable, i.e. not thread-safe.
22  * <p/>
23  * For each XXX test case, you can define a corresponding beginXXX() method(optional). It will be run on the client
24  * side. It can be used to initialize HTTP related parameters (HTTP parameters, cookies, HTTP headers, URL to simulate,
25  * ...). One will be able to retrieve these values in your testXXX() by calling the different API of HttpServletRequest
26  * (like getQueryString(), getCookies(), getHeader(), ...).
27  * <p/>
28  * The signature of the begin method is:
29  * <p/>
30  * <pre>
31  * public void beginXXX(org.apache.cactus.WebRequest theRequest) {
32  * [...]
33  * }
34  * </pre>
35  * <p/>
36  * where theRequest is the object that you use to set all the HTTP related parameters.
37  * <p/>
38  * For each XXX test case, you can define a corresponding endXXX() method. This method is called on the client side. You
39  * will use this method to verify the returned HTTP related parameters from your test case (like the returned content of
40  * the HTTP response, any returned cookies, returned HTTP headers, ...).
41  * <p/>
42  * The signature of the end method is:
43  * <pre>
44  * public void endXXX(org.apache.cactus.WebResponse theResponse) {
45  * [...]
46  * }
47  * </pre>
48  *
49  * @author real_vg, TCSDEVELOPER
50  * @version 1.0
51  */
52 public class TCServletTestCase extends ServletTestCase {
53  
54     /**
55      * This is a Default constructor defined in order to allow creating Test Case without needing to define constructor
56      * (new feature in JUnit 3.8.1).
57      */
58     public TCServletTestCase() {
597        super();
607    }
61  
62     /**
63      * Constructs a TCServletTestCase test case with the given name.
64      *
65      * @param name the name of the test case
66      */
67     public TCServletTestCase(final String name) {
681        super(name);
691    }
70  
71     /**
72      * This method returns a valid {@link javax.servlet.ServletConfig} object that can be accessed from the
73      * <tt>testXXX()</tt>, {@link #setUp()} and {@link #tearDown()} methods.
74      * <p/>
75      * <b>Note:</b> Calling this method from either the <tt>beginXXX()</tt> or <tt>endXXX()</tt> methods will return
76      * <tt>null</tt>.
77      *
78      * @return the {@link javax.servlet.ServletConfig} object currently in scope
79      */
80     public ServletConfig getConfig() {
814        return config;
82     }
83  
84     /**
85      * This method returns a valid {@link HttpServletRequest} object that can be accessed from the <tt>testXXX()</tt>,
86      * {@link #setUp()} and {@link #tearDown()} methods.
87      * <p/>
88      * <b>Note:</b> Calling this method from either the <tt>beginXXX()</tt> or <tt>endXXX()</tt> methods will return
89      * <tt>null</tt>.
90      *
91      * @return the {@link HttpServletRequest} object currently in scope
92      */
93     public HttpServletRequest getRequest() {
944        return request;
95     }
96  
97     /**
98      * This method returns a valid {@link HttpServletResponse} object that can be accessed from the <tt>testXXX()</tt>,
99      * {@link #setUp()} and {@link #tearDown()} methods.
100      * <p/>
101      * <b>Note:</b> Calling this method from either the <tt>beginXXX()</tt> or <tt>endXXX()</tt> methods will return
102      * <tt>null</tt>.
103      *
104      * @return the {@link HttpServletResponse} object currently in scope
105      */
106     public HttpServletResponse getResponse() {
1074        return response;
108     }
109  
110     /**
111      * This method returns a valid {@link HttpSession} object that can be accessed from the <tt>testXXX()</tt>, {@link
112      * #setUp()} and {@link #tearDown()} methods.
113      * <p/>
114      * <b>Note:</b> Calling this method from either the <tt>beginXXX()</tt> or <tt>endXXX()</tt> methods will return
115      * <tt>null</tt>.
116      *
117      * @return the {@link HttpSession} object currently in scope
118      */
119     public HttpSession getSession() {
1204        return session;
121     }
122 }

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.