001: /*
002: * $HeadURL: https://svn.apache.org/repos/asf/httpcomponents/httpcore/tags/4.0-beta1/module-main/src/test/java/org/apache/http/mockup/SessionInputBufferMockup.java $
003: * $Revision: 560358 $
004: * $Date: 2007-07-27 21:30:42 +0200 (Fri, 27 Jul 2007) $
005: *
006: * ====================================================================
007: * Licensed to the Apache Software Foundation (ASF) under one
008: * or more contributor license agreements. See the NOTICE file
009: * distributed with this work for additional information
010: * regarding copyright ownership. The ASF licenses this file
011: * to you under the Apache License, Version 2.0 (the
012: * "License"); you may not use this file except in compliance
013: * with the License. You may obtain a copy of the License at
014: *
015: * http://www.apache.org/licenses/LICENSE-2.0
016: *
017: * Unless required by applicable law or agreed to in writing,
018: * software distributed under the License is distributed on an
019: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
020: * KIND, either express or implied. See the License for the
021: * specific language governing permissions and limitations
022: * under the License.
023: * ====================================================================
024: *
025: * This software consists of voluntary contributions made by many
026: * individuals on behalf of the Apache Software Foundation. For more
027: * information on the Apache Software Foundation, please see
028: * <http://www.apache.org/>.
029: *
030: */
031:
032: package org.apache.http.mockup;
033:
034: import java.io.ByteArrayInputStream;
035: import java.io.IOException;
036: import java.io.InputStream;
037: import java.io.UnsupportedEncodingException;
038:
039: import org.apache.http.impl.io.AbstractSessionInputBuffer;
040: import org.apache.http.params.BasicHttpParams;
041: import org.apache.http.params.HttpParams;
042:
043: /**
044: * {@link IdentityInputStream} mockup implementation.
045: *
046: * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
047: */
048: public class SessionInputBufferMockup extends
049: AbstractSessionInputBuffer {
050:
051: public static int BUFFER_SIZE = 16;
052:
053: public SessionInputBufferMockup(final InputStream instream,
054: int buffersize, final HttpParams params) {
055: super ();
056: init(instream, buffersize, params);
057: }
058:
059: public SessionInputBufferMockup(final InputStream instream,
060: int buffersize) {
061: this (instream, buffersize, new BasicHttpParams());
062: }
063:
064: public SessionInputBufferMockup(final byte[] bytes,
065: final HttpParams params) {
066: this (bytes, BUFFER_SIZE, params);
067: }
068:
069: public SessionInputBufferMockup(final byte[] bytes) {
070: this (bytes, BUFFER_SIZE, new BasicHttpParams());
071: }
072:
073: public SessionInputBufferMockup(final byte[] bytes, int buffersize,
074: final HttpParams params) {
075: this (new ByteArrayInputStream(bytes), buffersize, params);
076: }
077:
078: public SessionInputBufferMockup(final byte[] bytes, int buffersize) {
079: this (new ByteArrayInputStream(bytes), buffersize,
080: new BasicHttpParams());
081: }
082:
083: public SessionInputBufferMockup(final String s,
084: final String charset, int buffersize,
085: final HttpParams params)
086: throws UnsupportedEncodingException {
087: this (s.getBytes(charset), buffersize, params);
088: }
089:
090: public SessionInputBufferMockup(final String s,
091: final String charset, int buffersize)
092: throws UnsupportedEncodingException {
093: this (s.getBytes(charset), buffersize, new BasicHttpParams());
094: }
095:
096: public SessionInputBufferMockup(final String s,
097: final String charset, final HttpParams params)
098: throws UnsupportedEncodingException {
099: this (s.getBytes(charset), params);
100: }
101:
102: public SessionInputBufferMockup(final String s, final String charset)
103: throws UnsupportedEncodingException {
104: this (s.getBytes(charset), new BasicHttpParams());
105:
106: }
107:
108: public boolean isDataAvailable(int timeout) throws IOException {
109: return true;
110: }
111:
112: }
|