1 /*
2 * ========================================================================
3 *
4 * Licensed to the Apache Software Foundation (ASF) under one or more
5 * contributor license agreements. See the NOTICE file distributed with
6 * this work for additional information regarding copyright ownership.
7 * The ASF licenses this file to You under the Apache License, Version 2.0
8 * (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 * ========================================================================
20 */
21 package org.apache.cactus;
22
23 import javax.servlet.http.HttpServletResponse;
24 import javax.servlet.http.HttpSession;
25
26 import junit.framework.Test;
27
28 import org.apache.cactus.internal.AbstractCactusTestCase;
29 import org.apache.cactus.internal.CactusTestCase;
30 import org.apache.cactus.internal.client.connector.http.HttpProtocolHandler;
31 import org.apache.cactus.internal.configuration.DefaultServletConfiguration;
32 import org.apache.cactus.server.AbstractServletConfigWrapper;
33 import org.apache.cactus.spi.client.connector.ProtocolHandler;
34
35 /**
36 * Cactus test case to unit test Servlets. Test classes that need access to
37 * valid Servlet implicit objects (such as the HTTP request, the HTTP response,
38 * the servlet config, ...) must subclass this class.
39 *
40 * @version $Id: ServletTestCase.java 238991 2004-05-22 11:34:50Z vmassol $
41 */
42 public class ServletTestCase
43 extends AbstractCactusTestCase implements CactusTestCase
44 {
45 /**
46 * Valid <code>HttpServletRequest</code> object that you can access from
47 * the <code>testXXX()</code>, <code>setUp</code> and
48 * <code>tearDown()</code> methods. If you try to access it from either the
49 * <code>beginXXX()</code> or <code>endXXX()</code> methods it will
50 * have the <code>null</code> value.
51 */
52 public org.apache.cactus.server.AbstractHttpServletRequestWrapper request;
53
54 /**
55 * Valid <code>HttpServletResponse</code> object that you can access from
56 * the <code>testXXX()</code>, <code>setUp</code> and
57 * <code>tearDown()</code> methods. If you try to access it from either the
58 * <code>beginXXX()</code> or <code>endXXX()</code> methods it will
59 * have the <code>null</code> value.
60 */
61 public HttpServletResponse response;
62
63 /**
64 * Valid <code>HttpSession</code> object that you can access from
65 * the <code>testXXX()</code>, <code>setUp</code> and
66 * <code>tearDown()</code> methods. If you try to access it from either the
67 * <code>beginXXX()</code> or <code>endXXX()</code> methods it will
68 * have the <code>null</code> value.
69 */
70 public HttpSession session;
71
72 /**
73 * Valid <code>ServletConfig</code> object that you can access from
74 * the <code>testXXX()</code>, <code>setUp</code> and
75 * <code>tearDown()</code> methods. If you try to access it from either the
76 * <code>beginXXX()</code> or <code>endXXX()</code> methods it will
77 * have the <code>null</code> value.
78 */
79 public AbstractServletConfigWrapper config;
80
81 /**
82 * @see AbstractCactusTestCase#AbstractCactusTestCase()
83 */
84 public ServletTestCase()
85 {
86 super();
87 }
88
89 /**
90 * {@inheritDoc}
91 * @see AbstractCactusTestCase#AbstractCactusTestCase(String)
92 */
93 public ServletTestCase(String theName)
94 {
95 super(theName);
96 }
97
98 /**
99 * {@inheritDoc}
100 * @see AbstractCactusTestCase#AbstractCactusTestCase(String, Test)
101 */
102 public ServletTestCase(String theName, Test theTest)
103 {
104 super(theName, theTest);
105 }
106
107 /**
108 * {@inheritDoc}
109 * @see AbstractCactusTestCase#createProtocolHandler()
110 */
111 protected ProtocolHandler createProtocolHandler()
112 {
113 return new HttpProtocolHandler(new DefaultServletConfiguration());
114 }
115 }