KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cactus > sample > servlet > unit > TestHttpRequestSpecific


1 /*
2  * ========================================================================
3  *
4  * Copyright 2001-2003 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
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 JavaDoc;
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,v 1.3 2004/02/29 16:36:45 vmassol Exp $
31  */

32 public class TestHttpRequestSpecific extends ServletTestCase
33 {
34     /**
35      * Verify that <code>HttpServletRequest.getParameterMap()</code> works.
36      *
37      * @param theRequest the request object that serves to initialize the
38      * HTTP connection to the server redirector.
39      */

40     public void beginGetParameterMap(WebRequest theRequest)
41     {
42         theRequest.addParameter("multivalue", "value 1");
43         theRequest.addParameter("multivalue", "value 2");
44     }
45
46     /**
47      * Verify that <code>HttpServletRequest.getParameterMap()</code> works.
48      */

49     public void testGetParameterMap()
50     {
51         Map JavaDoc parameters = request.getParameterMap();
52         assertTrue(parameters.containsKey("multivalue"));
53         String JavaDoc[] values = (String JavaDoc[]) parameters.get("multivalue");
54         assertEquals(2, values.length);
55         assertEquals("value 1", values[0]);
56         assertEquals("value 2", values[1]);
57     }
58
59     //-------------------------------------------------------------------------
60

61     /**
62      * Verifies that the wrapped HTTP request is a simple pass through when no
63      * simulation URL is defined.
64      */

65     public void testRequestURL()
66     {
67         StringBuffer JavaDoc realURL = request.getOriginalRequest().getRequestURL();
68         StringBuffer JavaDoc wrappedURL = request.getRequestURL();
69
70         assertEquals(realURL.toString(), wrappedURL.toString());
71     }
72
73 }
74
Popular Tags