KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > portlet > TestRenderWebResponse


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.portlet;
16
17 import javax.portlet.RenderResponse;
18
19 import org.apache.tapestry.util.ContentType;
20 import org.easymock.MockControl;
21
22 /**
23  * Tests for {@link org.apache.tapestry.portlet.RenderWebResponse}.
24  *
25  * @author Howard M. Lewis Ship
26  * @since 4.0
27  */

28 public class TestRenderWebResponse extends BasePortletWebTestCase
29 {
30     private RenderResponse newResponse()
31     {
32         return (RenderResponse) newMock(RenderResponse.class);
33     }
34
35     public void testReset()
36     {
37         RenderResponse response = newResponse();
38
39         response.reset();
40
41         replayControls();
42
43         RenderWebResponse rwr = new RenderWebResponse(response);
44
45         rwr.reset();
46
47         verifyControls();
48     }
49
50     public void testGetOutputStream() throws Exception JavaDoc
51     {
52         MockControl control = newControl(RenderResponse.class);
53         RenderResponse response = (RenderResponse) control.getMock();
54         replayControls();
55
56         RenderWebResponse rwr = new RenderWebResponse(response);
57
58         try
59         {
60             rwr.getOutputStream(new ContentType("foo/bar"));
61             unreachable();
62         }
63         catch (UnsupportedOperationException JavaDoc ex)
64         {
65             // Expected.
66
}
67
68         verifyControls();
69     }
70
71     public void testGetNamespace()
72     {
73         MockControl control = newControl(RenderResponse.class);
74         RenderResponse response = (RenderResponse) control.getMock();
75
76         response.getNamespace();
77         control.setReturnValue("_NAMESPACE_");
78
79         replayControls();
80
81         RenderWebResponse rwr = new RenderWebResponse(response);
82
83         assertEquals("_NAMESPACE_", rwr.getNamespace());
84
85         verifyControls();
86     }
87 }
Popular Tags