use of org.llorllale.cactoos.matchers.HasString in project cactoos by yegor256.
the class HeadOfTest method readsHeadOfShorterInput.
@Test
void readsHeadOfShorterInput() throws Exception {
final String input = "readsHeadOfShorterInput";
new Assertion<>("must limit to at most the number of available bytes", new TextOf(new HeadOf(new InputOf(input), 35)), new HasString(input)).affirm();
}
use of org.llorllale.cactoos.matchers.HasString 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.llorllale.cactoos.matchers.HasString in project cactoos by yegor256.
the class LoggingInputTest method logReadFromText.
@Test
void logReadFromText() throws Exception {
final Logger logger = new FakeLogger();
new LengthOf(new LoggingInput(new InputOf("Hello, товарищ!"), "memory", logger)).value();
new Assertion<>("Must log 22 bytes read from memory", new TextOf(logger.toString()), new HasString("Read 22 byte(s) from memory in")).affirm();
}
use of org.llorllale.cactoos.matchers.HasString in project cactoos by yegor256.
the class LoggingInputTest method logSkipFromLargeTextFile.
@Test
void logSkipFromLargeTextFile() throws Exception {
final Logger logger = new FakeLogger();
new LoggingInput(new ResourceOf("org/cactoos/large-text.txt"), "text file", logger).stream().skip(100);
new Assertion<>("Must log skip from text file", new TextOf(logger.toString()), new HasString("Skipped 100 byte(s) from text file.")).affirm();
}
use of org.llorllale.cactoos.matchers.HasString in project cactoos by yegor256.
the class LoggingInputTest method logReadFromDeadInput.
@Test
void logReadFromDeadInput() throws Exception {
final Logger logger = new FakeLogger();
new LengthOf(new LoggingInput(new DeadInput(), "dead input", logger)).value();
new Assertion<>("Must log zero byte read from dead input", new TextOf(logger.toString()), new HasString("Read 0 byte(s) from dead input in")).affirm();
}
Aggregations