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

LineHitsSource
1 /*
2  * Copyright (C) 2006 TopCoder Inc., All Rights Reserved.
3  */
4 package com.topcoder.testframework.web;
5  
6 import org.apache.cactus.FilterTestCase;
7  
8 import javax.servlet.FilterChain;
9 import javax.servlet.FilterConfig;
10 import javax.servlet.http.HttpServletRequest;
11 import javax.servlet.http.HttpServletResponse;
12  
13  
14 /**
15  * This class represents JUnit test case to unit test code that needs an access to valid Filter implicit objects (such
16  * as the FilterConfig and FilterChain objects) This implementation of the class is derived from Cactus FilterTestCase,
17  * and just adds more high level access to Filter objects. Filter objects should be accessed by the derived classes
18  * using the getter methods provided by this class. Derived classes should not use directly methods and fields defined
19  * 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 TCFilterTestCase extends FilterTestCase {
53  
54     /**
55      * Default constructor defined in order to allow creating Test Case without needing to define constructor (new
56      * feature in JUnit 3.8.1).
57      */
58     public TCFilterTestCase() {
597        super();
607    }
61  
62     /**
63      * Constructs a TCFilterTestCase with the given name.
64      *
65      * @param name the name of the test case
66      */
67     public TCFilterTestCase(final String name) {
681        super(name);
691    }
70  
71     /**
72      * This method returns a valid {@link FilterConfig} object that can be accessed from the <tt>testXXX()</tt>, {@link
73      * #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 FilterConfig} object currently in scope
79      */
80     public FilterConfig getConfig() {
814        return config;
82     }
83  
84     /**
85      * This method returns a valid {@link FilterChain} object that can be accessed from the <tt>testXXX()</tt>, {@link
86      * #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 FilterChain} object currently in scope
92      */
93     public FilterChain getFilterChain() {
944        return filterChain;
95     }
96  
97     /**
98      * This method returns a valid {@link HttpServletRequest} 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 HttpServletRequest} object currently in scope
105      */
106     public HttpServletRequest getRequest() {
1074        return request;
108     }
109  
110     /**
111      * This method returns a valid {@link HttpServletResponse} object that can be accessed from the <tt>testXXX()</tt>,
112      * {@link #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 HttpServletResponse} object currently in scope
118      */
119     public HttpServletResponse getResponse() {
1204        return response;
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.