Return-Path: Delivered-To: apmail-hc-commits-archive@www.apache.org Received: (qmail 72416 invoked from network); 23 Apr 2010 13:45:26 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 23 Apr 2010 13:45:26 -0000 Received: (qmail 9089 invoked by uid 500); 23 Apr 2010 13:45:26 -0000 Delivered-To: apmail-hc-commits-archive@hc.apache.org Received: (qmail 9052 invoked by uid 500); 23 Apr 2010 13:45:26 -0000 Mailing-List: contact commits-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list commits@hc.apache.org Received: (qmail 9045 invoked by uid 99); 23 Apr 2010 13:45:26 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Apr 2010 13:45:26 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Apr 2010 13:45:18 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 811932388B43; Fri, 23 Apr 2010 13:44:09 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r937295 [6/9] - in /httpcomponents/httpcore/trunk/httpcore/src: main/java/org/apache/http/ main/java/org/apache/http/entity/ main/java/org/apache/http/impl/ main/java/org/apache/http/impl/entity/ main/java/org/apache/http/impl/io/ main/java... Date: Fri, 23 Apr 2010 13:44:05 -0000 To: commits@hc.apache.org From: olegk@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100423134409.811932388B43@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/ByteArrayBuffer.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/ByteArrayBuffer.java?rev=937295&r1=937294&r2=937295&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/ByteArrayBuffer.java (original) +++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/ByteArrayBuffer.java Fri Apr 23 13:44:00 2010 @@ -29,18 +29,18 @@ package org.apache.http.util; /** * A resizable byte array. - * + * * @since 4.0 */ public final class ByteArrayBuffer { - + private byte[] buffer; private int len; /** - * Creates an instance of {@link ByteArrayBuffer} with the given initial + * Creates an instance of {@link ByteArrayBuffer} with the given initial * capacity. - * + * * @param capacity the capacity */ public ByteArrayBuffer(int capacity) { @@ -48,7 +48,7 @@ public final class ByteArrayBuffer { if (capacity < 0) { throw new IllegalArgumentException("Buffer capacity may not be negative"); } - this.buffer = new byte[capacity]; + this.buffer = new byte[capacity]; } private void expand(int newlen) { @@ -58,16 +58,16 @@ public final class ByteArrayBuffer { } /** - * Appends len bytes to this buffer from the given source - * array starting at index off. The capacity of the buffer - * is increased, if necessary, to accommodate all len bytes. + * Appends len bytes to this buffer from the given source + * array starting at index off. The capacity of the buffer + * is increased, if necessary, to accommodate all len bytes. * * @param b the bytes to be appended. * @param off the index of the first byte to append. * @param len the number of bytes to append. - * @throws IndexOutOfBoundsException if off if out of - * range, len is negative, or - * off + len is out of range. + * @throws IndexOutOfBoundsException if off if out of + * range, len is negative, or + * off + len is out of range. */ public void append(final byte[] b, int off, int len) { if (b == null) { @@ -89,8 +89,8 @@ public final class ByteArrayBuffer { } /** - * Appends b byte to this buffer. The capacity of the buffer - * is increased, if necessary, to accommodate the additional byte. + * Appends b byte to this buffer. The capacity of the buffer + * is increased, if necessary, to accommodate the additional byte. * * @param b the byte to be appended. */ @@ -104,18 +104,18 @@ public final class ByteArrayBuffer { } /** - * Appends len chars to this buffer from the given source - * array starting at index off. The capacity of the buffer - * is increased if necessary to accommodate all len chars. + * Appends len chars to this buffer from the given source + * array starting at index off. The capacity of the buffer + * is increased if necessary to accommodate all len chars. *

* The chars are converted to bytes using simple cast. * * @param b the chars to be appended. * @param off the index of the first char to append. * @param len the number of bytes to append. - * @throws IndexOutOfBoundsException if off if out of - * range, len is negative, or - * off + len is out of range. + * @throws IndexOutOfBoundsException if off if out of + * range, len is negative, or + * off + len is out of range. */ public void append(final char[] b, int off, int len) { if (b == null) { @@ -140,19 +140,19 @@ public final class ByteArrayBuffer { } /** - * Appends len chars to this buffer from the given source - * char array buffer starting at index off. The capacity - * of the buffer is increased if necessary to accommodate all - * len chars. + * Appends len chars to this buffer from the given source + * char array buffer starting at index off. The capacity + * of the buffer is increased if necessary to accommodate all + * len chars. *

* The chars are converted to bytes using simple cast. * * @param b the chars to be appended. * @param off the index of the first char to append. * @param len the number of bytes to append. - * @throws IndexOutOfBoundsException if off if out of - * range, len is negative, or - * off + len is out of range. + * @throws IndexOutOfBoundsException if off if out of + * range, len is negative, or + * off + len is out of range. */ public void append(final CharArrayBuffer b, int off, int len) { if (b == null) { @@ -160,7 +160,7 @@ public final class ByteArrayBuffer { } append(b.buffer(), off, len); } - + /** * Clears content of the buffer. The underlying byte array is not resized. */ @@ -169,35 +169,35 @@ public final class ByteArrayBuffer { } /** - * Converts the content of this buffer to an array of bytes. - * + * Converts the content of this buffer to an array of bytes. + * * @return byte array */ public byte[] toByteArray() { - byte[] b = new byte[this.len]; + byte[] b = new byte[this.len]; if (this.len > 0) { System.arraycopy(this.buffer, 0, b, 0, this.len); } return b; } - + /** - * Returns the byte value in this buffer at the specified + * Returns the byte value in this buffer at the specified * index. The index argument must be greater than or equal to * 0, and less than the length of this buffer. * * @param i the index of the desired byte value. * @return the byte value at the specified index. - * @throws IndexOutOfBoundsException if index is + * @throws IndexOutOfBoundsException if index is * negative or greater than or equal to {@link #length()}. */ public int byteAt(int i) { return this.buffer[i]; } - + /** - * Returns the current capacity. The capacity is the amount of storage - * available for newly appended bytes, beyond which an allocation + * Returns the current capacity. The capacity is the amount of storage + * available for newly appended bytes, beyond which an allocation * will occur. * * @return the current capacity @@ -205,7 +205,7 @@ public final class ByteArrayBuffer { public int capacity() { return this.buffer.length; } - + /** * Returns the length of the buffer (byte count). * @@ -218,11 +218,11 @@ public final class ByteArrayBuffer { /** * Ensures that the capacity is at least equal to the specified minimum. * If the current capacity is less than the argument, then a new internal - * array is allocated with greater capacity. If the required + * array is allocated with greater capacity. If the required * argument is non-positive, this method takes no action. * * @param required the minimum required capacity. - * + * * @since 4.1 */ public void ensureCapacity(int required) { @@ -234,24 +234,24 @@ public final class ByteArrayBuffer { expand(this.len + required); } } - + /** * Returns reference to the underlying byte array. - * + * * @return the byte array. */ public byte[] buffer() { return this.buffer; } - + /** - * Sets the length of the buffer. The new length value is expected to be - * less than the current capacity and greater than or equal to - * 0. + * Sets the length of the buffer. The new length value is expected to be + * less than the current capacity and greater than or equal to + * 0. * * @param len the new length * @throws IndexOutOfBoundsException if the - * len argument is greater than the current + * len argument is greater than the current * capacity of the buffer or less than 0. */ public void setLength(int len) { @@ -260,48 +260,48 @@ public final class ByteArrayBuffer { } this.len = len; } - + /** - * Returns true if this buffer is empty, that is, its + * Returns true if this buffer is empty, that is, its * {@link #length()} is equal to 0. * @return true if this buffer is empty, false - * otherwise. + * otherwise. */ public boolean isEmpty() { - return this.len == 0; + return this.len == 0; } - + /** - * Returns true if this buffer is full, that is, its + * Returns true if this buffer is full, that is, its * {@link #length()} is equal to its {@link #capacity()}. * @return true if this buffer is full, false - * otherwise. + * otherwise. */ public boolean isFull() { - return this.len == this.buffer.length; + return this.len == this.buffer.length; } - + /** * Returns the index within this buffer of the first occurrence of the - * specified byte, starting the search at the specified + * specified byte, starting the search at the specified * beginIndex and finishing at endIndex. - * If no such byte occurs in this buffer within the specified bounds, + * If no such byte occurs in this buffer within the specified bounds, * -1 is returned. *

- * There is no restriction on the value of beginIndex and - * endIndex. If beginIndex is negative, - * it has the same effect as if it were zero. If endIndex is + * There is no restriction on the value of beginIndex and + * endIndex. If beginIndex is negative, + * it has the same effect as if it were zero. If endIndex is * greater than {@link #length()}, it has the same effect as if it were - * {@link #length()}. If the beginIndex is greater than + * {@link #length()}. If the beginIndex is greater than * the endIndex, -1 is returned. * * @param b the byte to search for. * @param beginIndex the index to start the search from. * @param endIndex the index to finish the search at. * @return the index of the first occurrence of the byte in the buffer - * within the given bounds, or -1 if the byte does + * within the given bounds, or -1 if the byte does * not occur. - * + * * @since 4.1 */ public int indexOf(byte b, int beginIndex, int endIndex) { @@ -321,17 +321,17 @@ public final class ByteArrayBuffer { } return -1; } - + /** * Returns the index within this buffer of the first occurrence of the - * specified byte, starting the search at 0 and finishing - * at {@link #length()}. If no such byte occurs in this buffer within + * specified byte, starting the search at 0 and finishing + * at {@link #length()}. If no such byte occurs in this buffer within * those bounds, -1 is returned. * * @param b the byte to search for. - * @return the index of the first occurrence of the byte in the + * @return the index of the first occurrence of the byte in the * buffer, or -1 if the byte does not occur. - * + * * @since 4.1 */ public int indexOf(byte b) { Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/CharArrayBuffer.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/CharArrayBuffer.java?rev=937295&r1=937294&r2=937295&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/CharArrayBuffer.java (original) +++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/CharArrayBuffer.java Fri Apr 23 13:44:00 2010 @@ -31,18 +31,18 @@ import org.apache.http.protocol.HTTP; /** * A resizable char array. - * + * * @since 4.0 */ public final class CharArrayBuffer { - + private char[] buffer; private int len; /** - * Creates an instance of {@link CharArrayBuffer} with the given initial + * Creates an instance of {@link CharArrayBuffer} with the given initial * capacity. - * + * * @param capacity the capacity */ public CharArrayBuffer(int capacity) { @@ -50,7 +50,7 @@ public final class CharArrayBuffer { if (capacity < 0) { throw new IllegalArgumentException("Buffer capacity may not be negative"); } - this.buffer = new char[capacity]; + this.buffer = new char[capacity]; } private void expand(int newlen) { @@ -58,18 +58,18 @@ public final class CharArrayBuffer { System.arraycopy(this.buffer, 0, newbuffer, 0, this.len); this.buffer = newbuffer; } - + /** - * Appends len chars to this buffer from the given source - * array starting at index off. The capacity of the buffer - * is increased, if necessary, to accommodate all len chars. + * Appends len chars to this buffer from the given source + * array starting at index off. The capacity of the buffer + * is increased, if necessary, to accommodate all len chars. * * @param b the chars to be appended. * @param off the index of the first char to append. * @param len the number of chars to append. - * @throws IndexOutOfBoundsException if off is out of - * range, len is negative, or - * off + len is out of range. + * @throws IndexOutOfBoundsException if off is out of + * range, len is negative, or + * off + len is out of range. */ public void append(final char[] b, int off, int len) { if (b == null) { @@ -89,13 +89,13 @@ public final class CharArrayBuffer { System.arraycopy(b, off, this.buffer, this.len, len); this.len = newlen; } - + /** - * Appends chars of the given string to this buffer. The capacity of the + * Appends chars of the given string to this buffer. The capacity of the * buffer is increased, if necessary, to accommodate all chars. - * + * * @param str the string. - */ + */ public void append(String str) { if (str == null) { str = "null"; @@ -110,17 +110,17 @@ public final class CharArrayBuffer { } /** - * Appends len chars to this buffer from the given source - * buffer starting at index off. The capacity of the - * destination buffer is increased, if necessary, to accommodate all - * len chars. + * Appends len chars to this buffer from the given source + * buffer starting at index off. The capacity of the + * destination buffer is increased, if necessary, to accommodate all + * len chars. * * @param b the source buffer to be appended. * @param off the index of the first char to append. * @param len the number of chars to append. - * @throws IndexOutOfBoundsException if off is out of - * range, len is negative, or - * off + len is out of range. + * @throws IndexOutOfBoundsException if off is out of + * range, len is negative, or + * off + len is out of range. */ public void append(final CharArrayBuffer b, int off, int len) { if (b == null) { @@ -128,11 +128,11 @@ public final class CharArrayBuffer { } append(b.buffer, off, len); } - + /** - * Appends all chars to this buffer from the given source buffer starting - * at index 0. The capacity of the destination buffer is - * increased, if necessary, to accommodate all {@link #length()} chars. + * Appends all chars to this buffer from the given source buffer starting + * at index 0. The capacity of the destination buffer is + * increased, if necessary, to accommodate all {@link #length()} chars. * * @param b the source buffer to be appended. */ @@ -142,10 +142,10 @@ public final class CharArrayBuffer { } append(b.buffer,0, b.len); } - + /** - * Appends ch char to this buffer. The capacity of the buffer - * is increased, if necessary, to accommodate the additional char. + * Appends ch char to this buffer. The capacity of the buffer + * is increased, if necessary, to accommodate the additional char. * * @param ch the char to be appended. */ @@ -159,18 +159,18 @@ public final class CharArrayBuffer { } /** - * Appends len bytes to this buffer from the given source - * array starting at index off. The capacity of the buffer - * is increased, if necessary, to accommodate all len bytes. + * Appends len bytes to this buffer from the given source + * array starting at index off. The capacity of the buffer + * is increased, if necessary, to accommodate all len bytes. *

* The bytes are converted to chars using simple cast. * * @param b the bytes to be appended. * @param off the index of the first byte to append. * @param len the number of bytes to append. - * @throws IndexOutOfBoundsException if off is out of - * range, len is negative, or - * off + len is out of range. + * @throws IndexOutOfBoundsException if off is out of + * range, len is negative, or + * off + len is out of range. */ public void append(final byte[] b, int off, int len) { if (b == null) { @@ -193,20 +193,20 @@ public final class CharArrayBuffer { } this.len = newlen; } - + /** - * Appends len bytes to this buffer from the given source - * array starting at index off. The capacity of the buffer - * is increased, if necessary, to accommodate all len bytes. + * Appends len bytes to this buffer from the given source + * array starting at index off. The capacity of the buffer + * is increased, if necessary, to accommodate all len bytes. *

* The bytes are converted to chars using simple cast. * * @param b the bytes to be appended. * @param off the index of the first byte to append. * @param len the number of bytes to append. - * @throws IndexOutOfBoundsException if off is out of - * range, len is negative, or - * off + len is out of range. + * @throws IndexOutOfBoundsException if off is out of + * range, len is negative, or + * off + len is out of range. */ public void append(final ByteArrayBuffer b, int off, int len) { if (b == null) { @@ -214,64 +214,64 @@ public final class CharArrayBuffer { } append(b.buffer(), off, len); } - + /** - * Appends chars of the textual representation of the given object to this - * buffer. The capacity of the buffer is increased, if necessary, to + * Appends chars of the textual representation of the given object to this + * buffer. The capacity of the buffer is increased, if necessary, to * accommodate all chars. - * + * * @param obj the object. - */ + */ public void append(final Object obj) { append(String.valueOf(obj)); } - + /** * Clears content of the buffer. The underlying char array is not resized. */ public void clear() { this.len = 0; } - + /** - * Converts the content of this buffer to an array of chars. - * + * Converts the content of this buffer to an array of chars. + * * @return char array */ public char[] toCharArray() { - char[] b = new char[this.len]; + char[] b = new char[this.len]; if (this.len > 0) { System.arraycopy(this.buffer, 0, b, 0, this.len); } return b; } - + /** - * Returns the char value in this buffer at the specified + * Returns the char value in this buffer at the specified * index. The index argument must be greater than or equal to * 0, and less than the length of this buffer. * * @param i the index of the desired char value. * @return the char value at the specified index. - * @throws IndexOutOfBoundsException if index is + * @throws IndexOutOfBoundsException if index is * negative or greater than or equal to {@link #length()}. */ public char charAt(int i) { return this.buffer[i]; } - + /** * Returns reference to the underlying char array. - * + * * @return the char array. */ public char[] buffer() { return this.buffer; } - + /** - * Returns the current capacity. The capacity is the amount of storage - * available for newly appended chars, beyond which an allocation will + * Returns the current capacity. The capacity is the amount of storage + * available for newly appended chars, beyond which an allocation will * occur. * * @return the current capacity @@ -279,7 +279,7 @@ public final class CharArrayBuffer { public int capacity() { return this.buffer.length; } - + /** * Returns the length of the buffer (char count). * @@ -292,7 +292,7 @@ public final class CharArrayBuffer { /** * Ensures that the capacity is at least equal to the specified minimum. * If the current capacity is less than the argument, then a new internal - * array is allocated with greater capacity. If the required + * array is allocated with greater capacity. If the required * argument is non-positive, this method takes no action. * * @param required the minimum required capacity. @@ -306,15 +306,15 @@ public final class CharArrayBuffer { expand(this.len + required); } } - + /** - * Sets the length of the buffer. The new length value is expected to be - * less than the current capacity and greater than or equal to - * 0. + * Sets the length of the buffer. The new length value is expected to be + * less than the current capacity and greater than or equal to + * 0. * * @param len the new length * @throws IndexOutOfBoundsException if the - * len argument is greater than the current + * len argument is greater than the current * capacity of the buffer or less than 0. */ public void setLength(int len) { @@ -323,46 +323,46 @@ public final class CharArrayBuffer { } this.len = len; } - + /** - * Returns true if this buffer is empty, that is, its + * Returns true if this buffer is empty, that is, its * {@link #length()} is equal to 0. * @return true if this buffer is empty, false - * otherwise. + * otherwise. */ public boolean isEmpty() { - return this.len == 0; + return this.len == 0; } - + /** - * Returns true if this buffer is full, that is, its + * Returns true if this buffer is full, that is, its * {@link #length()} is equal to its {@link #capacity()}. * @return true if this buffer is full, false - * otherwise. + * otherwise. */ public boolean isFull() { - return this.len == this.buffer.length; + return this.len == this.buffer.length; } - + /** * Returns the index within this buffer of the first occurrence of the - * specified character, starting the search at the specified + * specified character, starting the search at the specified * beginIndex and finishing at endIndex. - * If no such character occurs in this buffer within the specified bounds, + * If no such character occurs in this buffer within the specified bounds, * -1 is returned. *

- * There is no restriction on the value of beginIndex and - * endIndex. If beginIndex is negative, - * it has the same effect as if it were zero. If endIndex is + * There is no restriction on the value of beginIndex and + * endIndex. If beginIndex is negative, + * it has the same effect as if it were zero. If endIndex is * greater than {@link #length()}, it has the same effect as if it were - * {@link #length()}. If the beginIndex is greater than + * {@link #length()}. If the beginIndex is greater than * the endIndex, -1 is returned. * * @param ch the char to search for. * @param beginIndex the index to start the search from. * @param endIndex the index to finish the search at. * @return the index of the first occurrence of the character in the buffer - * within the given bounds, or -1 if the character does + * within the given bounds, or -1 if the character does * not occur. */ public int indexOf(int ch, int beginIndex, int endIndex) { @@ -382,15 +382,15 @@ public final class CharArrayBuffer { } return -1; } - + /** * Returns the index within this buffer of the first occurrence of the - * specified character, starting the search at 0 and finishing - * at {@link #length()}. If no such character occurs in this buffer within + * specified character, starting the search at 0 and finishing + * at {@link #length()}. If no such character occurs in this buffer within * those bounds, -1 is returned. * * @param ch the char to search for. - * @return the index of the first occurrence of the character in the + * @return the index of the first occurrence of the character in the * buffer, or -1 if the character does not occur. */ public int indexOf(int ch) { @@ -398,8 +398,8 @@ public final class CharArrayBuffer { } /** - * Returns a substring of this buffer. The substring begins at the specified - * beginIndex and extends to the character at index + * Returns a substring of this buffer. The substring begins at the specified + * beginIndex and extends to the character at index * endIndex - 1. * * @param beginIndex the beginning index, inclusive. @@ -407,19 +407,19 @@ public final class CharArrayBuffer { * @return the specified substring. * @exception StringIndexOutOfBoundsException if the * beginIndex is negative, or - * endIndex is larger than the length of this - * buffer, or beginIndex is larger than + * endIndex is larger than the length of this + * buffer, or beginIndex is larger than * endIndex. */ public String substring(int beginIndex, int endIndex) { return new String(this.buffer, beginIndex, endIndex - beginIndex); } - + /** * Returns a substring of this buffer with leading and trailing whitespace - * omitted. The substring begins with the first non-whitespace character - * from beginIndex and extends to the last - * non-whitespace character with the index lesser than + * omitted. The substring begins with the first non-whitespace character + * from beginIndex and extends to the last + * non-whitespace character with the index lesser than * endIndex. * * @param beginIndex the beginning index, inclusive. @@ -427,8 +427,8 @@ public final class CharArrayBuffer { * @return the specified substring. * @exception IndexOutOfBoundsException if the * beginIndex is negative, or - * endIndex is larger than the length of this - * buffer, or beginIndex is larger than + * endIndex is larger than the length of this + * buffer, or beginIndex is larger than * endIndex. */ public String substringTrimmed(int beginIndex, int endIndex) { @@ -449,9 +449,9 @@ public final class CharArrayBuffer { } return new String(this.buffer, beginIndex, endIndex - beginIndex); } - + public String toString() { return new String(this.buffer, 0, this.len); } - + } Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/EncodingUtils.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/EncodingUtils.java?rev=937295&r1=937294&r2=937295&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/EncodingUtils.java (original) +++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/EncodingUtils.java Fri Apr 23 13:44:00 2010 @@ -32,8 +32,8 @@ import org.apache.http.protocol.HTTP; /** * The home for utility methods that handle various encoding tasks. - * - * + * + * * @since 4.0 */ public final class EncodingUtils { @@ -45,14 +45,14 @@ public final class EncodingUtils { * * @param data the byte array to be encoded * @param offset the index of the first byte to encode - * @param length the number of bytes to encode + * @param length the number of bytes to encode * @param charset the desired character encoding * @return The result of the conversion. */ public static String getString( - final byte[] data, - int offset, - int length, + final byte[] data, + int offset, + int length, String charset ) { @@ -111,8 +111,8 @@ public final class EncodingUtils { } catch (UnsupportedEncodingException e) { return data.getBytes(); } - } - + } + /** * Converts the specified string to byte array of ASCII characters. * @@ -139,7 +139,7 @@ public final class EncodingUtils { * * @param data the byte array to be encoded * @param offset the index of the first byte to encode - * @param length the number of bytes to encode + * @param length the number of bytes to encode * @return The string representation of the byte array */ public static String getAsciiString(final byte[] data, int offset, int length) { Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/EntityUtils.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/EntityUtils.java?rev=937295&r1=937294&r2=937295&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/EntityUtils.java (original) +++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/EntityUtils.java Fri Apr 23 13:44:00 2010 @@ -40,7 +40,7 @@ import org.apache.http.protocol.HTTP; /** * Static helpers for dealing with {@link HttpEntity}s. - * + * * @since 4.0 */ public final class EntityUtils { @@ -51,10 +51,10 @@ public final class EntityUtils { /** * Ensures that the entity content is fully consumed and the content stream, if exists, * is closed. - * + * * @param entity * @throws IOException if an error occurs reading the input stream - * + * * @since 4.1 */ public static void consume(final HttpEntity entity) throws IOException { @@ -68,10 +68,10 @@ public final class EntityUtils { } } } - + /** * Read the contents of an entity and return it as a byte array. - * + * * @param entity * @return byte array containing the entity content. May be empty; never null. * @throws IOException if an error occurs reading the input stream @@ -104,10 +104,10 @@ public final class EntityUtils { } return buffer.toByteArray(); } - + /** * Obtains character set of the entity, if known. - * + * * @param entity must not be null * @return the character set, or null if not found * @throws ParseException if header elements cannot be parsed @@ -118,7 +118,7 @@ public final class EntityUtils { throw new IllegalArgumentException("HTTP entity may not be null"); } String charset = null; - if (entity.getContentType() != null) { + if (entity.getContentType() != null) { HeaderElement values[] = entity.getContentType().getElements(); if (values.length > 0) { NameValuePair param = values[0].getParameterByName("charset"); @@ -132,12 +132,12 @@ public final class EntityUtils { /** * Obtains mime type of the entity, if known. - * + * * @param entity must not be null * @return the character set, or null if not found * @throws ParseException if header elements cannot be parsed * @throws IllegalArgumentException if entity is null - * + * * @since 4.1 */ public static String getContentMimeType(final HttpEntity entity) throws ParseException { @@ -145,7 +145,7 @@ public final class EntityUtils { throw new IllegalArgumentException("HTTP entity may not be null"); } String mimeType = null; - if (entity.getContentType() != null) { + if (entity.getContentType() != null) { HeaderElement values[] = entity.getContentType().getElements(); if (values.length > 0) { mimeType = values[0].getName(); @@ -156,9 +156,9 @@ public final class EntityUtils { /** * Get the entity content as a String, using the provided default character set - * if none is found in the entity. + * if none is found in the entity. * If defaultCharset is null, the default "ISO-8859-1" is used. - * + * * @param entity must not be null * @param defaultCharset character set to be applied if none found in the entity * @return the entity content as a String @@ -190,7 +190,7 @@ public final class EntityUtils { charset = HTTP.DEFAULT_CONTENT_CHARSET; } Reader reader = new InputStreamReader(instream, charset); - CharArrayBuffer buffer = new CharArrayBuffer(i); + CharArrayBuffer buffer = new CharArrayBuffer(i); try { char[] tmp = new char[1024]; int l; @@ -207,7 +207,7 @@ public final class EntityUtils { * Read the contents of an entity and return it as a String. * The content is converted using the character set from the entity (if any), * failing that, "ISO-8859-1" is used. - * + * * @param entity * @return String containing the content. * @throws ParseException if header elements cannot be parsed @@ -218,5 +218,5 @@ public final class EntityUtils { throws IOException, ParseException { return toString(entity, null); } - + } Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/ExceptionUtils.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/ExceptionUtils.java?rev=937295&r1=937294&r2=937295&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/ExceptionUtils.java (original) +++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/ExceptionUtils.java Fri Apr 23 13:44:00 2010 @@ -30,8 +30,8 @@ import java.lang.reflect.Method; /** * The home for utility methods that handle various exception-related tasks. - * - * + * + * * @since 4.0 */ public final class ExceptionUtils { @@ -44,10 +44,10 @@ public final class ExceptionUtils { * {@link Throwable#initCause(Throwable) initCause} method of {@link Throwable}, * or null if the method * does not exist. - * + * * @return A Method for Throwable.initCause, or * null if unavailable. - */ + */ static private Method getInitCauseMethod() { try { Class[] paramsClasses = new Class[] { Throwable.class }; @@ -56,10 +56,10 @@ public final class ExceptionUtils { return null; } } - - /** + + /** * If we're running on JDK 1.4 or later, initialize the cause for the given throwable. - * + * * @param throwable The throwable. * @param cause The cause of the throwable. */ @@ -75,5 +75,5 @@ public final class ExceptionUtils { private ExceptionUtils() { } - + } Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/LangUtils.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/LangUtils.java?rev=937295&r1=937294&r2=937295&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/LangUtils.java (original) +++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/util/LangUtils.java Fri Apr 23 13:44:00 2010 @@ -30,12 +30,12 @@ package org.apache.http.util; /** * A set of utility methods to help produce consistent * {@link Object#equals equals} and {@link Object#hashCode hashCode} methods. - * - * + * + * * @since 4.0 */ public final class LangUtils { - + public static final int HASH_SEED = 17; public static final int HASH_OFFSET = 37; @@ -50,11 +50,11 @@ public final class LangUtils { public static int hashCode(final int seed, final boolean b) { return hashCode(seed, b ? 1 : 0); } - + public static int hashCode(final int seed, final Object obj) { return hashCode(seed, obj != null ? obj.hashCode() : 0); } - + public static boolean equals(final Object obj1, final Object obj2) { return obj1 == null ? obj2 == null : obj1.equals(obj2); } @@ -79,5 +79,5 @@ public final class LangUtils { } } } - + } Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/TestHttpExceptions.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/TestHttpExceptions.java?rev=937295&r1=937294&r2=937295&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/TestHttpExceptions.java (original) +++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/TestHttpExceptions.java Fri Apr 23 13:44:00 2010 @@ -58,5 +58,5 @@ public class TestHttpExceptions extends new UnsupportedHttpVersionException(); new UnsupportedHttpVersionException("Oppsie"); } - + } Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/TestHttpHost.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/TestHttpHost.java?rev=937295&r1=937294&r2=937295&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/TestHttpHost.java (original) +++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/TestHttpHost.java Fri Apr 23 13:44:00 2010 @@ -46,21 +46,21 @@ public class TestHttpHost extends TestCa public void testConstructor() { HttpHost host1 = new HttpHost("somehost"); - assertEquals("somehost", host1.getHostName()); - assertEquals(-1, host1.getPort()); - assertEquals("http", host1.getSchemeName()); + assertEquals("somehost", host1.getHostName()); + assertEquals(-1, host1.getPort()); + assertEquals("http", host1.getSchemeName()); HttpHost host2 = new HttpHost("somehost", 8080); - assertEquals("somehost", host2.getHostName()); - assertEquals(8080, host2.getPort()); - assertEquals("http", host2.getSchemeName()); + assertEquals("somehost", host2.getHostName()); + assertEquals(8080, host2.getPort()); + assertEquals("http", host2.getSchemeName()); HttpHost host3 = new HttpHost("somehost", -1); - assertEquals("somehost", host3.getHostName()); - assertEquals(-1, host3.getPort()); - assertEquals("http", host3.getSchemeName()); + assertEquals("somehost", host3.getHostName()); + assertEquals(-1, host3.getPort()); + assertEquals("http", host3.getSchemeName()); HttpHost host4 = new HttpHost("somehost", 443, "https"); - assertEquals("somehost", host4.getHostName()); - assertEquals(443, host4.getPort()); - assertEquals("https", host4.getSchemeName()); + assertEquals("somehost", host4.getHostName()); + assertEquals(443, host4.getPort()); + assertEquals("https", host4.getSchemeName()); try { new HttpHost(null, -1, null); fail("IllegalArgumentException should have been thrown"); @@ -68,7 +68,7 @@ public class TestHttpHost extends TestCa //expected } } - + public void testHashCode() { HttpHost host1 = new HttpHost("somehost", 8080, "http"); HttpHost host2 = new HttpHost("somehost", 80, "http"); @@ -84,7 +84,7 @@ public class TestHttpHost extends TestCa assertTrue(host2.hashCode() == host5.hashCode()); assertTrue(host5.hashCode() != host6.hashCode()); } - + public void testEquals() { HttpHost host1 = new HttpHost("somehost", 8080, "http"); HttpHost host2 = new HttpHost("somehost", 80, "http"); @@ -102,7 +102,7 @@ public class TestHttpHost extends TestCa assertFalse(host1.equals(null)); assertFalse(host1.equals("http://somehost")); } - + public void testToString() { HttpHost host1 = new HttpHost("somehost"); assertEquals("http://somehost", host1.toString()); @@ -134,7 +134,7 @@ public class TestHttpHost extends TestCa HttpHost clone = (HttpHost) orig.clone(); assertEquals(orig, clone); } - + public void testSerialization() throws Exception { HttpHost orig = new HttpHost("somehost", 8080, "https"); ByteArrayOutputStream outbuffer = new ByteArrayOutputStream(); @@ -147,5 +147,5 @@ public class TestHttpHost extends TestCa HttpHost clone = (HttpHost) instream.readObject(); assertEquals(orig, clone); } - + } Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/TestHttpVersion.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/TestHttpVersion.java?rev=937295&r1=937294&r2=937295&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/TestHttpVersion.java (original) +++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/TestHttpVersion.java Fri Apr 23 13:44:00 2010 @@ -47,16 +47,16 @@ public class TestHttpVersion extends Tes } // ------------------------------------------------------------------ Tests - + public void testHttpVersionInvalidConstructorInput() throws Exception { try { - new HttpVersion(-1, -1); + new HttpVersion(-1, -1); fail("IllegalArgumentException should have been thrown"); } catch (IllegalArgumentException e) { // expected } try { - new HttpVersion(0, -1); + new HttpVersion(0, -1); fail("IllegalArgumentException should have been thrown"); } catch (IllegalArgumentException e) { // expected @@ -64,9 +64,9 @@ public class TestHttpVersion extends Tes } public void testHttpVersionEquality() throws Exception { - HttpVersion ver1 = new HttpVersion(1, 1); - HttpVersion ver2 = new HttpVersion(1, 1); - + HttpVersion ver1 = new HttpVersion(1, 1); + HttpVersion ver2 = new HttpVersion(1, 1); + assertEquals(ver1.hashCode(), ver2.hashCode()); assertTrue(ver1.equals(ver1)); assertTrue(ver1.equals(ver2)); @@ -74,7 +74,7 @@ public class TestHttpVersion extends Tes assertTrue(ver1.equals(ver2)); assertFalse(ver1.equals(new Float(1.1))); - + assertTrue((new HttpVersion(0, 9)).equals(HttpVersion.HTTP_0_9)); assertTrue((new HttpVersion(1, 0)).equals(HttpVersion.HTTP_1_0)); assertTrue((new HttpVersion(1, 1)).equals(HttpVersion.HTTP_1_1)); @@ -103,18 +103,18 @@ public class TestHttpVersion extends Tes assertTrue(HttpVersion.HTTP_0_9.lessEquals(HttpVersion.HTTP_1_1)); assertTrue(HttpVersion.HTTP_0_9.greaterEquals(HttpVersion.HTTP_0_9)); assertFalse(HttpVersion.HTTP_0_9.greaterEquals(HttpVersion.HTTP_1_0)); - + assertTrue(HttpVersion.HTTP_1_0.compareToVersion(HttpVersion.HTTP_1_1) < 0); assertTrue(HttpVersion.HTTP_1_0.compareToVersion(HttpVersion.HTTP_0_9) > 0); assertTrue(HttpVersion.HTTP_1_0.compareToVersion(HttpVersion.HTTP_1_0) == 0); } - + public void testCloning() throws Exception { HttpVersion orig = HttpVersion.HTTP_1_1; HttpVersion clone = (HttpVersion) orig.clone(); assertEquals(orig, clone); } - + public void testSerialization() throws Exception { HttpVersion orig = HttpVersion.HTTP_1_1; ByteArrayOutputStream outbuffer = new ByteArrayOutputStream(); @@ -127,6 +127,6 @@ public class TestHttpVersion extends Tes HttpVersion clone = (HttpVersion) instream.readObject(); assertEquals(orig, clone); } - + } Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestAbstractHttpEntity.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestAbstractHttpEntity.java?rev=937295&r1=937294&r2=937295&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestAbstractHttpEntity.java (original) +++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestAbstractHttpEntity.java Fri Apr 23 13:44:00 2010 @@ -82,5 +82,5 @@ public class TestAbstractHttpEntity exte httpentity.setChunked(true); assertTrue(httpentity.isChunked()); } - + } Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestBasicHttpEntity.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestBasicHttpEntity.java?rev=937295&r1=937294&r2=937295&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestBasicHttpEntity.java (original) +++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestBasicHttpEntity.java Fri Apr 23 13:44:00 2010 @@ -46,18 +46,18 @@ public class TestBasicHttpEntity extends } public void testBasics() throws Exception { - + byte[] bytes = "Message content".getBytes(HTTP.US_ASCII); InputStream content = new ByteArrayInputStream(bytes); BasicHttpEntity httpentity = new BasicHttpEntity(); httpentity.setContent(content); httpentity.setContentLength(bytes.length); - + assertEquals(bytes.length, httpentity.getContentLength()); assertFalse(httpentity.isRepeatable()); assertTrue(httpentity.isStreaming()); } - + public void testContent() throws Exception { byte[] bytes = "Message content".getBytes(HTTP.US_ASCII); InputStream content = new ByteArrayInputStream(bytes); @@ -79,13 +79,13 @@ public class TestBasicHttpEntity extends // expected } } - + public void testWriteTo() throws Exception { byte[] bytes = "Message content".getBytes(HTTP.US_ASCII); InputStream content = new ByteArrayInputStream(bytes); BasicHttpEntity httpentity = new BasicHttpEntity(); httpentity.setContent(content); - + ByteArrayOutputStream out = new ByteArrayOutputStream(); httpentity.writeTo(out); byte[] bytes2 = out.toByteArray(); Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestBufferedHttpEntity.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestBufferedHttpEntity.java?rev=937295&r1=937294&r2=937295&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestBufferedHttpEntity.java (original) +++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestBufferedHttpEntity.java Fri Apr 23 13:44:00 2010 @@ -86,7 +86,7 @@ public class TestBufferedHttpEntity exte byte[] bytes = "Message content".getBytes(HTTP.US_ASCII); InputStreamEntity httpentity = new InputStreamEntity(new ByteArrayInputStream(bytes), -1); BufferedHttpEntity bufentity = new BufferedHttpEntity(httpentity); - + ByteArrayOutputStream out = new ByteArrayOutputStream(); bufentity.writeTo(out); byte[] bytes2 = out.toByteArray(); @@ -104,7 +104,7 @@ public class TestBufferedHttpEntity exte for (int i = 0; i < bytes.length; i++) { assertEquals(bytes[i], bytes2[i]); } - + try { bufentity.writeTo(null); fail("IllegalArgumentException should have been thrown"); @@ -112,12 +112,12 @@ public class TestBufferedHttpEntity exte // expected } } - + public void testWriteToWrapped() throws Exception { byte[] bytes = "Message content".getBytes(HTTP.US_ASCII); ByteArrayEntity httpentity = new ByteArrayEntity(bytes); BufferedHttpEntity bufentity = new BufferedHttpEntity(httpentity); - + ByteArrayOutputStream out = new ByteArrayOutputStream(); bufentity.writeTo(out); byte[] bytes2 = out.toByteArray(); @@ -135,7 +135,7 @@ public class TestBufferedHttpEntity exte for (int i = 0; i < bytes.length; i++) { assertEquals(bytes[i], bytes2[i]); } - + try { bufentity.writeTo(null); fail("IllegalArgumentException should have been thrown"); Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestByteArrayEntity.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestByteArrayEntity.java?rev=937295&r1=937294&r2=937295&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestByteArrayEntity.java (original) +++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestByteArrayEntity.java Fri Apr 23 13:44:00 2010 @@ -46,13 +46,13 @@ public class TestByteArrayEntity extends public void testBasics() throws Exception { byte[] bytes = "Message content".getBytes(HTTP.US_ASCII); ByteArrayEntity httpentity = new ByteArrayEntity(bytes); - + assertEquals(bytes.length, httpentity.getContentLength()); assertNotNull(httpentity.getContent()); assertTrue(httpentity.isRepeatable()); - assertFalse(httpentity.isStreaming()); + assertFalse(httpentity.isStreaming()); } - + public void testIllegalConstructor() throws Exception { try { new ByteArrayEntity(null); @@ -65,7 +65,7 @@ public class TestByteArrayEntity extends public void testWriteTo() throws Exception { byte[] bytes = "Message content".getBytes(HTTP.US_ASCII); ByteArrayEntity httpentity = new ByteArrayEntity(bytes); - + ByteArrayOutputStream out = new ByteArrayOutputStream(); httpentity.writeTo(out); byte[] bytes2 = out.toByteArray(); @@ -83,7 +83,7 @@ public class TestByteArrayEntity extends for (int i = 0; i < bytes.length; i++) { assertEquals(bytes[i], bytes2[i]); } - + try { httpentity.writeTo(null); fail("IllegalArgumentException should have been thrown"); @@ -91,5 +91,5 @@ public class TestByteArrayEntity extends // expected } } - + } Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestEntityTemplate.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestEntityTemplate.java?rev=937295&r1=937294&r2=937295&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestEntityTemplate.java (original) +++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestEntityTemplate.java Fri Apr 23 13:44:00 2010 @@ -52,9 +52,9 @@ public class TestEntityTemplate extends public void writeTo(final OutputStream outstream) throws IOException { outstream.write('a'); } - + }); - + assertEquals(-1, httpentity.getContentLength()); assertTrue(httpentity.isRepeatable()); assertFalse(httpentity.isStreaming()); @@ -75,15 +75,15 @@ public class TestEntityTemplate extends public void writeTo(final OutputStream outstream) throws IOException { outstream.write('a'); } - + }); - + ByteArrayOutputStream out = new ByteArrayOutputStream(); httpentity.writeTo(out); byte[] bytes2 = out.toByteArray(); assertNotNull(bytes2); assertEquals(1, bytes2.length); - + try { httpentity.writeTo(null); fail("IllegalArgumentException should have been thrown"); @@ -91,14 +91,14 @@ public class TestEntityTemplate extends // expected } } - + public void testgetContent() throws Exception { HttpEntity httpentity = new EntityTemplate(new ContentProducer() { public void writeTo(final OutputStream outstream) throws IOException { outstream.write('a'); } - + }); try { httpentity.getContent(); @@ -107,5 +107,5 @@ public class TestEntityTemplate extends // expected } } - + } Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestFileEntity.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestFileEntity.java?rev=937295&r1=937294&r2=937295&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestFileEntity.java (original) +++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestFileEntity.java Fri Apr 23 13:44:00 2010 @@ -50,13 +50,13 @@ public class TestFileEntity extends Test File tmpfile = File.createTempFile("testfile", ".txt"); tmpfile.deleteOnExit(); FileEntity httpentity = new FileEntity(tmpfile, HTTP.ISO_8859_1); - + assertEquals(tmpfile.length(), httpentity.getContentLength()); final InputStream content = httpentity.getContent(); assertNotNull(content); content.close(); assertTrue(httpentity.isRepeatable()); - assertFalse(httpentity.isStreaming()); + assertFalse(httpentity.isStreaming()); if (!tmpfile.delete()){ fail("Failed to delete: "+tmpfile); } @@ -74,16 +74,16 @@ public class TestFileEntity extends Test public void testWriteTo() throws Exception { File tmpfile = File.createTempFile("testfile", ".txt"); tmpfile.deleteOnExit(); - + FileOutputStream outstream = new FileOutputStream(tmpfile); outstream.write(0); outstream.write(1); outstream.write(2); outstream.write(3); outstream.close(); - + FileEntity httpentity = new FileEntity(tmpfile, HTTP.ISO_8859_1); - + ByteArrayOutputStream out = new ByteArrayOutputStream(); httpentity.writeTo(out); byte[] bytes = out.toByteArray(); @@ -103,5 +103,5 @@ public class TestFileEntity extends Test // expected } } - + } Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestHttpEntityWrapper.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestHttpEntityWrapper.java?rev=937295&r1=937294&r2=937295&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestHttpEntityWrapper.java (original) +++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestHttpEntityWrapper.java Fri Apr 23 13:44:00 2010 @@ -49,8 +49,8 @@ public class TestHttpEntityWrapper exten StringEntity httpentity = new StringEntity(s, HTTP.ISO_8859_1); httpentity.setContentType(HTTP.PLAIN_TEXT_TYPE); httpentity.setContentEncoding(HTTP.IDENTITY_CODING); - HttpEntityWrapper wrapped = new HttpEntityWrapper(httpentity); - + HttpEntityWrapper wrapped = new HttpEntityWrapper(httpentity); + assertEquals(httpentity.getContentLength(), wrapped.getContentLength()); assertEquals(httpentity.getContentType(), wrapped.getContentType()); assertEquals(httpentity.getContentEncoding(), wrapped.getContentEncoding()); @@ -73,8 +73,8 @@ public class TestHttpEntityWrapper exten String s = "Message content"; byte[] bytes = s.getBytes(HTTP.ISO_8859_1); StringEntity httpentity = new StringEntity(s); - HttpEntityWrapper wrapped = new HttpEntityWrapper(httpentity); - + HttpEntityWrapper wrapped = new HttpEntityWrapper(httpentity); + ByteArrayOutputStream out = new ByteArrayOutputStream(); wrapped.writeTo(out); byte[] bytes2 = out.toByteArray(); @@ -92,7 +92,7 @@ public class TestHttpEntityWrapper exten for (int i = 0; i < bytes.length; i++) { assertEquals(bytes[i], bytes2[i]); } - + try { wrapped.writeTo(null); fail("IllegalArgumentException should have been thrown"); @@ -108,5 +108,5 @@ public class TestHttpEntityWrapper exten EntityUtils.consume(wrapped); EntityUtils.consume(wrapped); } - + } Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestInputStreamEntity.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestInputStreamEntity.java?rev=937295&r1=937294&r2=937295&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestInputStreamEntity.java (original) +++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestInputStreamEntity.java Fri Apr 23 13:44:00 2010 @@ -49,7 +49,7 @@ public class TestInputStreamEntity exten byte[] bytes = "Message content".getBytes(HTTP.ISO_8859_1); InputStream instream = new ByteArrayInputStream(bytes); InputStreamEntity httpentity = new InputStreamEntity(instream, bytes.length); - + assertEquals(bytes.length, httpentity.getContentLength()); assertEquals(instream, httpentity.getContent()); assertNotNull(httpentity.getContent()); @@ -70,7 +70,7 @@ public class TestInputStreamEntity exten byte[] bytes = "Message content".getBytes(HTTP.ISO_8859_1); InputStream instream = new ByteArrayInputStream(bytes); InputStreamEntity httpentity = new InputStreamEntity(instream, 7); - + ByteArrayOutputStream out = new ByteArrayOutputStream(); httpentity.writeTo(out); byte[] bytes2 = out.toByteArray(); @@ -96,7 +96,7 @@ public class TestInputStreamEntity exten assertNotNull(bytes2); assertEquals(bytes.length, bytes2.length); assertFalse(httpentity.isStreaming()); - + try { httpentity.writeTo(null); fail("IllegalArgumentException should have been thrown"); @@ -104,7 +104,7 @@ public class TestInputStreamEntity exten // expected } } - + public void testConsume() throws Exception { byte[] bytes = "Message content".getBytes(HTTP.ISO_8859_1); InputStream instream = new ByteArrayInputStream(bytes); @@ -115,5 +115,5 @@ public class TestInputStreamEntity exten httpentity.consumeContent(); assertFalse(httpentity.isStreaming()); } - + } Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestSerializableEntity.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestSerializableEntity.java?rev=937295&r1=937294&r2=937295&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestSerializableEntity.java (original) +++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestSerializableEntity.java Fri Apr 23 13:44:00 2010 @@ -44,7 +44,7 @@ public class TestSerializableEntity exte public int intValue = 4; public String stringValue = "Hello"; - + public SerializableObject() {} } @@ -81,7 +81,7 @@ public class TestSerializableEntity exte assertTrue(httpentity.isRepeatable()); assertFalse(httpentity.isStreaming()); } - + public void testIllegalConstructor() throws Exception { try { new SerializableEntity(null, false); @@ -112,7 +112,7 @@ public class TestSerializableEntity exte // expected } } - + public void testWriteToDirect() throws Exception { Serializable serializableObj = new SerializableObject(); SerializableEntity httpentity = new SerializableEntity(serializableObj, false); Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestStringEntity.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestStringEntity.java?rev=937295&r1=937294&r2=937295&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestStringEntity.java (original) +++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/entity/TestStringEntity.java Fri Apr 23 13:44:00 2010 @@ -46,12 +46,12 @@ public class TestStringEntity extends Te public void testBasics() throws Exception { String s = "Message content"; StringEntity httpentity = new StringEntity(s, HTTP.ISO_8859_1); - + byte[] bytes = s.getBytes(HTTP.ISO_8859_1); assertEquals(bytes.length, httpentity.getContentLength()); assertNotNull(httpentity.getContent()); assertTrue(httpentity.isRepeatable()); - assertFalse(httpentity.isStreaming()); + assertFalse(httpentity.isStreaming()); } public void testIllegalConstructor() throws Exception { @@ -66,13 +66,13 @@ public class TestStringEntity extends Te public void testDefaultContent() throws Exception { String s = "Message content"; StringEntity httpentity = new StringEntity(s, "text/csv", "ANSI_X3.4-1968"); - assertEquals("text/csv; charset=ANSI_X3.4-1968", + assertEquals("text/csv; charset=ANSI_X3.4-1968", httpentity.getContentType().getValue()); httpentity = new StringEntity(s, HTTP.US_ASCII); - assertEquals("text/plain; charset=US-ASCII", + assertEquals("text/plain; charset=US-ASCII", httpentity.getContentType().getValue()); httpentity = new StringEntity(s); - assertEquals("text/plain; charset=ISO-8859-1", + assertEquals("text/plain; charset=ISO-8859-1", httpentity.getContentType().getValue()); } @@ -80,7 +80,7 @@ public class TestStringEntity extends Te String s = "Message content"; byte[] bytes = s.getBytes(HTTP.ISO_8859_1); StringEntity httpentity = new StringEntity(s); - + ByteArrayOutputStream out = new ByteArrayOutputStream(); httpentity.writeTo(out); byte[] bytes2 = out.toByteArray(); @@ -98,7 +98,7 @@ public class TestStringEntity extends Te for (int i = 0; i < bytes.length; i++) { assertEquals(bytes[i], bytes2[i]); } - + try { httpentity.writeTo(null); fail("IllegalArgumentException should have been thrown"); @@ -106,5 +106,5 @@ public class TestStringEntity extends Te // expected } } - + } Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestDefaultConnectionReuseStrategy.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestDefaultConnectionReuseStrategy.java?rev=937295&r1=937294&r2=937295&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestDefaultConnectionReuseStrategy.java (original) +++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestDefaultConnectionReuseStrategy.java Fri Apr 23 13:44:00 2010 @@ -150,7 +150,7 @@ public class TestDefaultConnectionReuseS assertFalse(reuseStrategy.keepAlive(response, context)); } - + public void testExplicitClose() throws Exception { // Use HTTP 1.1 HttpResponse response = @@ -159,7 +159,7 @@ public class TestDefaultConnectionReuseS assertFalse(reuseStrategy.keepAlive(response, context)); } - + public void testExplicitKeepAlive() throws Exception { // Use HTTP 1.0 HttpResponse response = @@ -175,7 +175,7 @@ public class TestDefaultConnectionReuseS assertFalse(reuseStrategy.keepAlive(response, context)); } - + public void testHTTP11Default() throws Exception { HttpResponse response = createResponse(HttpVersion.HTTP_1_1, 200, "OK"); @@ -188,7 +188,7 @@ public class TestDefaultConnectionReuseS assertTrue(reuseStrategy.keepAlive(response, context)); } - + public void testBrokenConnectionDirective1() throws Exception { // Use HTTP 1.0 HttpResponse response = @@ -374,7 +374,7 @@ public class TestDefaultConnectionReuseS public HttpConnectionMetrics getMetrics() { return null; } - + } // class MockConnection } // class TestDefaultConnectionReuseStrategy Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestSessionBuffers.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestSessionBuffers.java?rev=937295&r1=937294&r2=937295&view=diff ============================================================================== --- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestSessionBuffers.java (original) +++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/TestSessionBuffers.java Fri Apr 23 13:44:00 2010 @@ -52,29 +52,29 @@ public class TestSessionBuffers extends public void testInit() throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(); - new SessionOutputBufferMockup(out); + new SessionOutputBufferMockup(out); try { - new SessionOutputBufferMockup(null, new BasicHttpParams()); + new SessionOutputBufferMockup(null, new BasicHttpParams()); fail("IllegalArgumentException should have been thrown"); } catch (IllegalArgumentException ex) { //expected } ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); - new SessionInputBufferMockup(in, 10); + new SessionInputBufferMockup(in, 10); try { - new SessionInputBufferMockup(in, -10); + new SessionInputBufferMockup(in, -10); fail("IllegalArgumentException should have been thrown"); } catch (IllegalArgumentException ex) { //expected } try { - new SessionOutputBufferMockup(out, -10); + new SessionOutputBufferMockup(out, -10); fail("IllegalArgumentException should have been thrown"); } catch (IllegalArgumentException ex) { //expected } try { - new SessionInputBufferMockup((InputStream)null, 1024); + new SessionInputBufferMockup((InputStream)null, 1024); fail("IllegalArgumentException should have been thrown"); } catch (IllegalArgumentException ex) { //expected @@ -90,7 +90,7 @@ public class TestSessionBuffers extends assertEquals(SessionInputBufferMockup.BUFFER_SIZE - 2, inbuffer.available()); assertEquals(2, inbuffer.length()); - SessionOutputBufferMockup outbuffer = new SessionOutputBufferMockup(); + SessionOutputBufferMockup outbuffer = new SessionOutputBufferMockup(); assertEquals(SessionOutputBufferMockup.BUFFER_SIZE, outbuffer.capacity()); assertEquals(SessionOutputBufferMockup.BUFFER_SIZE, outbuffer.available()); assertEquals(0, outbuffer.length()); @@ -98,9 +98,9 @@ public class TestSessionBuffers extends assertEquals(SessionOutputBufferMockup.BUFFER_SIZE - 3, outbuffer.available()); assertEquals(3, outbuffer.length()); } - + public void testBasicReadWriteLine() throws Exception { - + String[] teststrs = new String[5]; teststrs[0] = "Hello"; teststrs[1] = "This string should be much longer than the size of the output buffer " + @@ -113,9 +113,9 @@ public class TestSessionBuffers extends teststrs[2] = buffer.toString(); teststrs[3] = ""; teststrs[4] = "And goodbye"; - - CharArrayBuffer chbuffer = new CharArrayBuffer(16); - SessionOutputBufferMockup outbuffer = new SessionOutputBufferMockup(); + + CharArrayBuffer chbuffer = new CharArrayBuffer(16); + SessionOutputBufferMockup outbuffer = new SessionOutputBufferMockup(); for (int i = 0; i < teststrs.length; i++) { chbuffer.clear(); chbuffer.append(teststrs[i]); @@ -125,7 +125,7 @@ public class TestSessionBuffers extends outbuffer.writeLine((String)null); outbuffer.writeLine((CharArrayBuffer)null); outbuffer.flush(); - + HttpTransportMetrics tmetrics = outbuffer.getMetrics(); long bytesWritten = tmetrics.getBytesTransferred(); long expected = 0; @@ -133,14 +133,14 @@ public class TestSessionBuffers extends expected += (teststrs[i].length() + 2/*CRLF*/); } assertEquals(expected, bytesWritten); - + SessionInputBufferMockup inbuffer = new SessionInputBufferMockup( outbuffer.getData()); for (int i = 0; i < teststrs.length; i++) { assertEquals(teststrs[i], inbuffer.readLine()); } - + assertNull(inbuffer.readLine()); assertNull(inbuffer.readLine()); tmetrics = inbuffer.getMetrics(); @@ -149,7 +149,7 @@ public class TestSessionBuffers extends } public void testComplexReadWriteLine() throws Exception { - SessionOutputBufferMockup outbuffer = new SessionOutputBufferMockup(); + SessionOutputBufferMockup outbuffer = new SessionOutputBufferMockup(); outbuffer.write(new byte[] {'a', '\n'}); outbuffer.write(new byte[] {'\r', '\n'}); outbuffer.write(new byte[] {'\r', '\r', '\n'}); @@ -157,12 +157,12 @@ public class TestSessionBuffers extends //these write operations should have no effect outbuffer.write(null); outbuffer.write(null, 0, 12); - + outbuffer.flush(); long bytesWritten = outbuffer.getMetrics().getBytesTransferred(); assertEquals(8, bytesWritten); - + StringBuffer buffer = new StringBuffer(); for (int i = 0; i < 14; i++) { buffer.append("a"); @@ -200,7 +200,7 @@ public class TestSessionBuffers extends outbuffer.flush(); bytesWritten = outbuffer.getMetrics().getBytesTransferred(); assertEquals(8 + 14 + 2 + 15 + 2 + 16 + 2 + 1, bytesWritten); - + SessionInputBufferMockup inbuffer = new SessionInputBufferMockup( outbuffer.getData()); @@ -217,9 +217,9 @@ public class TestSessionBuffers extends long bytesRead = inbuffer.getMetrics().getBytesTransferred(); assertEquals(bytesWritten, bytesRead); } - + public void testBasicReadWriteLineLargeBuffer() throws Exception { - + String[] teststrs = new String[5]; teststrs[0] = "Hello"; teststrs[1] = "This string should be much longer than the size of the output buffer " + @@ -232,9 +232,9 @@ public class TestSessionBuffers extends teststrs[2] = buffer.toString(); teststrs[3] = ""; teststrs[4] = "And goodbye"; - - CharArrayBuffer chbuffer = new CharArrayBuffer(16); - SessionOutputBufferMockup outbuffer = new SessionOutputBufferMockup(); + + CharArrayBuffer chbuffer = new CharArrayBuffer(16); + SessionOutputBufferMockup outbuffer = new SessionOutputBufferMockup(); for (int i = 0; i < teststrs.length; i++) { chbuffer.clear(); chbuffer.append(teststrs[i]); @@ -244,14 +244,14 @@ public class TestSessionBuffers extends outbuffer.writeLine((String)null); outbuffer.writeLine((CharArrayBuffer)null); outbuffer.flush(); - + long bytesWritten = outbuffer.getMetrics().getBytesTransferred(); long expected = 0; for (int i = 0; i < teststrs.length; i++) { expected += (teststrs[i].length() + 2/*CRLF*/); } assertEquals(expected, bytesWritten); - + SessionInputBufferMockup inbuffer = new SessionInputBufferMockup( outbuffer.getData(), 1024); @@ -291,15 +291,15 @@ public class TestSessionBuffers extends for (int i = 0; i < out.length; i++) { assertEquals(out[i], tmp[i]); } - + SessionInputBufferMockup inbuffer = new SessionInputBufferMockup(tmp); // these read operations will have no effect assertEquals(0, inbuffer.read(null, 0, 10)); - assertEquals(0, inbuffer.read(null)); + assertEquals(0, inbuffer.read(null)); long bytesRead = inbuffer.getMetrics().getBytesTransferred(); assertEquals(0, bytesRead); - + byte[] in = new byte[40]; off = 0; remaining = in.length; @@ -323,7 +323,7 @@ public class TestSessionBuffers extends bytesRead = inbuffer.getMetrics().getBytesTransferred(); assertEquals(out.length, bytesRead); } - + public void testReadWriteByte() throws Exception { // make the buffer larger than that of outbuffer byte[] out = new byte[40]; @@ -343,7 +343,7 @@ public class TestSessionBuffers extends for (int i = 0; i < out.length; i++) { assertEquals(out[i], tmp[i]); } - + SessionInputBufferMockup inbuffer = new SessionInputBufferMockup(tmp); byte[] in = new byte[40]; for (int i = 0; i < in.length; i++) { @@ -361,14 +361,14 @@ public class TestSessionBuffers extends public void testLineLimit() throws Exception { HttpParams params = new BasicHttpParams(); String s = "a very looooooooooooooooooooooooooooooooooooooong line\r\n "; - byte[] tmp = s.getBytes("US-ASCII"); + byte[] tmp = s.getBytes("US-ASCII"); // no limit params.setIntParameter(CoreConnectionPNames.MAX_LINE_LENGTH, 0); SessionInputBufferMockup inbuffer1 = new SessionInputBufferMockup(tmp, 5, params); assertNotNull(inbuffer1.readLine()); long bytesRead = inbuffer1.getMetrics().getBytesTransferred(); assertEquals(60, bytesRead); - + // 15 char limit params.setIntParameter(CoreConnectionPNames.MAX_LINE_LENGTH, 15); SessionInputBufferMockup inbuffer2 = new SessionInputBufferMockup(tmp, 5, params); @@ -385,17 +385,17 @@ public class TestSessionBuffers extends static final int SWISS_GERMAN_HELLO [] = { 0x47, 0x72, 0xFC, 0x65, 0x7A, 0x69, 0x5F, 0x7A, 0xE4, 0x6D, 0xE4 }; - + static final int RUSSIAN_HELLO [] = { - 0x412, 0x441, 0x435, 0x43C, 0x5F, 0x43F, 0x440, 0x438, - 0x432, 0x435, 0x442 - }; - + 0x412, 0x441, 0x435, 0x43C, 0x5F, 0x43F, 0x440, 0x438, + 0x432, 0x435, 0x442 + }; + private static String constructString(int [] unicodeChars) { StringBuffer buffer = new StringBuffer(); if (unicodeChars != null) { for (int i = 0; i < unicodeChars.length; i++) { - buffer.append((char)unicodeChars[i]); + buffer.append((char)unicodeChars[i]); } } return buffer.toString(); @@ -405,13 +405,13 @@ public class TestSessionBuffers extends String s1 = constructString(SWISS_GERMAN_HELLO); String s2 = constructString(RUSSIAN_HELLO); String s3 = "Like hello and stuff"; - + HttpParams params = new BasicHttpParams(); HttpProtocolParams.setHttpElementCharset(params, "UTF-8"); - + SessionOutputBufferMockup outbuffer = new SessionOutputBufferMockup(params); - CharArrayBuffer chbuffer = new CharArrayBuffer(16); + CharArrayBuffer chbuffer = new CharArrayBuffer(16); for (int i = 0; i < 10; i++) { chbuffer.clear(); chbuffer.append(s1); @@ -429,7 +429,7 @@ public class TestSessionBuffers extends (s2.toString().getBytes("UTF-8").length + 2) + (s3.toString().getBytes("UTF-8").length + 2)) * 10; assertEquals(expected, bytesWritten); - + SessionInputBufferMockup inbuffer = new SessionInputBufferMockup( outbuffer.getData(), params); @@ -446,13 +446,13 @@ public class TestSessionBuffers extends public void testNonAsciiReadWriteLine() throws Exception { String s1 = constructString(SWISS_GERMAN_HELLO); - + HttpParams params = new BasicHttpParams(); HttpProtocolParams.setHttpElementCharset(params, HTTP.ISO_8859_1); - + SessionOutputBufferMockup outbuffer = new SessionOutputBufferMockup(params); - CharArrayBuffer chbuffer = new CharArrayBuffer(16); + CharArrayBuffer chbuffer = new CharArrayBuffer(16); for (int i = 0; i < 10; i++) { chbuffer.clear(); chbuffer.append(s1); @@ -462,7 +462,7 @@ public class TestSessionBuffers extends long bytesWritten = outbuffer.getMetrics().getBytesTransferred(); long expected = ((s1.toString().getBytes(HTTP.ISO_8859_1).length + 2)) * 10; assertEquals(expected, bytesWritten); - + SessionInputBufferMockup inbuffer = new SessionInputBufferMockup( outbuffer.getData(), params); @@ -480,7 +480,7 @@ public class TestSessionBuffers extends public void testInvalidCharArrayBuffer() throws Exception { SessionInputBufferMockup inbuffer = new SessionInputBufferMockup(new byte[] {}); try { - inbuffer.readLine(null); + inbuffer.readLine(null); fail("IllegalArgumentException should have been thrown"); } catch (IllegalArgumentException ex) { //expected @@ -488,6 +488,6 @@ public class TestSessionBuffers extends assertEquals(0, bytesRead); } } - + }