use of org.hamcrest.core.AllOf in project cactoos by yegor256.
the class TeeInputStreamTest method copiesContentByteByByte.
@Test
@SuppressWarnings("unchecked")
void copiesContentByteByByte() throws Exception {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final String content = "Hello, товарищ!";
new Assertion<>("Must copy InputStream to OutputStream byte by byte", new TextOf(new ReaderOf(new TeeInputStream(new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8)), baos))).asString(), new AllOf<>(new IsEqual<String>(content), new IsEqual<String>(new String(baos.toByteArray(), StandardCharsets.UTF_8)))).affirm();
}
use of org.hamcrest.core.AllOf in project cactoos by yegor256.
the class InputOfTest method readsStringBuilder.
@Test
void readsStringBuilder() throws Exception {
final String starts = "Name it, ";
final String ends = "then it exists!";
new Assertion<>("must receive a string builder", new TextOf(new BytesOf(new InputOf(new StringBuilder(starts).append(ends)))), new AllOf<>(new StartsWith(starts), new EndsWith(ends))).affirm();
}
use of org.hamcrest.core.AllOf in project cactoos by yegor256.
the class InputOfTest method readsStringBuffer.
@Test
void readsStringBuffer() throws Exception {
final String starts = "The future ";
final String ends = "is now!";
new Assertion<>("must receive a string buffer", new TextOf(new BytesOf(new InputOf(new StringBuffer(starts).append(ends)))), new AllOf<>(new StartsWith(starts), new EndsWith(ends))).affirm();
}
use of org.hamcrest.core.AllOf in project cactoos by yegor256.
the class LoggingInputTest method logResetFromLargeTextFile.
@Test
@SuppressWarnings("unchecked")
void logResetFromLargeTextFile() throws Exception {
final Logger logger = new FakeLogger();
final InputStream input = new LoggingInput(new ResourceOf("org/cactoos/large-text.txt"), "text file", logger).stream();
// @checkstyle MagicNumber (1 line)
input.mark(150);
input.reset();
new Assertion<>("Must log mark and reset from text file", new TextOf(logger.toString()), new AllOf<>(new HasString("Marked position 150 from text file"), new HasString("Reset input stream from text file"))).affirm();
}
use of org.hamcrest.core.AllOf in project cactoos by yegor256.
the class TextOfTest method readsStringBuffer.
@Test
void readsStringBuffer() {
final String starts = "In our daily life, ";
final String ends = "we can smile!";
new Assertion<>("Can't process a string builder hahahaha", new TextOf(new StringBuffer(starts).append(ends)), new AllOf<>(new StartsWith(starts), new EndsWith(ends))).affirm();
}
Aggregations