Repository: commons-io
Updated Branches:
  refs/heads/master 941a9a6c2 -> 9e2b2c097


Fixed files in repo with incorrect line endings


Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/9e2b2c09
Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/9e2b2c09
Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/9e2b2c09

Branch: refs/heads/master
Commit: 9e2b2c09732ca596331f7ca34ba4e0f03d70093d
Parents: 941a9a6
Author: Kristian Rosenvold <krosenv...@apache.org>
Authored: Thu Sep 22 09:39:25 2016 +0200
Committer: Kristian Rosenvold <krosenv...@apache.org>
Committed: Thu Sep 22 09:39:25 2016 +0200

----------------------------------------------------------------------
 .../org/apache/commons/io/ByteOrderFactory.java | 152 ++++----
 .../java/org/apache/commons/io/Charsets.java    | 384 +++++++++----------
 .../MessageDigestCalculatingInputStream.java    | 168 ++++----
 .../apache/commons/io/ByteOrderFactoryTest.java |  86 ++---
 .../org/apache/commons/io/CharsetsTestCase.java | 180 ++++-----
 ...MessageDigestCalculatingInputStreamTest.java |  96 ++---
 .../io/input/ObservableInputStreamTest.java     | 268 ++++++-------
 7 files changed, 667 insertions(+), 667 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-io/blob/9e2b2c09/src/main/java/org/apache/commons/io/ByteOrderFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/io/ByteOrderFactory.java 
b/src/main/java/org/apache/commons/io/ByteOrderFactory.java
index b5f08ea..70d839d 100644
--- a/src/main/java/org/apache/commons/io/ByteOrderFactory.java
+++ b/src/main/java/org/apache/commons/io/ByteOrderFactory.java
@@ -1,76 +1,76 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.commons.io;
-
-import java.nio.ByteOrder;
-import java.util.Locale;
-
-/**
- * Converts Strings to {@link ByteOrder} instances.
- *
- * @since 2.6
- */
-public class ByteOrderFactory {
-
-    private static final Locale ComparisonLocale = Locale.ROOT;
-
-    /**
-     * Big endian.
-     */
-    public static final String BIG_ENDIAN = "Big";
-
-    /**
-     * Little endian.
-     */
-    public static final String LITTLE_ENDIAN = "Little";
-
-    /**
-     * Parses the String argument as a {@link ByteOrder}, ignoring case.
-     * <p>
-     * Returns {@code ByteOrder.LITTLE_ENDIAN} if the given value is {@code 
"little"} or {@code "LITTLE_ENDIAN"}.
-     * </p>
-     * <p>
-     * Returns {@code ByteOrder.BIG_ENDIAN} if the given value is {@code 
"big"} or {@code "BIG_ENDIAN"}.
-     * </p>
-     * Examples:
-     * <ul>
-     * <li>{@code ByteOrderFactory.parseByteOrder("little")} returns {@code 
ByteOrder.LITTLE_ENDIAN}</li>
-     * <li>{@code ByteOrderFactory.parseByteOrder("big")} returns {@code 
ByteOrder.BIG_ENDIAN}</li>
-     * </ul>
-     * 
-     * @param value
-     *            the {@code String} containing the ByteOrder representation 
to be parsed
-     * @return the ByteOrder represented by the string argument
-     * @throws IllegalArgumentException
-     *             if the {@code String} containing the ByteOrder 
representation to be parsed is unknown.
-     */
-    public static ByteOrder parseByteOrder(final String value) {
-        final String valueUp = value.toUpperCase(ComparisonLocale);
-        final String bigEndianUp = BIG_ENDIAN.toUpperCase(ComparisonLocale);
-        final String littleEndianUp = 
LITTLE_ENDIAN.toUpperCase(ComparisonLocale);
-        if (bigEndianUp.equals(valueUp) || 
ByteOrder.BIG_ENDIAN.toString().equals(valueUp)) {
-            return ByteOrder.BIG_ENDIAN;
-        }
-        if (littleEndianUp.equals(valueUp) || 
ByteOrder.LITTLE_ENDIAN.toString().equals(valueUp)) {
-            return ByteOrder.LITTLE_ENDIAN;
-        }
-        throw new IllegalArgumentException("Unsupported byte order setting: " 
+ value + ", expeced one of " + ByteOrder.LITTLE_ENDIAN + ", " +
-                LITTLE_ENDIAN + ", " + ByteOrder.BIG_ENDIAN + ", " + 
bigEndianUp);
-    }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.io;
+
+import java.nio.ByteOrder;
+import java.util.Locale;
+
+/**
+ * Converts Strings to {@link ByteOrder} instances.
+ *
+ * @since 2.6
+ */
+public class ByteOrderFactory {
+
+    private static final Locale ComparisonLocale = Locale.ROOT;
+
+    /**
+     * Big endian.
+     */
+    public static final String BIG_ENDIAN = "Big";
+
+    /**
+     * Little endian.
+     */
+    public static final String LITTLE_ENDIAN = "Little";
+
+    /**
+     * Parses the String argument as a {@link ByteOrder}, ignoring case.
+     * <p>
+     * Returns {@code ByteOrder.LITTLE_ENDIAN} if the given value is {@code 
"little"} or {@code "LITTLE_ENDIAN"}.
+     * </p>
+     * <p>
+     * Returns {@code ByteOrder.BIG_ENDIAN} if the given value is {@code 
"big"} or {@code "BIG_ENDIAN"}.
+     * </p>
+     * Examples:
+     * <ul>
+     * <li>{@code ByteOrderFactory.parseByteOrder("little")} returns {@code 
ByteOrder.LITTLE_ENDIAN}</li>
+     * <li>{@code ByteOrderFactory.parseByteOrder("big")} returns {@code 
ByteOrder.BIG_ENDIAN}</li>
+     * </ul>
+     * 
+     * @param value
+     *            the {@code String} containing the ByteOrder representation 
to be parsed
+     * @return the ByteOrder represented by the string argument
+     * @throws IllegalArgumentException
+     *             if the {@code String} containing the ByteOrder 
representation to be parsed is unknown.
+     */
+    public static ByteOrder parseByteOrder(final String value) {
+        final String valueUp = value.toUpperCase(ComparisonLocale);
+        final String bigEndianUp = BIG_ENDIAN.toUpperCase(ComparisonLocale);
+        final String littleEndianUp = 
LITTLE_ENDIAN.toUpperCase(ComparisonLocale);
+        if (bigEndianUp.equals(valueUp) || 
ByteOrder.BIG_ENDIAN.toString().equals(valueUp)) {
+            return ByteOrder.BIG_ENDIAN;
+        }
+        if (littleEndianUp.equals(valueUp) || 
ByteOrder.LITTLE_ENDIAN.toString().equals(valueUp)) {
+            return ByteOrder.LITTLE_ENDIAN;
+        }
+        throw new IllegalArgumentException("Unsupported byte order setting: " 
+ value + ", expeced one of " + ByteOrder.LITTLE_ENDIAN + ", " +
+                LITTLE_ENDIAN + ", " + ByteOrder.BIG_ENDIAN + ", " + 
bigEndianUp);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/commons-io/blob/9e2b2c09/src/main/java/org/apache/commons/io/Charsets.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/io/Charsets.java 
b/src/main/java/org/apache/commons/io/Charsets.java
index b9279df..b1105c2 100644
--- a/src/main/java/org/apache/commons/io/Charsets.java
+++ b/src/main/java/org/apache/commons/io/Charsets.java
@@ -1,192 +1,192 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.io;
-
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-import java.util.Collections;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-/**
- * Charsets required of every implementation of the Java platform.
- * 
- * From the Java documentation <a 
href="https://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html";>
- * Standard charsets</a>:
- * <p>
- * <cite>Every implementation of the Java platform is required to support the 
following character encodings. Consult
- * the release documentation for your implementation to see if any other 
encodings are supported. Consult the release
- * documentation for your implementation to see if any other encodings are 
supported. </cite>
- * </p>
- * 
- * <ul>
- * <li><code>US-ASCII</code><br>
- * Seven-bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the 
Unicode character set.</li>
- * <li><code>ISO-8859-1</code><br>
- * ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1.</li>
- * <li><code>UTF-8</code><br>
- * Eight-bit Unicode Transformation Format.</li>
- * <li><code>UTF-16BE</code><br>
- * Sixteen-bit Unicode Transformation Format, big-endian byte order.</li>
- * <li><code>UTF-16LE</code><br>
- * Sixteen-bit Unicode Transformation Format, little-endian byte order.</li>
- * <li><code>UTF-16</code><br>
- * Sixteen-bit Unicode Transformation Format, byte order specified by a 
mandatory initial byte-order mark (either order
- * accepted on input, big-endian used on output.)</li>
- * </ul>
- * 
- * @see <a 
href="https://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html";>Standard
 charsets</a>
- * @since 2.3
- * @version $Id$
- */
-public class Charsets {
-    //
-    // This class should only contain Charset instances for required 
encodings. This guarantees that it will load
-    // correctly and without delay on all Java platforms.
-    //
-
-    /**
-     * Constructs a sorted map from canonical charset names to charset objects 
required of every implementation of the
-     * Java platform.
-     * <p>
-     * From the Java documentation <a 
href="https://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html";>
-     * Standard charsets</a>:
-     * </p>
-     * 
-     * @return An immutable, case-insensitive map from canonical charset names 
to charset objects.
-     * @see Charset#availableCharsets()
-     * @since 2.5
-     */
-    public static SortedMap<String, Charset> requiredCharsets() {
-        // maybe cache?
-        final TreeMap<String, Charset> m = new 
TreeMap<>(String.CASE_INSENSITIVE_ORDER);
-        m.put(StandardCharsets.ISO_8859_1.name(), StandardCharsets.ISO_8859_1);
-        m.put(StandardCharsets.US_ASCII.name(), StandardCharsets.US_ASCII);
-        m.put(StandardCharsets.UTF_16.name(), StandardCharsets.UTF_16);
-        m.put(StandardCharsets.UTF_16BE.name(), StandardCharsets.UTF_16BE);
-        m.put(StandardCharsets.UTF_16LE.name(), StandardCharsets.UTF_16LE);
-        m.put(StandardCharsets.UTF_8.name(), StandardCharsets.UTF_8);
-        return Collections.unmodifiableSortedMap(m);
-    }
-
-    /**
-     * Returns the given Charset or the default Charset if the given Charset 
is null.
-     * 
-     * @param charset
-     *            A charset or null.
-     * @return the given Charset or the default Charset if the given Charset 
is null
-     */
-    public static Charset toCharset(final Charset charset) {
-        return charset == null ? Charset.defaultCharset() : charset;
-    }
-
-    /**
-     * Returns a Charset for the named charset. If the name is null, return 
the default Charset.
-     * 
-     * @param charset
-     *            The name of the requested charset, may be null.
-     * @return a Charset for the named charset
-     * @throws java.nio.charset.UnsupportedCharsetException
-     *             If the named charset is unavailable
-     */
-    public static Charset toCharset(final String charset) {
-        return charset == null ? Charset.defaultCharset() : 
Charset.forName(charset);
-    }
-
-    /**
-     * CharEncodingISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1.
-     * <p>
-     * Every implementation of the Java platform is required to support this 
character encoding.
-     * </p>
-     * 
-     * @see <a 
href="https://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html";>Standard
 charsets</a>
-     * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
-     */
-    @Deprecated
-    public static final Charset ISO_8859_1 = StandardCharsets.ISO_8859_1;
-
-    /**
-     * <p>
-     * Seven-bit ASCII, also known as ISO646-US, also known as the Basic Latin 
block of the Unicode character set.
-     * </p>
-     * <p>
-     * Every implementation of the Java platform is required to support this 
character encoding.
-     * </p>
-     * 
-     * @see <a 
href="https://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html";>Standard
 charsets</a>
-     * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
-     */
-    @Deprecated
-    public static final Charset US_ASCII = StandardCharsets.US_ASCII;
-
-    /**
-     * <p>
-     * Sixteen-bit Unicode Transformation Format, The byte order specified by 
a mandatory initial byte-order mark
-     * (either order accepted on input, big-endian used on output)
-     * </p>
-     * <p>
-     * Every implementation of the Java platform is required to support this 
character encoding.
-     * </p>
-     * 
-     * @see <a 
href="https://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html";>Standard
 charsets</a>
-     * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
-     */
-    @Deprecated
-    public static final Charset UTF_16 = StandardCharsets.UTF_16;
-
-    /**
-     * <p>
-     * Sixteen-bit Unicode Transformation Format, big-endian byte order.
-     * </p>
-     * <p>
-     * Every implementation of the Java platform is required to support this 
character encoding.
-     * </p>
-     * 
-     * @see <a 
href="https://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html";>Standard
 charsets</a>
-     * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
-     */
-    @Deprecated
-    public static final Charset UTF_16BE = StandardCharsets.UTF_16BE;
-
-    /**
-     * <p>
-     * Sixteen-bit Unicode Transformation Format, little-endian byte order.
-     * </p>
-     * <p>
-     * Every implementation of the Java platform is required to support this 
character encoding.
-     * </p>
-     * 
-     * @see <a 
href="https://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html";>Standard
 charsets</a>
-     * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
-     */
-    @Deprecated
-    public static final Charset UTF_16LE = StandardCharsets.UTF_16LE;
-
-    /**
-     * <p>
-     * Eight-bit Unicode Transformation Format.
-     * </p>
-     * <p>
-     * Every implementation of the Java platform is required to support this 
character encoding.
-     * </p>
-     * 
-     * @see <a 
href="https://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html";>Standard
 charsets</a>
-     * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
-     */
-    @Deprecated
-    public static final Charset UTF_8 = StandardCharsets.UTF_8;
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.io;
+
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.util.Collections;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+/**
+ * Charsets required of every implementation of the Java platform.
+ * 
+ * From the Java documentation <a 
href="https://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html";>
+ * Standard charsets</a>:
+ * <p>
+ * <cite>Every implementation of the Java platform is required to support the 
following character encodings. Consult
+ * the release documentation for your implementation to see if any other 
encodings are supported. Consult the release
+ * documentation for your implementation to see if any other encodings are 
supported. </cite>
+ * </p>
+ * 
+ * <ul>
+ * <li><code>US-ASCII</code><br>
+ * Seven-bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the 
Unicode character set.</li>
+ * <li><code>ISO-8859-1</code><br>
+ * ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1.</li>
+ * <li><code>UTF-8</code><br>
+ * Eight-bit Unicode Transformation Format.</li>
+ * <li><code>UTF-16BE</code><br>
+ * Sixteen-bit Unicode Transformation Format, big-endian byte order.</li>
+ * <li><code>UTF-16LE</code><br>
+ * Sixteen-bit Unicode Transformation Format, little-endian byte order.</li>
+ * <li><code>UTF-16</code><br>
+ * Sixteen-bit Unicode Transformation Format, byte order specified by a 
mandatory initial byte-order mark (either order
+ * accepted on input, big-endian used on output.)</li>
+ * </ul>
+ * 
+ * @see <a 
href="https://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html";>Standard
 charsets</a>
+ * @since 2.3
+ * @version $Id$
+ */
+public class Charsets {
+    //
+    // This class should only contain Charset instances for required 
encodings. This guarantees that it will load
+    // correctly and without delay on all Java platforms.
+    //
+
+    /**
+     * Constructs a sorted map from canonical charset names to charset objects 
required of every implementation of the
+     * Java platform.
+     * <p>
+     * From the Java documentation <a 
href="https://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html";>
+     * Standard charsets</a>:
+     * </p>
+     * 
+     * @return An immutable, case-insensitive map from canonical charset names 
to charset objects.
+     * @see Charset#availableCharsets()
+     * @since 2.5
+     */
+    public static SortedMap<String, Charset> requiredCharsets() {
+        // maybe cache?
+        final TreeMap<String, Charset> m = new 
TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+        m.put(StandardCharsets.ISO_8859_1.name(), StandardCharsets.ISO_8859_1);
+        m.put(StandardCharsets.US_ASCII.name(), StandardCharsets.US_ASCII);
+        m.put(StandardCharsets.UTF_16.name(), StandardCharsets.UTF_16);
+        m.put(StandardCharsets.UTF_16BE.name(), StandardCharsets.UTF_16BE);
+        m.put(StandardCharsets.UTF_16LE.name(), StandardCharsets.UTF_16LE);
+        m.put(StandardCharsets.UTF_8.name(), StandardCharsets.UTF_8);
+        return Collections.unmodifiableSortedMap(m);
+    }
+
+    /**
+     * Returns the given Charset or the default Charset if the given Charset 
is null.
+     * 
+     * @param charset
+     *            A charset or null.
+     * @return the given Charset or the default Charset if the given Charset 
is null
+     */
+    public static Charset toCharset(final Charset charset) {
+        return charset == null ? Charset.defaultCharset() : charset;
+    }
+
+    /**
+     * Returns a Charset for the named charset. If the name is null, return 
the default Charset.
+     * 
+     * @param charset
+     *            The name of the requested charset, may be null.
+     * @return a Charset for the named charset
+     * @throws java.nio.charset.UnsupportedCharsetException
+     *             If the named charset is unavailable
+     */
+    public static Charset toCharset(final String charset) {
+        return charset == null ? Charset.defaultCharset() : 
Charset.forName(charset);
+    }
+
+    /**
+     * CharEncodingISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1.
+     * <p>
+     * Every implementation of the Java platform is required to support this 
character encoding.
+     * </p>
+     * 
+     * @see <a 
href="https://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html";>Standard
 charsets</a>
+     * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
+     */
+    @Deprecated
+    public static final Charset ISO_8859_1 = StandardCharsets.ISO_8859_1;
+
+    /**
+     * <p>
+     * Seven-bit ASCII, also known as ISO646-US, also known as the Basic Latin 
block of the Unicode character set.
+     * </p>
+     * <p>
+     * Every implementation of the Java platform is required to support this 
character encoding.
+     * </p>
+     * 
+     * @see <a 
href="https://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html";>Standard
 charsets</a>
+     * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
+     */
+    @Deprecated
+    public static final Charset US_ASCII = StandardCharsets.US_ASCII;
+
+    /**
+     * <p>
+     * Sixteen-bit Unicode Transformation Format, The byte order specified by 
a mandatory initial byte-order mark
+     * (either order accepted on input, big-endian used on output)
+     * </p>
+     * <p>
+     * Every implementation of the Java platform is required to support this 
character encoding.
+     * </p>
+     * 
+     * @see <a 
href="https://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html";>Standard
 charsets</a>
+     * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
+     */
+    @Deprecated
+    public static final Charset UTF_16 = StandardCharsets.UTF_16;
+
+    /**
+     * <p>
+     * Sixteen-bit Unicode Transformation Format, big-endian byte order.
+     * </p>
+     * <p>
+     * Every implementation of the Java platform is required to support this 
character encoding.
+     * </p>
+     * 
+     * @see <a 
href="https://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html";>Standard
 charsets</a>
+     * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
+     */
+    @Deprecated
+    public static final Charset UTF_16BE = StandardCharsets.UTF_16BE;
+
+    /**
+     * <p>
+     * Sixteen-bit Unicode Transformation Format, little-endian byte order.
+     * </p>
+     * <p>
+     * Every implementation of the Java platform is required to support this 
character encoding.
+     * </p>
+     * 
+     * @see <a 
href="https://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html";>Standard
 charsets</a>
+     * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
+     */
+    @Deprecated
+    public static final Charset UTF_16LE = StandardCharsets.UTF_16LE;
+
+    /**
+     * <p>
+     * Eight-bit Unicode Transformation Format.
+     * </p>
+     * <p>
+     * Every implementation of the Java platform is required to support this 
character encoding.
+     * </p>
+     * 
+     * @see <a 
href="https://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html";>Standard
 charsets</a>
+     * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets}
+     */
+    @Deprecated
+    public static final Charset UTF_8 = StandardCharsets.UTF_8;
+}

http://git-wip-us.apache.org/repos/asf/commons-io/blob/9e2b2c09/src/main/java/org/apache/commons/io/input/MessageDigestCalculatingInputStream.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/commons/io/input/MessageDigestCalculatingInputStream.java
 
b/src/main/java/org/apache/commons/io/input/MessageDigestCalculatingInputStream.java
index b12e53a..cfb345d 100644
--- 
a/src/main/java/org/apache/commons/io/input/MessageDigestCalculatingInputStream.java
+++ 
b/src/main/java/org/apache/commons/io/input/MessageDigestCalculatingInputStream.java
@@ -1,84 +1,84 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.io.input;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-
-
-/**
- * This class is an example for using an {@link ObservableInputStream}. It
- * creates its own {@link Observer}, which calculates a checksum using a
- * MessageDigest, for example an MD5 sum.
- * {@em Note}: Neither {@link ObservableInputStream}, nor {@link 
MessageDigest},
- * are thread safe. So is {@link MessageDigestCalculatingInputStream}.
- */
-public class MessageDigestCalculatingInputStream extends ObservableInputStream 
{
-    public static class MessageDigestMaintainingObserver extends Observer {
-        private final MessageDigest md;
-
-        public MessageDigestMaintainingObserver(MessageDigest pMd) {
-            md = pMd;
-        }
-
-        @Override
-        void data(int pByte) throws IOException {
-            md.update((byte) pByte);
-        }
-
-        @Override
-        void data(byte[] pBuffer, int pOffset, int pLength) throws IOException 
{
-            md.update(pBuffer, pOffset, pLength);
-        }
-    }
-
-    private final MessageDigest messageDigest;
-
-    /** Creates a new instance, which calculates a signature on the given 
stream,
-     * using the given {@link MessageDigest}.
-     */
-    public MessageDigestCalculatingInputStream(InputStream pStream, 
MessageDigest pDigest) {
-        super(pStream);
-        messageDigest = pDigest;
-        add(new MessageDigestMaintainingObserver(pDigest));
-    }
-    /** Creates a new instance, which calculates a signature on the given 
stream,
-     * using a {@link MessageDigest} with the given algorithm.
-     */
-    public MessageDigestCalculatingInputStream(InputStream pStream, String 
pAlgorithm) throws NoSuchAlgorithmException {
-        this(pStream, MessageDigest.getInstance(pAlgorithm));
-    }
-    /** Creates a new instance, which calculates a signature on the given 
stream,
-     * using a {@link MessageDigest} with the "MD5" algorithm.
-     */
-    public MessageDigestCalculatingInputStream(InputStream pStream) throws 
NoSuchAlgorithmException {
-        this(pStream, MessageDigest.getInstance("MD5"));
-    }
-
-    /** Returns the {@link MessageDigest}, which is being used for generating 
the
-     * checksum.
-     * {@em Note}: The checksum will only reflect the data, which has been 
read so far.
-     * This is probably not, what you expect. Make sure, that the complete 
data has been
-     * read, if that is what you want. The easiest way to do so is by invoking
-     * {@link #consume()}.
-     */
-    public MessageDigest getMessageDigest() {
-        return messageDigest;
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.io.input;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+
+/**
+ * This class is an example for using an {@link ObservableInputStream}. It
+ * creates its own {@link Observer}, which calculates a checksum using a
+ * MessageDigest, for example an MD5 sum.
+ * {@em Note}: Neither {@link ObservableInputStream}, nor {@link 
MessageDigest},
+ * are thread safe. So is {@link MessageDigestCalculatingInputStream}.
+ */
+public class MessageDigestCalculatingInputStream extends ObservableInputStream 
{
+    public static class MessageDigestMaintainingObserver extends Observer {
+        private final MessageDigest md;
+
+        public MessageDigestMaintainingObserver(MessageDigest pMd) {
+            md = pMd;
+        }
+
+        @Override
+        void data(int pByte) throws IOException {
+            md.update((byte) pByte);
+        }
+
+        @Override
+        void data(byte[] pBuffer, int pOffset, int pLength) throws IOException 
{
+            md.update(pBuffer, pOffset, pLength);
+        }
+    }
+
+    private final MessageDigest messageDigest;
+
+    /** Creates a new instance, which calculates a signature on the given 
stream,
+     * using the given {@link MessageDigest}.
+     */
+    public MessageDigestCalculatingInputStream(InputStream pStream, 
MessageDigest pDigest) {
+        super(pStream);
+        messageDigest = pDigest;
+        add(new MessageDigestMaintainingObserver(pDigest));
+    }
+    /** Creates a new instance, which calculates a signature on the given 
stream,
+     * using a {@link MessageDigest} with the given algorithm.
+     */
+    public MessageDigestCalculatingInputStream(InputStream pStream, String 
pAlgorithm) throws NoSuchAlgorithmException {
+        this(pStream, MessageDigest.getInstance(pAlgorithm));
+    }
+    /** Creates a new instance, which calculates a signature on the given 
stream,
+     * using a {@link MessageDigest} with the "MD5" algorithm.
+     */
+    public MessageDigestCalculatingInputStream(InputStream pStream) throws 
NoSuchAlgorithmException {
+        this(pStream, MessageDigest.getInstance("MD5"));
+    }
+
+    /** Returns the {@link MessageDigest}, which is being used for generating 
the
+     * checksum.
+     * {@em Note}: The checksum will only reflect the data, which has been 
read so far.
+     * This is probably not, what you expect. Make sure, that the complete 
data has been
+     * read, if that is what you want. The easiest way to do so is by invoking
+     * {@link #consume()}.
+     */
+    public MessageDigest getMessageDigest() {
+        return messageDigest;
+    }
+}

http://git-wip-us.apache.org/repos/asf/commons-io/blob/9e2b2c09/src/test/java/org/apache/commons/io/ByteOrderFactoryTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/io/ByteOrderFactoryTest.java 
b/src/test/java/org/apache/commons/io/ByteOrderFactoryTest.java
index 42eae02..bf17a09 100644
--- a/src/test/java/org/apache/commons/io/ByteOrderFactoryTest.java
+++ b/src/test/java/org/apache/commons/io/ByteOrderFactoryTest.java
@@ -1,43 +1,43 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.io;
-
-import java.nio.ByteOrder;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class ByteOrderFactoryTest {
-
-    private ByteOrder parseByteOrder(final String value) {
-        return ByteOrderFactory.parseByteOrder(value);
-    }
-
-    @Test
-    public void testParseBig() {
-        Assert.assertEquals(ByteOrder.BIG_ENDIAN, parseByteOrder("big"));
-        Assert.assertEquals(ByteOrder.BIG_ENDIAN, parseByteOrder("Big"));
-        Assert.assertEquals(ByteOrder.BIG_ENDIAN, parseByteOrder("BIG"));
-    }
-
-    @Test
-    public void testParseLittle() {
-        Assert.assertEquals(ByteOrder.LITTLE_ENDIAN, parseByteOrder("little"));
-        Assert.assertEquals(ByteOrder.LITTLE_ENDIAN, parseByteOrder("Little"));
-        Assert.assertEquals(ByteOrder.LITTLE_ENDIAN, parseByteOrder("LITTLE"));
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.io;
+
+import java.nio.ByteOrder;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ByteOrderFactoryTest {
+
+    private ByteOrder parseByteOrder(final String value) {
+        return ByteOrderFactory.parseByteOrder(value);
+    }
+
+    @Test
+    public void testParseBig() {
+        Assert.assertEquals(ByteOrder.BIG_ENDIAN, parseByteOrder("big"));
+        Assert.assertEquals(ByteOrder.BIG_ENDIAN, parseByteOrder("Big"));
+        Assert.assertEquals(ByteOrder.BIG_ENDIAN, parseByteOrder("BIG"));
+    }
+
+    @Test
+    public void testParseLittle() {
+        Assert.assertEquals(ByteOrder.LITTLE_ENDIAN, parseByteOrder("little"));
+        Assert.assertEquals(ByteOrder.LITTLE_ENDIAN, parseByteOrder("Little"));
+        Assert.assertEquals(ByteOrder.LITTLE_ENDIAN, parseByteOrder("LITTLE"));
+    }
+}

http://git-wip-us.apache.org/repos/asf/commons-io/blob/9e2b2c09/src/test/java/org/apache/commons/io/CharsetsTestCase.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/io/CharsetsTestCase.java 
b/src/test/java/org/apache/commons/io/CharsetsTestCase.java
index 9f50dd0..fc3a90e 100644
--- a/src/test/java/org/apache/commons/io/CharsetsTestCase.java
+++ b/src/test/java/org/apache/commons/io/CharsetsTestCase.java
@@ -1,90 +1,90 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.commons.io;
-
-import java.nio.charset.Charset;
-import java.util.SortedMap;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * Tests {@link Charsets}.
- * 
- * @version $Id: CharEncodingTest.java 1298985 2012-03-09 19:12:49Z ggregory $
- */
-public class CharsetsTestCase {
-
-    @Test
-    public void testRequiredCharsets() {
-        final SortedMap<String, Charset> requiredCharsets = 
Charsets.requiredCharsets();
-        // test for what we expect to be there as of Java 6
-        // Make sure the object at the given key is the right one
-        Assert.assertEquals(requiredCharsets.get("US-ASCII").name(), 
"US-ASCII");
-        Assert.assertEquals(requiredCharsets.get("ISO-8859-1").name(), 
"ISO-8859-1");
-        Assert.assertEquals(requiredCharsets.get("UTF-8").name(), "UTF-8");
-        Assert.assertEquals(requiredCharsets.get("UTF-16").name(), "UTF-16");
-        Assert.assertEquals(requiredCharsets.get("UTF-16BE").name(), 
"UTF-16BE");
-        Assert.assertEquals(requiredCharsets.get("UTF-16LE").name(), 
"UTF-16LE");
-    }
-
-    @Test
-    @SuppressWarnings("deprecation") // unavoidable until Java 7
-    public void testIso8859_1() {
-        Assert.assertEquals("ISO-8859-1", Charsets.ISO_8859_1.name());
-    }
-
-    @Test
-    public void testToCharset() {
-        Assert.assertEquals(Charset.defaultCharset(), 
Charsets.toCharset((String) null));
-        Assert.assertEquals(Charset.defaultCharset(), 
Charsets.toCharset((Charset) null));
-        Assert.assertEquals(Charset.defaultCharset(), 
Charsets.toCharset(Charset.defaultCharset()));
-        Assert.assertEquals(Charset.forName("UTF-8"), 
Charsets.toCharset(Charset.forName("UTF-8")));
-    }
-
-    @Test
-    @SuppressWarnings("deprecation") // unavoidable until Java 7
-    public void testUsAscii() {
-        Assert.assertEquals("US-ASCII", Charsets.US_ASCII.name());
-    }
-
-    @Test
-    @SuppressWarnings("deprecation") // unavoidable until Java 7
-    public void testUtf16() {
-        Assert.assertEquals("UTF-16", Charsets.UTF_16.name());
-    }
-
-    @Test
-    @SuppressWarnings("deprecation") // unavoidable until Java 7
-    public void testUtf16Be() {
-        Assert.assertEquals("UTF-16BE", Charsets.UTF_16BE.name());
-    }
-
-    @Test
-    @SuppressWarnings("deprecation") // unavoidable until Java 7
-    public void testUtf16Le() {
-        Assert.assertEquals("UTF-16LE", Charsets.UTF_16LE.name());
-    }
-
-    @Test
-    @SuppressWarnings("deprecation") // unavoidable until Java 7
-    public void testUtf8() {
-        Assert.assertEquals("UTF-8", Charsets.UTF_8.name());
-    }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.io;
+
+import java.nio.charset.Charset;
+import java.util.SortedMap;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Tests {@link Charsets}.
+ * 
+ * @version $Id: CharEncodingTest.java 1298985 2012-03-09 19:12:49Z ggregory $
+ */
+public class CharsetsTestCase {
+
+    @Test
+    public void testRequiredCharsets() {
+        final SortedMap<String, Charset> requiredCharsets = 
Charsets.requiredCharsets();
+        // test for what we expect to be there as of Java 6
+        // Make sure the object at the given key is the right one
+        Assert.assertEquals(requiredCharsets.get("US-ASCII").name(), 
"US-ASCII");
+        Assert.assertEquals(requiredCharsets.get("ISO-8859-1").name(), 
"ISO-8859-1");
+        Assert.assertEquals(requiredCharsets.get("UTF-8").name(), "UTF-8");
+        Assert.assertEquals(requiredCharsets.get("UTF-16").name(), "UTF-16");
+        Assert.assertEquals(requiredCharsets.get("UTF-16BE").name(), 
"UTF-16BE");
+        Assert.assertEquals(requiredCharsets.get("UTF-16LE").name(), 
"UTF-16LE");
+    }
+
+    @Test
+    @SuppressWarnings("deprecation") // unavoidable until Java 7
+    public void testIso8859_1() {
+        Assert.assertEquals("ISO-8859-1", Charsets.ISO_8859_1.name());
+    }
+
+    @Test
+    public void testToCharset() {
+        Assert.assertEquals(Charset.defaultCharset(), 
Charsets.toCharset((String) null));
+        Assert.assertEquals(Charset.defaultCharset(), 
Charsets.toCharset((Charset) null));
+        Assert.assertEquals(Charset.defaultCharset(), 
Charsets.toCharset(Charset.defaultCharset()));
+        Assert.assertEquals(Charset.forName("UTF-8"), 
Charsets.toCharset(Charset.forName("UTF-8")));
+    }
+
+    @Test
+    @SuppressWarnings("deprecation") // unavoidable until Java 7
+    public void testUsAscii() {
+        Assert.assertEquals("US-ASCII", Charsets.US_ASCII.name());
+    }
+
+    @Test
+    @SuppressWarnings("deprecation") // unavoidable until Java 7
+    public void testUtf16() {
+        Assert.assertEquals("UTF-16", Charsets.UTF_16.name());
+    }
+
+    @Test
+    @SuppressWarnings("deprecation") // unavoidable until Java 7
+    public void testUtf16Be() {
+        Assert.assertEquals("UTF-16BE", Charsets.UTF_16BE.name());
+    }
+
+    @Test
+    @SuppressWarnings("deprecation") // unavoidable until Java 7
+    public void testUtf16Le() {
+        Assert.assertEquals("UTF-16LE", Charsets.UTF_16LE.name());
+    }
+
+    @Test
+    @SuppressWarnings("deprecation") // unavoidable until Java 7
+    public void testUtf8() {
+        Assert.assertEquals("UTF-8", Charsets.UTF_8.name());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/commons-io/blob/9e2b2c09/src/test/java/org/apache/commons/io/input/MessageDigestCalculatingInputStreamTest.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/commons/io/input/MessageDigestCalculatingInputStreamTest.java
 
b/src/test/java/org/apache/commons/io/input/MessageDigestCalculatingInputStreamTest.java
index 4162d21..420b5d9 100644
--- 
a/src/test/java/org/apache/commons/io/input/MessageDigestCalculatingInputStreamTest.java
+++ 
b/src/test/java/org/apache/commons/io/input/MessageDigestCalculatingInputStreamTest.java
@@ -1,48 +1,48 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.io.input;
-
-import static org.junit.Assert.*;
-
-import java.io.ByteArrayInputStream;
-import java.security.MessageDigest;
-import java.util.Random;
-
-import org.junit.Test;
-
-public class MessageDigestCalculatingInputStreamTest {
-    public static byte[] generateRandomByteStream(int pSize) {
-        final byte[] buffer = new byte[pSize];
-        final Random rnd = new Random();
-        rnd.nextBytes(buffer);
-        return buffer;
-    }
-
-    @Test
-    public void test() throws Exception {
-        for (int i = 256;  i < 8192;  i = i*2) {
-            final byte[] buffer = generateRandomByteStream(i);
-            final MessageDigest md5Sum = MessageDigest.getInstance("MD5");
-            final byte[] expect = md5Sum.digest(buffer);
-            final MessageDigestCalculatingInputStream md5InputStream = new 
MessageDigestCalculatingInputStream(new ByteArrayInputStream(buffer));
-            md5InputStream.consume();
-            final byte[] got = md5InputStream.getMessageDigest().digest();
-            assertArrayEquals(expect, got);
-        }
-    }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.io.input;
+
+import static org.junit.Assert.*;
+
+import java.io.ByteArrayInputStream;
+import java.security.MessageDigest;
+import java.util.Random;
+
+import org.junit.Test;
+
+public class MessageDigestCalculatingInputStreamTest {
+    public static byte[] generateRandomByteStream(int pSize) {
+        final byte[] buffer = new byte[pSize];
+        final Random rnd = new Random();
+        rnd.nextBytes(buffer);
+        return buffer;
+    }
+
+    @Test
+    public void test() throws Exception {
+        for (int i = 256;  i < 8192;  i = i*2) {
+            final byte[] buffer = generateRandomByteStream(i);
+            final MessageDigest md5Sum = MessageDigest.getInstance("MD5");
+            final byte[] expect = md5Sum.digest(buffer);
+            final MessageDigestCalculatingInputStream md5InputStream = new 
MessageDigestCalculatingInputStream(new ByteArrayInputStream(buffer));
+            md5InputStream.consume();
+            final byte[] got = md5InputStream.getMessageDigest().digest();
+            assertArrayEquals(expect, got);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/commons-io/blob/9e2b2c09/src/test/java/org/apache/commons/io/input/ObservableInputStreamTest.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/commons/io/input/ObservableInputStreamTest.java 
b/src/test/java/org/apache/commons/io/input/ObservableInputStreamTest.java
index d74af27..992e915 100644
--- a/src/test/java/org/apache/commons/io/input/ObservableInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/ObservableInputStreamTest.java
@@ -1,134 +1,134 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.commons.io.input;
-
-import static org.junit.Assert.*;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-
-import org.apache.commons.io.input.ObservableInputStream;
-import org.apache.commons.io.input.ObservableInputStream.Observer;
-import org.junit.Test;
-
-public class ObservableInputStreamTest {
-    private static class LastByteKeepingObserver extends Observer {
-        private int lastByteSeen = -1;
-        private boolean finished;
-        private boolean closed;
-
-        @Override
-        void data(int pByte) throws IOException {
-            super.data(pByte);
-            lastByteSeen = pByte;
-        }
-        
-        @Override
-        void finished() throws IOException {
-            super.finished();
-            finished = true;
-        }
-        
-        @Override
-        void closed() throws IOException {
-            super.closed();
-            closed = true;
-        }
-    }
-    private static class LastBytesKeepingObserver extends Observer {
-        private byte[] buffer = null;
-        private int offset = -1;
-        private int length = -1;
-
-        @Override
-        void data(byte[] pBuffer, int pOffset, int pLength) throws IOException 
{
-            super.data(pBuffer, pOffset, pLength);
-            buffer = pBuffer;
-            offset = pOffset;
-            length = pLength;
-        }
-    }
-
-    /** Tests, that {@link Observer#data(int)} is called.
-     */
-    @Test
-    public void testDataByteCalled() throws Exception {
-        final byte[] buffer = 
MessageDigestCalculatingInputStreamTest.generateRandomByteStream(4096);
-        final ObservableInputStream ois = new ObservableInputStream(new 
ByteArrayInputStream(buffer));
-        final LastByteKeepingObserver lko = new LastByteKeepingObserver();
-        assertEquals(-1, lko.lastByteSeen);
-        ois.read();
-        assertEquals(-1, lko.lastByteSeen);
-        assertFalse(lko.finished);
-        assertFalse(lko.closed);
-        ois.add(lko);
-        for (int i = 1;  i < buffer.length;  i++) {
-            final int result = ois.read();
-            assertEquals((byte) result, buffer[i]);
-            assertEquals(result, lko.lastByteSeen);
-            assertFalse(lko.finished);
-            assertFalse(lko.closed);
-        }
-        final int result = ois.read();
-        assertEquals(-1, result);
-        assertTrue(lko.finished);
-        assertFalse(lko.closed);
-        ois.close();
-        assertTrue(lko.finished);
-        assertTrue(lko.closed);
-    }
-
-    /** Tests, that {@link Observer#data(byte[],int,int)} is called.
-     */
-    @Test
-    public void testDataBytesCalled() throws Exception {
-        final byte[] buffer = 
MessageDigestCalculatingInputStreamTest.generateRandomByteStream(4096);
-        ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
-        final ObservableInputStream ois = new ObservableInputStream(bais);
-        final LastBytesKeepingObserver lko = new LastBytesKeepingObserver();
-        final byte[] readBuffer = new byte[23];
-        assertEquals(null, lko.buffer);
-        ois.read(readBuffer);
-        assertEquals(null, lko.buffer);
-        ois.add(lko);
-        for (;;) {
-            if (bais.available() >= 2048) {
-                final int result = ois.read(readBuffer);
-                if (result == -1) {
-                    ois.close();
-                    break;
-                } else {
-                    assertEquals(readBuffer, lko.buffer);
-                    assertEquals(0, lko.offset);
-                    assertEquals(readBuffer.length, lko.length);
-                }
-            } else {
-                final int res = Math.min(11, bais.available());
-                final int result = ois.read(readBuffer, 1, 11);
-                if (result == -1) {
-                    ois.close();
-                    break;
-                } else {
-                    assertEquals(readBuffer, lko.buffer);
-                    assertEquals(1, lko.offset);
-                    assertEquals(res, lko.length);
-                }
-            }
-        }
-    }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.io.input;
+
+import static org.junit.Assert.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+
+import org.apache.commons.io.input.ObservableInputStream;
+import org.apache.commons.io.input.ObservableInputStream.Observer;
+import org.junit.Test;
+
+public class ObservableInputStreamTest {
+    private static class LastByteKeepingObserver extends Observer {
+        private int lastByteSeen = -1;
+        private boolean finished;
+        private boolean closed;
+
+        @Override
+        void data(int pByte) throws IOException {
+            super.data(pByte);
+            lastByteSeen = pByte;
+        }
+        
+        @Override
+        void finished() throws IOException {
+            super.finished();
+            finished = true;
+        }
+        
+        @Override
+        void closed() throws IOException {
+            super.closed();
+            closed = true;
+        }
+    }
+    private static class LastBytesKeepingObserver extends Observer {
+        private byte[] buffer = null;
+        private int offset = -1;
+        private int length = -1;
+
+        @Override
+        void data(byte[] pBuffer, int pOffset, int pLength) throws IOException 
{
+            super.data(pBuffer, pOffset, pLength);
+            buffer = pBuffer;
+            offset = pOffset;
+            length = pLength;
+        }
+    }
+
+    /** Tests, that {@link Observer#data(int)} is called.
+     */
+    @Test
+    public void testDataByteCalled() throws Exception {
+        final byte[] buffer = 
MessageDigestCalculatingInputStreamTest.generateRandomByteStream(4096);
+        final ObservableInputStream ois = new ObservableInputStream(new 
ByteArrayInputStream(buffer));
+        final LastByteKeepingObserver lko = new LastByteKeepingObserver();
+        assertEquals(-1, lko.lastByteSeen);
+        ois.read();
+        assertEquals(-1, lko.lastByteSeen);
+        assertFalse(lko.finished);
+        assertFalse(lko.closed);
+        ois.add(lko);
+        for (int i = 1;  i < buffer.length;  i++) {
+            final int result = ois.read();
+            assertEquals((byte) result, buffer[i]);
+            assertEquals(result, lko.lastByteSeen);
+            assertFalse(lko.finished);
+            assertFalse(lko.closed);
+        }
+        final int result = ois.read();
+        assertEquals(-1, result);
+        assertTrue(lko.finished);
+        assertFalse(lko.closed);
+        ois.close();
+        assertTrue(lko.finished);
+        assertTrue(lko.closed);
+    }
+
+    /** Tests, that {@link Observer#data(byte[],int,int)} is called.
+     */
+    @Test
+    public void testDataBytesCalled() throws Exception {
+        final byte[] buffer = 
MessageDigestCalculatingInputStreamTest.generateRandomByteStream(4096);
+        ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
+        final ObservableInputStream ois = new ObservableInputStream(bais);
+        final LastBytesKeepingObserver lko = new LastBytesKeepingObserver();
+        final byte[] readBuffer = new byte[23];
+        assertEquals(null, lko.buffer);
+        ois.read(readBuffer);
+        assertEquals(null, lko.buffer);
+        ois.add(lko);
+        for (;;) {
+            if (bais.available() >= 2048) {
+                final int result = ois.read(readBuffer);
+                if (result == -1) {
+                    ois.close();
+                    break;
+                } else {
+                    assertEquals(readBuffer, lko.buffer);
+                    assertEquals(0, lko.offset);
+                    assertEquals(readBuffer.length, lko.length);
+                }
+            } else {
+                final int res = Math.min(11, bais.available());
+                final int result = ois.read(readBuffer, 1, 11);
+                if (result == -1) {
+                    ois.close();
+                    break;
+                } else {
+                    assertEquals(readBuffer, lko.buffer);
+                    assertEquals(1, lko.offset);
+                    assertEquals(res, lko.length);
+                }
+            }
+        }
+    }
+
+}

Reply via email to