KickJava   Java API By Example, From Geeks To Geeks.

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


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

28 public class TestPortletWebResponse extends BasePortletWebTestCase
29 {
30     private PortletResponse newResponse()
31     {
32         return (PortletResponse) newMock(PortletResponse.class);
33     }
34
35     public void testGetOutputStreamUnsupported() throws Exception JavaDoc
36     {
37         PortletResponse response = newResponse();
38
39         replayControls();
40
41         PortletWebResponse pwr = new PortletWebResponse(response);
42
43         try
44         {
45             pwr.getOutputStream(new ContentType("foo/bar"));
46             unreachable();
47         }
48         catch (UnsupportedOperationException JavaDoc ex)
49         {
50             // Expected.
51
}
52
53         verifyControls();
54     }
55
56     public void testGetNamespace() throws Exception JavaDoc
57     {
58         PortletResponse response = newResponse();
59
60         replayControls();
61
62         PortletWebResponse pwr = new PortletWebResponse(response);
63
64         assertEquals("", pwr.getNamespace());
65
66         verifyControls();
67     }
68
69     public void testResetUnsupported()
70     {
71         PortletResponse response = newResponse();
72
73         replayControls();
74
75         PortletWebResponse pwr = new PortletWebResponse(response);
76
77         try
78         {
79             pwr.reset();
80             unreachable();
81         }
82         catch (UnsupportedOperationException JavaDoc ex)
83         {
84             // Expected.
85
}
86
87         verifyControls();
88     }
89
90     public void testEncodeURL()
91     {
92         MockControl control = newControl(PortletResponse.class);
93         PortletResponse response = (PortletResponse) control.getMock();
94
95         response.encodeURL("/foo");
96         control.setReturnValue("/foo;encoded");
97
98         replayControls();
99
100         PortletWebResponse pwr = new PortletWebResponse(response);
101
102         assertEquals("/foo;encoded", pwr.encodeURL("/foo"));
103
104         verifyControls();
105     }
106 }
Popular Tags