KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > request > TestDecodedRequestWrapper


1 // Copyright 2005 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package org.apache.tapestry.request;
16
17 import javax.servlet.http.HttpServletRequest JavaDoc;
18
19 import org.apache.hivemind.test.HiveMindTestCase;
20 import org.easymock.MockControl;
21
22 /**
23  * Tests for {@link org.apache.tapestry.request.DecodedRequestWrapper}and
24  * {@link org.apache.tapestry.request.DecodedRequest}.
25  *
26  * @author Howard M. Lewis Ship
27  * @since 4.0
28  */

29 public class TestDecodedRequestWrapper extends HiveMindTestCase
30 {
31     private HttpServletRequest JavaDoc newRequest()
32     {
33         return (HttpServletRequest JavaDoc) newMock(HttpServletRequest JavaDoc.class);
34     }
35
36     public void testInterceptedMethods()
37     {
38         DecodedRequest dr = new DecodedRequest();
39
40         dr.setRequestURI("/foo/bar/baz");
41         dr.setScheme("https");
42         dr.setServerPort(2170);
43         dr.setServerName("www.flintstone.com");
44
45         HttpServletRequest JavaDoc request = newRequest();
46
47         replayControls();
48
49         DecodedRequestWrapper w = new DecodedRequestWrapper(request, dr);
50
51         assertEquals("/foo/bar/baz", w.getRequestURI());
52         assertEquals("https", w.getScheme());
53         assertEquals(2170, w.getServerPort());
54         assertEquals("www.flintstone.com", w.getServerName());
55
56         verifyControls();
57     }
58
59     public void testRequestConstructor()
60     {
61         MockControl control = newControl(HttpServletRequest JavaDoc.class);
62         HttpServletRequest JavaDoc request = (HttpServletRequest JavaDoc) control.getMock();
63
64         request.getScheme();
65         control.setReturnValue("https");
66
67         request.getServerName();
68         control.setReturnValue("www.flintstone.com");
69
70         request.getRequestURI();
71         control.setReturnValue("/foo/bar/baz");
72
73         request.getServerPort();
74         control.setReturnValue(2170);
75
76         replayControls();
77
78         DecodedRequest dr = new DecodedRequest(request);
79
80         assertEquals("/foo/bar/baz", dr.getRequestURI());
81         assertEquals("https", dr.getScheme());
82         assertEquals(2170, dr.getServerPort());
83         assertEquals("www.flintstone.com", dr.getServerName());
84
85         verifyControls();
86     }
87 }
Popular Tags