SELF
- the "self" type of this assertion class. Please read "Emulating 'self types' using Java Generics to simplify fluent API implementation"
for more details.ACTUAL
- the type of the "actual" value.public abstract class AbstractInputStreamAssert<SELF extends AbstractInputStreamAssert<SELF,ACTUAL>,ACTUAL extends InputStream> extends AbstractAssert<SELF,ACTUAL>
InputStream
s.actual, info, myself, throwUnsupportedExceptionOnEquals
Constructor and Description |
---|
AbstractInputStreamAssert(ACTUAL actual,
Class<?> selfType) |
Modifier and Type | Method and Description |
---|---|
SELF |
hasContent(String expected)
Verifies that the content of the actual
InputStream is equal to the given String . |
SELF |
hasContentEqualTo(InputStream expected)
Deprecated.
use
hasSameContentAs(InputStream) instead |
SELF |
hasDigest(MessageDigest digest,
byte[] expected)
Verifies that the tested
InputStream digest (calculated with the specified MessageDigest ) is equal to the given one. |
SELF |
hasDigest(MessageDigest digest,
String expected)
Verifies that the tested
InputStream digest (calculated with the specified MessageDigest ) is equal to the given one. |
SELF |
hasDigest(String algorithm,
byte[] expected)
Verifies that the tested
InputStream digest (calculated with the specified algorithm) is equal to the given one. |
SELF |
hasDigest(String algorithm,
String expected)
Verifies that the tested
InputStream digest (calculated with the specified algorithm) is equal to the given one. |
SELF |
hasSameContentAs(InputStream expected)
Verifies that the content of the actual
InputStream is equal to the content of the given one. |
as, as, asList, asString, describedAs, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, inBinary, inHexadecimal, is, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, setCustomRepresentation, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, withFailMessage, withRepresentation, withThreadDumpOnError
@Deprecated public SELF hasContentEqualTo(InputStream expected)
hasSameContentAs(InputStream)
insteadInputStream
is equal to the content of the given one.expected
- the given InputStream
to compare the actual InputStream
to.this
assertion object.NullPointerException
- if the given InputStream
is null
.AssertionError
- if the actual InputStream
is null
.AssertionError
- if the content of the actual InputStream
is not equal to the content of the given one.InputStreamsException
- if an I/O error occurs.public SELF hasSameContentAs(InputStream expected)
InputStream
is equal to the content of the given one.
Example:
// assertion will pass
assertThat(new ByteArrayInputStream(new byte[] {0xa})).hasSameContentAs(new ByteArrayInputStream(new byte[] {0xa}));
// assertions will fail
assertThat(new ByteArrayInputStream(new byte[] {0xa})).hasSameContentAs(new ByteArrayInputStream(new byte[] {}));
assertThat(new ByteArrayInputStream(new byte[] {0xa})).hasSameContentAs(new ByteArrayInputStream(new byte[] {0xa, 0xc, 0xd}));
expected
- the given InputStream
to compare the actual InputStream
to.this
assertion object.NullPointerException
- if the given InputStream
is null
.AssertionError
- if the actual InputStream
is null
.AssertionError
- if the content of the actual InputStream
is not equal to the content of the given one.InputStreamsException
- if an I/O error occurs.public SELF hasContent(String expected)
InputStream
is equal to the given String
.
Example:
// assertion will pass
assertThat(new ByteArrayInputStream("a".getBytes())).hasContent("a");
// assertions will fail
assertThat(new ByteArrayInputStream("a".getBytes())).hasContent("");
assertThat(new ByteArrayInputStream("a".getBytes())).hasContent("ab");
expected
- the given String
to compare the actual InputStream
to.this
assertion object.NullPointerException
- if the given String
is null
.AssertionError
- if the actual InputStream
is null
.AssertionError
- if the content of the actual InputStream
is not equal to the given String
.InputStreamsException
- if an I/O error occurs.public SELF hasDigest(MessageDigest digest, byte[] expected)
InputStream
digest (calculated with the specified MessageDigest
) is equal to the given one.
Examples:
// assume that assertj-core-2.9.0.jar was downloaded from https://repo1.maven.org/maven2/org/assertj/assertj-core/2.9.0/assertj-core-2.9.0.jar
InputStream tested = new FileInputStream(new File("assertj-core-2.9.0.jar"));
// The following assertions succeed:
assertThat(tested).hasDigest(MessageDigest.getInstance("SHA1"), new byte[]{92, 90, -28, 91, 88, -15, 32, 35, -127, 122, -66, 73, 36, 71, -51, -57, -111, 44, 26, 44});
assertThat(tested).hasDigest(MessageDigest.getInstance("MD5"), new byte[]{-36, -77, 1, 92, -46, -124, 71, 100, 76, -127, 10, -13, 82, -125, 44, 25});
// The following assertions fail:
assertThat(tested).hasDigest(MessageDigest.getInstance("SHA1"), "93b9ced2ee5b3f0f4c8e640e77470dab031d4cad".getBytes());
assertThat(tested).hasDigest(MessageDigest.getInstance("MD5"), "3735dff8e1f9df0492a34ef075205b8f".getBytes());
digest
- the MessageDigest used to calculate the digests.expected
- the expected binary content to compare the actual InputStream
's digest to.this
assertion object.NullPointerException
- if the given algorithm is null
.NullPointerException
- if the given digest is null
.AssertionError
- if the actual InputStream
is null
.AssertionError
- if the actual InputStream
is not readable.InputStreamsException
- if an I/O error occurs.AssertionError
- if the content of the tested InputStream
's digest is not equal to the given one.public SELF hasDigest(MessageDigest digest, String expected)
InputStream
digest (calculated with the specified MessageDigest
) is equal to the given one.
Examples:
// assume that assertj-core-2.9.0.jar was downloaded from https://repo1.maven.org/maven2/org/assertj/assertj-core/2.9.0/assertj-core-2.9.0.jar
InputStream tested = new FileInputStream(new File("assertj-core-2.9.0.jar"));
// The following assertions succeed:
assertThat(tested).hasDigest(MessageDigest.getInstance("SHA1"), "5c5ae45b58f12023817abe492447cdc7912c1a2c");
assertThat(tested).hasDigest(MessageDigest.getInstance("MD5"), "dcb3015cd28447644c810af352832c19");
// The following assertions fail:
assertThat(tested).hasDigest(MessageDigest.getInstance("SHA1"), "93b9ced2ee5b3f0f4c8e640e77470dab031d4cad");
assertThat(tested).hasDigest(MessageDigest.getInstance("MD5"), "3735dff8e1f9df0492a34ef075205b8f");
digest
- the MessageDigest used to calculate the digests.expected
- the expected binary content to compare the actual InputStream
's digest to.this
assertion object.NullPointerException
- if the given algorithm is null
.NullPointerException
- if the given digest is null
.AssertionError
- if the actual InputStream
is null
.AssertionError
- if the actual InputStream
is not readable.InputStreamsException
- if an I/O error occurs.AssertionError
- if the content of the tested InputStream
's digest is not equal to the given one.public SELF hasDigest(String algorithm, byte[] expected)
InputStream
digest (calculated with the specified algorithm) is equal to the given one.
Examples:
// assume that assertj-core-2.9.0.jar was downloaded from https://repo1.maven.org/maven2/org/assertj/assertj-core/2.9.0/assertj-core-2.9.0.jar
InputStream tested = new FileInputStream(new File("assertj-core-2.9.0.jar"));
// The following assertion succeeds:
assertThat(tested).hasDigest("SHA1", new byte[]{92, 90, -28, 91, 88, -15, 32, 35, -127, 122, -66, 73, 36, 71, -51, -57, -111, 44, 26, 44});
assertThat(tested).hasDigest("MD5", new byte[]{-36, -77, 1, 92, -46, -124, 71, 100, 76, -127, 10, -13, 82, -125, 44, 25});
// The following assertion fails:
assertThat(tested).hasDigest("SHA1", "93b9ced2ee5b3f0f4c8e640e77470dab031d4cad".getBytes());
assertThat(tested).hasDigest("MD5", "3735dff8e1f9df0492a34ef075205b8f".getBytes());
algorithm
- the algorithm used to calculate the digests.expected
- the expected binary content to compare the actual InputStream
's content to.this
assertion object.NullPointerException
- if the given algorithm is null
.NullPointerException
- if the given digest is null
.AssertionError
- if the actual InputStream
is null
.AssertionError
- if the actual InputStream
is not readable.InputStreamsException
- if an I/O error occurs.AssertionError
- if the content of the tested InputStream
's digest is not equal to the given one.public SELF hasDigest(String algorithm, String expected)
InputStream
digest (calculated with the specified algorithm) is equal to the given one.
Examples:
// assume that assertj-core-2.9.0.jar was downloaded from https://repo1.maven.org/maven2/org/assertj/assertj-core/2.9.0/assertj-core-2.9.0.jar
InputStream tested = new FileInputStream(new File("assertj-core-2.9.0.jar"));
// The following assertion succeeds:
assertThat(tested).hasDigest("SHA1", "5c5ae45b58f12023817abe492447cdc7912c1a2c");
assertThat(tested).hasDigest("MD5", "dcb3015cd28447644c810af352832c19");
// The following assertion fails:
assertThat(tested).hasDigest("SHA1", "93b9ced2ee5b3f0f4c8e640e77470dab031d4cad");
assertThat(tested).hasDigest("MD5", "3735dff8e1f9df0492a34ef075205b8f");
algorithm
- the algorithm used to calculate the digests.expected
- the expected binary content to compare the actual InputStream
's content to.this
assertion object.NullPointerException
- if the given algorithm is null
.NullPointerException
- if the given digest is null
.AssertionError
- if the actual InputStream
is null
.AssertionError
- if the actual InputStream
is not readable.InputStreamsException
- if an I/O error occurs.AssertionError
- if the content of the tested InputStream
's digest is not equal to the given one.Copyright © 2014–2019 AssertJ. All rights reserved.