| 1 | /** |
| 2 | * Copyright 2008 ATG DUST Project |
| 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 | * |
| 7 | * You may obtain a copy of the License at 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 limitations under the License. |
| 13 | */ |
| 14 | package atg.server.http; |
| 15 | |
| 16 | import java.io.InputStream; |
| 17 | |
| 18 | // ------------------------------------- |
| 19 | /** |
| 20 | * A version of HttpConnectionServletInputStream that allows one to specify the |
| 21 | * content length parameter. This is useful for writing unit tests since the |
| 22 | * base class does not allow the content length to be set by callers outside of |
| 23 | * its package. |
| 24 | * |
| 25 | * @author Adam Belmont |
| 26 | * @version $Id: $ |
| 27 | * @see HttpConnectionServletInputStream |
| 28 | * |
| 29 | */ |
| 30 | public class TestingHttpConnectionServletInputStream extends |
| 31 | HttpConnectionServletInputStream { |
| 32 | |
| 33 | public static final String CLASS_VERSION = "$Id:$"; |
| 34 | // ------------------------------------- |
| 35 | /* |
| 36 | * (non-Javadoc) |
| 37 | * |
| 38 | * @see atg.server.http.HttpConnectionServletInputStream#getRequestContentLength() |
| 39 | */ |
| 40 | @Override |
| 41 | public int getRequestContentLength() { |
| 42 | // TODO Auto-generated method stub |
| 43 | return super.getRequestContentLength(); |
| 44 | } |
| 45 | |
| 46 | // ------------------------------------- |
| 47 | /* |
| 48 | * (non-Javadoc) |
| 49 | * |
| 50 | * @see atg.server.http.HttpConnectionServletInputStream#setRequestContentLength(int) |
| 51 | */ |
| 52 | @Override |
| 53 | public void setRequestContentLength(int pRequestContentLength) { |
| 54 | // TODO Auto-generated method stub |
| 55 | super.setRequestContentLength(pRequestContentLength); |
| 56 | } |
| 57 | |
| 58 | // ------------------------------------- |
| 59 | /** |
| 60 | * Constructs a new HttpConnectionServletInputStream that gets its input from |
| 61 | * the specified InputStream |
| 62 | * |
| 63 | * @param pIn |
| 64 | * the InputStream this will use to read its input |
| 65 | * @param pContentLength |
| 66 | * The "content length" size typically sent by an HttpClient |
| 67 | */ |
| 68 | public TestingHttpConnectionServletInputStream(InputStream pIn, |
| 69 | int pContentLength) { |
| 70 | super(pIn); |
| 71 | setRequestContentLength(pContentLength); |
| 72 | mIn = pIn; |
| 73 | // reset the total bytes read by the application from the underlying stream |
| 74 | mTotalBytesRead = 0; |
| 75 | } |
| 76 | } |