|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
JspTestCase.java | - | 0% | 0% | 0% |
|
1 |
/*
|
|
2 |
* ====================================================================
|
|
3 |
*
|
|
4 |
* The Apache Software License, Version 1.1
|
|
5 |
*
|
|
6 |
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
|
|
7 |
* reserved.
|
|
8 |
*
|
|
9 |
* Redistribution and use in source and binary forms, with or without
|
|
10 |
* modification, are permitted provided that the following conditions
|
|
11 |
* are met:
|
|
12 |
*
|
|
13 |
* 1. Redistributions of source code must retain the above copyright
|
|
14 |
* notice, this list of conditions and the following disclaimer.
|
|
15 |
*
|
|
16 |
* 2. Redistributions in binary form must reproduce the above copyright
|
|
17 |
* notice, this list of conditions and the following disclaimer in
|
|
18 |
* the documentation and/or other materials provided with the
|
|
19 |
* distribution.
|
|
20 |
*
|
|
21 |
* 3. The end-user documentation included with the redistribution, if
|
|
22 |
* any, must include the following acknowlegement:
|
|
23 |
* "This product includes software developed by the
|
|
24 |
* Apache Software Foundation (http://www.apache.org/)."
|
|
25 |
* Alternately, this acknowlegement may appear in the software itself,
|
|
26 |
* if and wherever such third-party acknowlegements normally appear.
|
|
27 |
*
|
|
28 |
* 4. The names "The Jakarta Project", "Cactus" and "Apache Software
|
|
29 |
* Foundation" must not be used to endorse or promote products
|
|
30 |
* derived from this software without prior written permission. For
|
|
31 |
* written permission, please contact apache@apache.org.
|
|
32 |
*
|
|
33 |
* 5. Products derived from this software may not be called "Apache"
|
|
34 |
* nor may "Apache" appear in their names without prior written
|
|
35 |
* permission of the Apache Group.
|
|
36 |
*
|
|
37 |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
|
38 |
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
39 |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
40 |
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
|
41 |
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
42 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
43 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
|
44 |
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
45 |
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
46 |
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
|
47 |
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
48 |
* SUCH DAMAGE.
|
|
49 |
* ====================================================================
|
|
50 |
*
|
|
51 |
* This software consists of voluntary contributions made by many
|
|
52 |
* individuals on behalf of the Apache Software Foundation. For more
|
|
53 |
* information on the Apache Software Foundation, please see
|
|
54 |
* <http://www.apache.org/>.
|
|
55 |
*
|
|
56 |
*/
|
|
57 |
package org.apache.cactus;
|
|
58 |
|
|
59 |
import javax.servlet.jsp.JspWriter;
|
|
60 |
|
|
61 |
import junit.framework.Test;
|
|
62 |
|
|
63 |
import org.apache.cactus.configuration.ConfigurationInitializer;
|
|
64 |
import org.apache.cactus.configuration.JspConfiguration;
|
|
65 |
import org.apache.cactus.internal.client.WebClientTestCaseDelegate;
|
|
66 |
import org.apache.cactus.internal.server.ServerTestCaseDelegate;
|
|
67 |
import org.apache.cactus.server.PageContextWrapper;
|
|
68 |
|
|
69 |
/**
|
|
70 |
* Test classes that need access to valid JSP implicit objects (such as the
|
|
71 |
* page context, the output jsp writer, the HTTP request, ...) must subclass
|
|
72 |
* this class.
|
|
73 |
*
|
|
74 |
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
|
|
75 |
*
|
|
76 |
* @version $Id: JspTestCase.java,v 1.13.2.1 2003/10/23 15:10:08 vmassol Exp $
|
|
77 |
*/
|
|
78 |
public class JspTestCase extends ServletTestCase |
|
79 |
{ |
|
80 |
/**
|
|
81 |
* As this class is the first one loaded on the client side, we ensure
|
|
82 |
* that the Cactus configuration has been initialized. In the future,
|
|
83 |
* this block will be removed as all initialization will be done in Cactus
|
|
84 |
* test suites. However, as we still support using Cactus TestCase classes
|
|
85 |
* we don't a proper initialization hook and thus we need this hack.
|
|
86 |
*/
|
|
87 |
static
|
|
88 |
{ |
|
89 | 0 |
ConfigurationInitializer.initialize(); |
90 |
} |
|
91 |
|
|
92 |
/**
|
|
93 |
* Valid <code>PageContext</code> object that you can access from
|
|
94 |
* the <code>testXXX()</code>, <code>setUp</code> and
|
|
95 |
* <code>tearDown()</code> methods. If you try to access it from either the
|
|
96 |
* <code>beginXXX()</code> or <code>endXXX()</code> methods it will
|
|
97 |
* have the <code>null</code> value.
|
|
98 |
*/
|
|
99 |
public PageContextWrapper pageContext;
|
|
100 |
|
|
101 |
/**
|
|
102 |
* Valid <code>JspWriter</code> object that you can access from
|
|
103 |
* the <code>testXXX()</code>, <code>setUp</code> and
|
|
104 |
* <code>tearDown()</code> methods. If you try to access it from either the
|
|
105 |
* <code>beginXXX()</code> or <code>endXXX()</code> methods it will
|
|
106 |
* have the <code>null</code> value.
|
|
107 |
*/
|
|
108 |
public JspWriter out;
|
|
109 |
|
|
110 |
/**
|
|
111 |
* Initializations common to all constructors.
|
|
112 |
*
|
|
113 |
* @param theTest a pure JUnit Test that Cactus will wrap
|
|
114 |
*/
|
|
115 | 0 |
void init(Test theTest)
|
116 |
{ |
|
117 | 0 |
setClientDelegate(new WebClientTestCaseDelegate(
|
118 |
this, theTest, new JspConfiguration())); |
|
119 | 0 |
setServerDelegate(new ServerTestCaseDelegate(this, theTest)); |
120 |
} |
|
121 |
|
|
122 |
/**
|
|
123 |
* Default constructor defined in order to allow creating Test Case
|
|
124 |
* without needing to define constructor (new feature in JUnit 3.8.1).
|
|
125 |
* Should only be used with JUnit 3.8.1 or greater.
|
|
126 |
*
|
|
127 |
* @since 1.5
|
|
128 |
*/
|
|
129 | 0 |
public JspTestCase()
|
130 |
{ |
|
131 | 0 |
super();
|
132 |
} |
|
133 |
|
|
134 |
/**
|
|
135 |
* Constructs a JUnit test case with the given name.
|
|
136 |
*
|
|
137 |
* @param theName the name of the test case
|
|
138 |
*/
|
|
139 | 0 |
public JspTestCase(String theName)
|
140 |
{ |
|
141 | 0 |
super(theName);
|
142 |
} |
|
143 |
|
|
144 |
/**
|
|
145 |
* Wraps a pure JUnit Test Case in a Cactus Test Case.
|
|
146 |
*
|
|
147 |
* @param theName the name of the test
|
|
148 |
* @param theTest the Test Case class to wrap
|
|
149 |
* @since 1.5
|
|
150 |
*/
|
|
151 | 0 |
public JspTestCase(String theName, Test theTest)
|
152 |
{ |
|
153 | 0 |
super(theName, theTest);
|
154 |
} |
|
155 |
|
|
156 |
} |
|
157 |
|
|