001 package org.fest.assertions.api;
002
003 import java.io.InputStream;
004
005 import org.fest.assertions.internal.InputStreams;
006 import org.fest.assertions.internal.InputStreamsException;
007 import org.fest.util.VisibleForTesting;
008
009 /**
010 * Assertion methods for <code>{@link InputStream}</code>s.
011 * <p>
012 * To create a new instance of this class, invoke <code>{@link Assertions#assertThat(InputStream)}</code>.
013 * </p>
014 * @author Matthieu Baechler
015 */
016 public class InputStreamAssert extends AbstractAssert<InputStreamAssert, InputStream> {
017
018 @VisibleForTesting
019 InputStreams inputStreams = InputStreams.instance();
020
021 public InputStreamAssert(InputStream actual) {
022 super(actual, InputStreamAssert.class);
023 }
024
025 /**
026 * Verifies that the content of the actual {@code InputStream} is equal to the content of the given one.
027 *
028 * @param expected the given {@code InputStream} to compare the actual {@code InputStream} to.
029 * @return {@code this} assertion object.
030 * @throws NullPointerException if the given {@code InputStream} is {@code null}.
031 * @throws AssertionError if the actual {@code InputStream} is {@code null}.
032 * @throws AssertionError if the content of the actual {@code InputStream} is not equal to the content of the given
033 * one.
034 * @throws InputStreamsException if an I/O error occurs.
035 */
036 public InputStreamAssert hasContentEqualTo(InputStream expected) {
037 inputStreams.assertEqualContent(info, actual, expected);
038 return this;
039 }
040
041 }