01: /*
02: * ========================================================================
03: *
04: * Copyright 2001-2003 The Apache Software Foundation.
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: *
18: * ========================================================================
19: */
20: package org.apache.cactus.sample.servlet.unit;
21:
22: import java.util.Map;
23:
24: import org.apache.cactus.ServletTestCase;
25: import org.apache.cactus.WebRequest;
26:
27: /**
28: * Test HTTP request methods specific to Servlet API 2.3.
29: *
30: * @version $Id: TestHttpRequestSpecific.java 238816 2004-02-29 16:36:46Z vmassol $
31: */
32: public class TestHttpRequestSpecific extends ServletTestCase {
33: /**
34: * Verify that <code>HttpServletRequest.getParameterMap()</code> works.
35: *
36: * @param theRequest the request object that serves to initialize the
37: * HTTP connection to the server redirector.
38: */
39: public void beginGetParameterMap(WebRequest theRequest) {
40: theRequest.addParameter("multivalue", "value 1");
41: theRequest.addParameter("multivalue", "value 2");
42: }
43:
44: /**
45: * Verify that <code>HttpServletRequest.getParameterMap()</code> works.
46: */
47: public void testGetParameterMap() {
48: Map parameters = request.getParameterMap();
49: assertTrue(parameters.containsKey("multivalue"));
50: String[] values = (String[]) parameters.get("multivalue");
51: assertEquals(2, values.length);
52: assertEquals("value 1", values[0]);
53: assertEquals("value 2", values[1]);
54: }
55:
56: //-------------------------------------------------------------------------
57:
58: /**
59: * Verifies that the wrapped HTTP request is a simple pass through when no
60: * simulation URL is defined.
61: */
62: public void testRequestURL() {
63: StringBuffer realURL = request.getOriginalRequest()
64: .getRequestURL();
65: StringBuffer wrappedURL = request.getRequestURL();
66:
67: assertEquals(realURL.toString(), wrappedURL.toString());
68: }
69:
70: }
|