Return-Path: Delivered-To: apmail-jakarta-httpclient-commits-archive@www.apache.org Received: (qmail 98439 invoked from network); 2 Apr 2005 17:18:42 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 2 Apr 2005 17:18:42 -0000 Received: (qmail 82708 invoked by uid 500); 2 Apr 2005 17:18:42 -0000 Mailing-List: contact httpclient-commits-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: httpclient-dev@jakarta.apache.org Delivered-To: mailing list httpclient-commits@jakarta.apache.org Received: (qmail 82694 invoked by uid 500); 2 Apr 2005 17:18:42 -0000 Delivered-To: apmail-jakarta-httpclient-cvs@jakarta.apache.org Received: (qmail 82691 invoked by uid 99); 2 Apr 2005 17:18:42 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Sat, 02 Apr 2005 09:18:41 -0800 Received: (qmail 98436 invoked by uid 65534); 2 Apr 2005 17:18:40 -0000 Message-ID: <20050402171840.98435.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: svnmailer-1.0.0-dev Date: Sat, 02 Apr 2005 17:18:40 -0000 Subject: svn commit: r159778 - in jakarta/httpclient/trunk/http-common/src: java/org/apache/http/io/ test/org/apache/http/io/ To: httpclient-cvs@jakarta.apache.org From: olegk@apache.org X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: olegk Date: Sat Apr 2 09:18:39 2005 New Revision: 159778 URL: http://svn.apache.org/viewcvs?view=3Drev&rev=3D159778 Log: Added InputStreamHttpDataReceiver and OutputStreamHttpDataTransmitter wrapp= er classes (provided for compatibility with old the IO model) Added: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/io/InputS= treamHttpDataReceiver.java (with props) jakarta/httpclient/trunk/http-common/src/java/org/apache/http/io/Output= StreamHttpDataTransmitter.java (with props) jakarta/httpclient/trunk/http-common/src/test/org/apache/http/io/TestOl= dIOHttpDataReceiverAndTransmitter.java (with props) Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/io/Chunke= dInputStream.java jakarta/httpclient/trunk/http-common/src/test/org/apache/http/io/TestAl= lIO.java jakarta/httpclient/trunk/http-common/src/test/org/apache/http/io/TestCh= unkCoding.java Modified: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/io/= ChunkedInputStream.java URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src= /java/org/apache/http/io/ChunkedInputStream.java?view=3Ddiff&r1=3D159777&r2= =3D159778 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/io/Chunke= dInputStream.java (original) +++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/io/Chunke= dInputStream.java Sat Apr 2 09:18:39 2005 @@ -35,12 +35,9 @@ =20 import org.apache.http.Header; import org.apache.http.HttpException; -import org.apache.http.params.HttpParams; -import org.apache.http.params.HttpProtocolParams; import org.apache.http.util.EncodingUtil; import org.apache.http.util.ExceptionUtil; import org.apache.http.util.HeadersParser; -import org.apache.http.util.HttpLineParser; =20 /** *

Transparently coalesces chunks of a HTTP stream that uses @@ -85,7 +82,7 @@ =20 private Header[] footers =3D new Header[] {}; =20 - public ChunkedInputStream(final HttpDataReceiver in) throws IOExceptio= n { + public ChunkedInputStream(final HttpDataReceiver in) { super(); if (in =3D=3D null) { throw new IllegalArgumentException("InputStream parameter may not be= null"); @@ -343,43 +340,4 @@ } } =20 - static class InputStreamHttpDataReceiver implements HttpDataReceiver { - =20 - private final InputStream instream; - =20 - private String charset =3D "US-ASCII"; - =20 - public InputStreamHttpDataReceiver(final InputStream instream) { - super(); - if (instream =3D=3D null) { - throw new IllegalArgumentException("Input stream may not b= e null"); - } - this.instream =3D instream; - } - =20 - public boolean isDataAvailable(int timeout) throws IOException { - return this.instream.available() > 0; - } - =20 - public int read() throws IOException { - return this.instream.read(); - } - =20 - public int read(final byte[] b, int off, int len) throws IOExcepti= on { - return this.instream.read(b, off, len); - } - =20 - public int read(final byte[] b) throws IOException { - return this.instream.read(b); - } - =20 - public String readLine() throws IOException { - return HttpLineParser.readLine(this.instream, this.charset); - } - =20 - public void reset(final HttpParams params) { - HttpProtocolParams protocolParams =3D new HttpProtocolParams(p= arams); - this.charset =3D protocolParams.getHttpElementCharset();=20 - } - } } Added: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/io/Inp= utStreamHttpDataReceiver.java URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src= /java/org/apache/http/io/InputStreamHttpDataReceiver.java?view=3Dauto&rev= =3D159778 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/io/InputS= treamHttpDataReceiver.java (added) +++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/io/InputS= treamHttpDataReceiver.java Sat Apr 2 09:18:39 2005 @@ -0,0 +1,88 @@ +/* + * $HeadURL$ + * $Revision$ + * $Date$ + * + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * + * Copyright 2002-2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implie= d=2E + * See the License for the specific language governing permissions and + * limitations under the License. + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + */ + +package org.apache.http.io; + +import java.io.IOException; +import java.io.InputStream; + +import org.apache.http.params.HttpParams; +import org.apache.http.params.HttpProtocolParams; +import org.apache.http.util.HttpLineParser; + +/** + *

Old IO Compatibility wrapper

+ * + * @author Oleg Kalnichevski + * + */ +public class InputStreamHttpDataReceiver implements HttpDataReceiver { + + private final InputStream instream; + =20 + private String charset =3D "US-ASCII"; + =20 + public InputStreamHttpDataReceiver(final InputStream instream) { + super(); + if (instream =3D=3D null) { + throw new IllegalArgumentException("Input stream may not be nu= ll"); + } + this.instream =3D instream; + } + =20 + public InputStream getInputStream() { + return this.instream; + } + =20 + public boolean isDataAvailable(int timeout) throws IOException { + return this.instream.available() > 0; + } + =20 + public int read() throws IOException { + return this.instream.read(); + } + =20 + public int read(final byte[] b, int off, int len) throws IOException { + return this.instream.read(b, off, len); + } + =20 + public int read(final byte[] b) throws IOException { + return this.instream.read(b); + } + =20 + public String readLine() throws IOException { + return HttpLineParser.readLine(this.instream, this.charset); + } + =20 + public void reset(final HttpParams params) { + HttpProtocolParams protocolParams =3D new HttpProtocolParams(param= s); + this.charset =3D protocolParams.getHttpElementCharset();=20 + } + =20 +} Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/i= o/InputStreamHttpDataReceiver.java ---------------------------------------------------------------------------= --- svn:eol-style =3D native Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/i= o/InputStreamHttpDataReceiver.java ---------------------------------------------------------------------------= --- svn:keywords =3D Date Author Id Revision HeadURL Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/i= o/InputStreamHttpDataReceiver.java ---------------------------------------------------------------------------= --- svn:mime-type =3D text/plain Added: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/io/Out= putStreamHttpDataTransmitter.java URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src= /java/org/apache/http/io/OutputStreamHttpDataTransmitter.java?view=3Dauto&r= ev=3D159778 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- jakarta/httpclient/trunk/http-common/src/java/org/apache/http/io/Output= StreamHttpDataTransmitter.java (added) +++ jakarta/httpclient/trunk/http-common/src/java/org/apache/http/io/Output= StreamHttpDataTransmitter.java Sat Apr 2 09:18:39 2005 @@ -0,0 +1,95 @@ +/* + * $HeadURL$ + * $Revision$ + * $Date$ + * + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * + * Copyright 2002-2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implie= d=2E + * See the License for the specific language governing permissions and + * limitations under the License. + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + */ + +package org.apache.http.io; + +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.http.params.HttpParams; +import org.apache.http.params.HttpProtocolParams; + +/** + *

Old IO Compatibility wrapper

+ * + * @author Oleg Kalnichevski + * + */ +public class OutputStreamHttpDataTransmitter implements HttpDataTransmitte= r { + + private static final int CR =3D 13; + private static final int LF =3D 10; + private static final byte[] CRLF =3D new byte[] {CR, LF}; + + private final OutputStream outstream; + =20 + private String charset =3D "US-ASCII"; + =20 + public OutputStreamHttpDataTransmitter(final OutputStream outstream) { + super(); + if (outstream =3D=3D null) { + throw new IllegalArgumentException("Input stream may not be nu= ll"); + } + this.outstream =3D outstream; + } + + public OutputStream getOutputStream() { + return this.outstream; + } + =20 + public void flush() throws IOException { + this.outstream.flush(); + } + =20 + public void write(final byte[] b, int off, int len) throws IOException= { + this.outstream.write(b, off, len); + } + =20 + public void write(final byte[] b) throws IOException { + this.outstream.write(b); + } + =20 + public void write(int b) throws IOException { + this.outstream.write(b); + } + =20 + public void writeLine(final String s) throws IOException { + if (s =3D=3D null) { + return; + } + this.outstream.write(s.getBytes(this.charset)); + this.outstream.write(CRLF); + } + =20 + public void reset(final HttpParams params) { + HttpProtocolParams protocolParams =3D new HttpProtocolParams(param= s); + this.charset =3D protocolParams.getHttpElementCharset();=20 + } + =20 +} Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/i= o/OutputStreamHttpDataTransmitter.java ---------------------------------------------------------------------------= --- svn:eol-style =3D native Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/i= o/OutputStreamHttpDataTransmitter.java ---------------------------------------------------------------------------= --- svn:keywords =3D Date Author Id Revision HeadURL Propchange: jakarta/httpclient/trunk/http-common/src/java/org/apache/http/i= o/OutputStreamHttpDataTransmitter.java ---------------------------------------------------------------------------= --- svn:mime-type =3D text/plain Modified: jakarta/httpclient/trunk/http-common/src/test/org/apache/http/io/= TestAllIO.java URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src= /test/org/apache/http/io/TestAllIO.java?view=3Ddiff&r1=3D159777&r2=3D159778 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- jakarta/httpclient/trunk/http-common/src/test/org/apache/http/io/TestAl= lIO.java (original) +++ jakarta/httpclient/trunk/http-common/src/test/org/apache/http/io/TestAl= lIO.java Sat Apr 2 09:18:39 2005 @@ -41,6 +41,7 @@ suite.addTest(TestHttpDataInputStream.suite()); suite.addTest(TestHttpDataOutputStream.suite()); suite.addTest(TestChunkCoding.suite()); + suite.addTest(TestOldIOHttpDataReceiverAndTransmitter.suite()); return suite; } =20 Modified: jakarta/httpclient/trunk/http-common/src/test/org/apache/http/io/= TestChunkCoding.java URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src= /test/org/apache/http/io/TestChunkCoding.java?view=3Ddiff&r1=3D159777&r2=3D= 159778 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- jakarta/httpclient/trunk/http-common/src/test/org/apache/http/io/TestCh= unkCoding.java (original) +++ jakarta/httpclient/trunk/http-common/src/test/org/apache/http/io/TestCh= unkCoding.java Sat Apr 2 09:18:39 2005 @@ -35,7 +35,6 @@ import java.io.OutputStream; =20 import org.apache.http.Header; -import org.apache.http.impl.DefaultHttpParams; import org.apache.http.util.EncodingUtil; =20 import junit.framework.Test; @@ -273,27 +272,6 @@ } assertEquals(0, out.size()); } - - public void testInputStreamHttpDataReceiver() throws IOException { - String s =3D "aaaaa"; - InputStream in =3D new ByteArrayInputStream( - EncodingUtil.getBytes(s, CONTENT_CHARSET)); - ChunkedInputStream.InputStreamHttpDataReceiver datareceiver =3D - new ChunkedInputStream.InputStreamHttpDataReceiver(in); - assertTrue(datareceiver.isDataAvailable(1)); - assertEquals('a', datareceiver.read()); - byte[] tmp =3D new byte[2]; - datareceiver.read(tmp); - assertEquals('a', tmp[0]); - assertEquals('a', tmp[1]); - datareceiver.read(tmp, 0, tmp.length); - assertEquals('a', tmp[0]); - assertEquals('a', tmp[1]); - assertEquals(-1, datareceiver.read()); - datareceiver.reset(new DefaultHttpParams(null)); - } - - =20 =20 public void testContentLengthInputStream() throws IOException { String correct =3D "1234567890123456"; Added: jakarta/httpclient/trunk/http-common/src/test/org/apache/http/io/Tes= tOldIOHttpDataReceiverAndTransmitter.java URL: http://svn.apache.org/viewcvs/jakarta/httpclient/trunk/http-common/src= /test/org/apache/http/io/TestOldIOHttpDataReceiverAndTransmitter.java?view= =3Dauto&rev=3D159778 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- jakarta/httpclient/trunk/http-common/src/test/org/apache/http/io/TestOl= dIOHttpDataReceiverAndTransmitter.java (added) +++ jakarta/httpclient/trunk/http-common/src/test/org/apache/http/io/TestOl= dIOHttpDataReceiverAndTransmitter.java Sat Apr 2 09:18:39 2005 @@ -0,0 +1,112 @@ +/* + * $HeadURL$ + * $Revision$ + * $Date$ + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * + * Copyright 2002-2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implie= d=2E + * See the License for the specific language governing permissions and + * limitations under the License. + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + */ + +package org.apache.http.io; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +import org.apache.http.impl.DefaultHttpParams; +import org.apache.http.util.EncodingUtil; + +public class TestOldIOHttpDataReceiverAndTransmitter extends TestCase { + + public TestOldIOHttpDataReceiverAndTransmitter(String testName) { + super(testName); + } + + // ------------------------------------------------------- TestCase Me= thods + + public static Test suite() { + return new TestSuite(TestOldIOHttpDataReceiverAndTransmitter.class= ); + } + + // -------------------------------------------------------------------= Main + public static void main(String args[]) { + String[] testCaseName =3D { TestOldIOHttpDataReceiverAndTransmitte= r=2Eclass.getName() }; + junit.textui.TestRunner.main(testCaseName); + } + + public void testConstructors() { + String s =3D "aaaaa"; + InputStream in =3D new ByteArrayInputStream(EncodingUtil.getAsciiB= ytes(s)); + new InputStreamHttpDataReceiver(in); + try { + new InputStreamHttpDataReceiver(null); + fail("IllegalArgumentException should have been thrown"); + } catch (IllegalArgumentException ex) { + // expected + } + new OutputStreamHttpDataTransmitter(new ByteArrayOutputStream());=20 + try { + new OutputStreamHttpDataTransmitter(null); + fail("IllegalArgumentException should have been thrown"); + } catch (IllegalArgumentException ex) { + // expected + } + } + =20 + public void testInputStreamHttpDataReceiver() throws IOException { + String s =3D "aaaaa"; + InputStream in =3D new ByteArrayInputStream(EncodingUtil.getAsciiB= ytes(s)); + HttpDataReceiver datareceiver =3D new InputStreamHttpDataReceiver(= in); + assertTrue(datareceiver.isDataAvailable(1)); + assertEquals('a', datareceiver.read()); + byte[] tmp =3D new byte[2]; + datareceiver.read(tmp); + assertEquals('a', tmp[0]); + assertEquals('a', tmp[1]); + datareceiver.read(tmp, 0, tmp.length); + assertEquals('a', tmp[0]); + assertEquals('a', tmp[1]); + assertEquals(-1, datareceiver.read()); + datareceiver.reset(new DefaultHttpParams(null)); + } + + public void testOutputStreamHttpDataTransmitter() throws IOException { + String s =3D "aaaaa\r\n"; + ByteArrayOutputStream out =3D new ByteArrayOutputStream(); + HttpDataTransmitter datatransmitter =3D new OutputStreamHttpDataTr= ansmitter(out); + datatransmitter.reset(new DefaultHttpParams(null)); + =20 + datatransmitter.write('a'); + datatransmitter.write(new byte[] {'a'}); + datatransmitter.write(new byte[] {'a'}, 0, 1); + datatransmitter.writeLine("aa"); + datatransmitter.flush(); + =20 + assertEquals(s, out.toString("US-ASCII")); + } +} + Propchange: jakarta/httpclient/trunk/http-common/src/test/org/apache/http/i= o/TestOldIOHttpDataReceiverAndTransmitter.java ---------------------------------------------------------------------------= --- svn:eol-style =3D native Propchange: jakarta/httpclient/trunk/http-common/src/test/org/apache/http/i= o/TestOldIOHttpDataReceiverAndTransmitter.java ---------------------------------------------------------------------------= --- svn:keywords =3D Date Author Id Revision HeadURL Propchange: jakarta/httpclient/trunk/http-common/src/test/org/apache/http/i= o/TestOldIOHttpDataReceiverAndTransmitter.java ---------------------------------------------------------------------------= --- svn:mime-type =3D text/plain