001: /*
002: * ========================================================================
003: *
004: * Copyright 2001-2004 The Apache Software Foundation.
005: *
006: * Licensed under the Apache License, Version 2.0 (the "License");
007: * you may not use this file except in compliance with the License.
008: * You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing, software
013: * distributed under the License is distributed on an "AS IS" BASIS,
014: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: *
018: * ========================================================================
019: */
020: package org.apache.cactus;
021:
022: import javax.servlet.http.HttpServletResponse;
023: import javax.servlet.http.HttpSession;
024:
025: import junit.framework.Test;
026:
027: import org.apache.cactus.internal.AbstractCactusTestCase;
028: import org.apache.cactus.internal.CactusTestCase;
029: import org.apache.cactus.internal.client.connector.http.HttpProtocolHandler;
030: import org.apache.cactus.internal.configuration.DefaultServletConfiguration;
031: import org.apache.cactus.server.ServletConfigWrapper;
032: import org.apache.cactus.spi.client.connector.ProtocolHandler;
033:
034: /**
035: * Cactus test case to unit test Servlets. Test classes that need access to
036: * valid Servlet implicit objects (such as the HTTP request, the HTTP response,
037: * the servlet config, ...) must subclass this class.
038: *
039: * @version $Id: ServletTestCase.java 238991 2004-05-22 11:34:50Z vmassol $
040: */
041: public class ServletTestCase extends AbstractCactusTestCase implements
042: CactusTestCase {
043: /**
044: * Valid <code>HttpServletRequest</code> object that you can access from
045: * the <code>testXXX()</code>, <code>setUp</code> and
046: * <code>tearDown()</code> methods. If you try to access it from either the
047: * <code>beginXXX()</code> or <code>endXXX()</code> methods it will
048: * have the <code>null</code> value.
049: */
050: public org.apache.cactus.server.HttpServletRequestWrapper request;
051:
052: /**
053: * Valid <code>HttpServletResponse</code> object that you can access from
054: * the <code>testXXX()</code>, <code>setUp</code> and
055: * <code>tearDown()</code> methods. If you try to access it from either the
056: * <code>beginXXX()</code> or <code>endXXX()</code> methods it will
057: * have the <code>null</code> value.
058: */
059: public HttpServletResponse response;
060:
061: /**
062: * Valid <code>HttpSession</code> object that you can access from
063: * the <code>testXXX()</code>, <code>setUp</code> and
064: * <code>tearDown()</code> methods. If you try to access it from either the
065: * <code>beginXXX()</code> or <code>endXXX()</code> methods it will
066: * have the <code>null</code> value.
067: */
068: public HttpSession session;
069:
070: /**
071: * Valid <code>ServletConfig</code> object that you can access from
072: * the <code>testXXX()</code>, <code>setUp</code> and
073: * <code>tearDown()</code> methods. If you try to access it from either the
074: * <code>beginXXX()</code> or <code>endXXX()</code> methods it will
075: * have the <code>null</code> value.
076: */
077: public ServletConfigWrapper config;
078:
079: /**
080: * @see AbstractCactusTestCase#AbstractCactusTestCase()
081: */
082: public ServletTestCase() {
083: super ();
084: }
085:
086: /**
087: * @see AbstractCactusTestCase#AbstractCactusTestCase(String)
088: */
089: public ServletTestCase(String theName) {
090: super (theName);
091: }
092:
093: /**
094: * @see AbstractCactusTestCase#AbstractCactusTestCase(String, Test)
095: */
096: public ServletTestCase(String theName, Test theTest) {
097: super (theName, theTest);
098: }
099:
100: /**
101: * @see AbstractCactusTestCase#createProtocolHandler()
102: */
103: protected ProtocolHandler createProtocolHandler() {
104: return new HttpProtocolHandler(
105: new DefaultServletConfiguration());
106: }
107: }
|