View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  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,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package org.apache.myfaces.view.facelets.mock;
21  
22  import java.util.Locale;
23  
24  /**
25   * 
26   * @author Jacob Hookom
27   * @version $Id: MockHttpServletResponse.java 883907 2009-11-24 22:37:53Z lu4242 $
28   */
29  public class MockHttpServletResponse extends org.apache.myfaces.test.mock.MockHttpServletResponse{
30      
31      private boolean committed = false;
32      private int status;
33      private String message;
34      private long contentLength = 0;
35      private int bufferSize = 0;
36      private Locale locale = Locale.getDefault();
37      
38      public MockHttpServletResponse() {
39          super();
40          setCharacterEncoding("ISO-8859-1");
41          setContentType("text/html");
42      }
43  
44      public void sendError(int status, String message){
45          if (this.committed) {
46              throw new IllegalStateException("Response is already committed");
47          }
48          this.status = status;
49          this.message = message;
50          this.committed = true;
51      }
52  
53      public void sendError(int status){
54          if (this.committed) {
55              throw new IllegalStateException("Response is already committed");
56          }
57          this.status = status;
58          this.committed = true;
59      }
60  
61      public void sendRedirect(String path){
62          if (this.committed) {
63              throw new IllegalStateException("Response is already committed");
64          }
65          this.committed = true;
66      }
67  
68      public void setStatus(int sc) {
69          this.status = sc;
70      }
71  
72      public void setStatus(int sc, String message) {
73          this.status = sc;
74          this.message = message;
75      }
76  
77      public void setContentLength(int contentLength) {
78          this.contentLength = contentLength;
79      }
80  
81      public void setBufferSize(int sz) {
82          this.bufferSize = sz;
83      }
84  
85      public int getBufferSize() {
86          return this.bufferSize;
87      }
88  
89      public void flushBuffer(){
90  
91      }
92  
93      public void resetBuffer() {
94  
95      }
96  
97      public boolean isCommitted() {
98          return this.committed;
99      }
100 
101     public void reset() {
102 
103     }
104 
105 }