|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.hamcrest.BaseMatcher<T> org.hamcrest.TypeSafeDiagnosingMatcher<T> de.smartics.util.test.matcher.io.AbstractEqualContentAs<InputStream> de.smartics.util.test.matcher.io.StreamsEqualContentAs
public class StreamsEqualContentAs
A matcher to check that the contents of two stream contain the identical information.
Add Import
import static de.smartics.util.test.matcher.io.StreamsEqualContentAs.streamsEqualContentAs;
In the following examples expected
and actual
are InputStream
s:
Assert Example
import static org.hamcrest.MatcherAssert.assertThat; assertThat(actual, streamsEqualContentAs(expected));
The following example shows a test spy and the verification of the expected stream argument:
Verify Example
import static org.mockito.Matchers.argThat; import static org.mockito.Mockito.verify; spy.pass(actual); // Test spy that expects a stream verify(spy).pass( (InputStream) argThat(streamsEqualContentAs(expected)));
Constructor Summary | |
---|---|
StreamsEqualContentAs(InputStream expected, String encoding) Default constructor. |
|
StreamsEqualContentAs(String expected, String encoding) Convenience constructor if the content is served as a String. |
Method Summary | |
---|---|
static org.hamcrest.Matcher<? super InputStream> |
streamsEqualContentAs(InputStream expected) Factory method to create the matcher defaulting to UTF-8. |
static org.hamcrest.Matcher<? super InputStream> |
streamsEqualContentAs(InputStream expected, String encoding) Factory method to create the matcher. |
static org.hamcrest.Matcher<? super InputStream> |
streamsEqualContentAs(String expected) Factory method to create the matcher for a preconfigured String with UTF-8 encoding. |
static org.hamcrest.Matcher<? super InputStream> |
streamsEqualContentAs(String expected, String encoding) Factory method to create the matcher for a preconfigured String . |
protected String |
toString(InputStream actual) Turns the instance to its string representation. |
Methods inherited from class de.smartics.util.test.matcher.io.AbstractEqualContentAs |
---|
describeTo, getActualContent, matchesSafely |
Methods inherited from class org.hamcrest.TypeSafeDiagnosingMatcher |
---|
describeMismatch, matches |
Methods inherited from class org.hamcrest.BaseMatcher |
---|
_dont_implement_Matcher___instead_extend_BaseMatcher_, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public StreamsEqualContentAs(InputStream expected, String encoding) throws IllegalArgumentException
expected
- the expected stream to compare to.
encoding
- the encoding expected on both streams.
IllegalArgumentException
- on any problem reading from the stream.
public StreamsEqualContentAs(String expected, String encoding)
expected
- the expected content.
encoding
- the encoding expected on both streams.
Method Detail |
---|
protected final String toString(InputStream actual) throws IllegalArgumentException
toString
in class
AbstractEqualContentAs<InputStream>
actual
- the instance whose string representation is requested.
actual
.
IllegalArgumentException
- if no string representation can be created.
AbstractEqualContentAs.toString(java.lang.Object)
public static org.hamcrest.Matcher<? super InputStream> streamsEqualContentAs(InputStream expected, String encoding) throws IllegalArgumentException
expected
- the expected stream content.
encoding
- the encoding expected on both streams.
IllegalArgumentException
- on any problem reading from the stream.
public static org.hamcrest.Matcher<? super InputStream> streamsEqualContentAs(InputStream expected) throws IllegalArgumentException
expected
- the expected stream content.
IllegalArgumentException
- on any problem reading from the stream.
public static org.hamcrest.Matcher<? super InputStream> streamsEqualContentAs(String expected, String encoding)
String
.
expected
- the expected stream content.
encoding
- the encoding expected on the stream.
public static org.hamcrest.Matcher<? super InputStream> streamsEqualContentAs(String expected)
String
with UTF-8 encoding.
expected
- the expected stream content.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |