1   /*
2    * Copyright 2001-2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.portletbridge.mock;
17  
18  import java.io.IOException;
19  import java.io.OutputStream;
20  import java.io.PrintWriter;
21  import java.io.StringWriter;
22  import java.util.Locale;
23  
24  import javax.portlet.PortletURL;
25  import javax.portlet.RenderResponse;
26  
27  /***
28   * @author jmccrindle
29   */
30  public class MockRenderResponse implements RenderResponse {
31  
32      private StringWriter writer = new StringWriter();
33      private String contentType = null;
34      private String title;
35      
36      /***
37       * 
38       */
39      public MockRenderResponse() {
40          super();
41      }
42  
43      /* (non-Javadoc)
44       * @see javax.portlet.RenderResponse#getContentType()
45       */
46      public String getContentType() {
47          return contentType;
48      }
49  
50      /* (non-Javadoc)
51       * @see javax.portlet.RenderResponse#createRenderURL()
52       */
53      public PortletURL createRenderURL() {
54          return new MockPortletURL();
55      }
56  
57      /* (non-Javadoc)
58       * @see javax.portlet.RenderResponse#createActionURL()
59       */
60      public PortletURL createActionURL() {
61          return new MockPortletURL();
62      }
63  
64      /* (non-Javadoc)
65       * @see javax.portlet.RenderResponse#getNamespace()
66       */
67      public String getNamespace() {
68          // TODO Auto-generated method stub
69          return null;
70      }
71  
72      /* (non-Javadoc)
73       * @see javax.portlet.RenderResponse#setTitle(java.lang.String)
74       */
75      public void setTitle(String title) {
76          this.title = title;
77      }
78  
79      /* (non-Javadoc)
80       * @see javax.portlet.RenderResponse#setContentType(java.lang.String)
81       */
82      public void setContentType(String contentType) {
83          this.contentType = contentType;
84      }
85  
86      /* (non-Javadoc)
87       * @see javax.portlet.RenderResponse#getCharacterEncoding()
88       */
89      public String getCharacterEncoding() {
90          // TODO Auto-generated method stub
91          return null;
92      }
93  
94      /* (non-Javadoc)
95       * @see javax.portlet.RenderResponse#getWriter()
96       */
97      public PrintWriter getWriter() throws IOException {
98          return new PrintWriter(writer);
99      }
100 
101     /* (non-Javadoc)
102      * @see javax.portlet.RenderResponse#getLocale()
103      */
104     public Locale getLocale() {
105         // TODO Auto-generated method stub
106         return null;
107     }
108 
109     /* (non-Javadoc)
110      * @see javax.portlet.RenderResponse#setBufferSize(int)
111      */
112     public void setBufferSize(int arg0) {
113         // TODO Auto-generated method stub
114         
115     }
116 
117     /* (non-Javadoc)
118      * @see javax.portlet.RenderResponse#getBufferSize()
119      */
120     public int getBufferSize() {
121         // TODO Auto-generated method stub
122         return 0;
123     }
124 
125     /* (non-Javadoc)
126      * @see javax.portlet.RenderResponse#flushBuffer()
127      */
128     public void flushBuffer() throws IOException {
129         // TODO Auto-generated method stub
130         
131     }
132 
133     /* (non-Javadoc)
134      * @see javax.portlet.RenderResponse#resetBuffer()
135      */
136     public void resetBuffer() {
137         // TODO Auto-generated method stub
138         
139     }
140 
141     /* (non-Javadoc)
142      * @see javax.portlet.RenderResponse#isCommitted()
143      */
144     public boolean isCommitted() {
145         // TODO Auto-generated method stub
146         return false;
147     }
148 
149     /* (non-Javadoc)
150      * @see javax.portlet.RenderResponse#reset()
151      */
152     public void reset() {
153         // TODO Auto-generated method stub
154         
155     }
156 
157     /* (non-Javadoc)
158      * @see javax.portlet.RenderResponse#getPortletOutputStream()
159      */
160     public OutputStream getPortletOutputStream() throws IOException {
161         // TODO Auto-generated method stub
162         return null;
163     }
164 
165     /* (non-Javadoc)
166      * @see javax.portlet.PortletResponse#addProperty(java.lang.String, java.lang.String)
167      */
168     public void addProperty(String arg0, String arg1) {
169         // TODO Auto-generated method stub
170         
171     }
172 
173     /* (non-Javadoc)
174      * @see javax.portlet.PortletResponse#setProperty(java.lang.String, java.lang.String)
175      */
176     public void setProperty(String arg0, String arg1) {
177         // TODO Auto-generated method stub
178         
179     }
180 
181     /* (non-Javadoc)
182      * @see javax.portlet.PortletResponse#encodeURL(java.lang.String)
183      */
184     public String encodeURL(String url) {
185         return url;
186     }
187     
188     public String retrieveContent() {
189         return writer.getBuffer().toString();
190     }
191 
192     public String retrieveTitle() {
193         return title;
194     }
195 }