use of org.llorllale.cactoos.matchers.HasString in project cactoos by yegor256.
the class RotatedTest method noRotateWhenShiftZero.
@Test
void noRotateWhenShiftZero() {
final String nonrotate = "Cactoos!";
new Assertion<>("Rotate text shift zero", new Rotated(new TextOf(nonrotate), 0), new HasString(nonrotate)).affirm();
}
use of org.llorllale.cactoos.matchers.HasString in project cactoos by yegor256.
the class LoggingInputTest method logReadFromOneByte.
@Test
void logReadFromOneByte() throws Exception {
final Logger logger = new FakeLogger();
new LengthOf(new LoggingInput(new InputOf("a"), "memory", logger)).value();
new Assertion<>("Must log one byte read from memory", new TextOf(logger.toString()), new HasString("Read 1 byte(s) from memory in")).affirm();
}
use of org.llorllale.cactoos.matchers.HasString in project cactoos by yegor256.
the class LoggingInputTest method logReadFromLargeTextFile.
@Test
@SuppressWarnings("unchecked")
void logReadFromLargeTextFile() throws Exception {
final Logger logger = new FakeLogger();
new LengthOf(new LoggingInput(new ResourceOf("org/cactoos/large-text.txt"), "text file", logger)).value();
new Assertion<>("Must log 74536 bytes read from text file", new TextOf(logger.toString()), new AllOf<>(new IsNot<Text>(new HasString("Read 16384 byte(s) from text file")), new HasString("Read 74536 byte(s) from text file in"), new HasString("Closed input stream from text file"))).affirm();
}
use of org.llorllale.cactoos.matchers.HasString in project cactoos by yegor256.
the class LoggingInputTest method logAllFromLargeTextFile.
@Test
@SuppressWarnings("unchecked")
void logAllFromLargeTextFile() throws Exception {
final Logger logger = new FakeLogger(Level.WARNING);
new LengthOf(new LoggingInput(new ResourceOf("org/cactoos/large-text.txt"), "text file", logger)).value();
new Assertion<>("Must log all read and close operations from text file", new TextOf(logger.toString()), new AllOf<>(new HasString("Read 16384 byte(s) from text file"), new HasString("Read 32768 byte(s) from text file"), new HasString("Read 49152 byte(s) from text file"), new HasString("Read 65536 byte(s) from text file"), new HasString("Read 74536 byte(s) from text file"), new HasString("Closed input stream from text file"))).affirm();
}
use of org.llorllale.cactoos.matchers.HasString in project cactoos by yegor256.
the class LoggingInputTest method logIntoCreatedLogger.
@Test
void logIntoCreatedLogger() throws Exception {
final FakeHandler handler = new FakeHandler();
final String src = "my source";
final Logger logger = Logger.getLogger(src);
logger.addHandler(handler);
try {
new LengthOf(new LoggingInput(new InputOf("Hi there"), src)).value();
new Assertion<>("", new TextOf(handler.toString()), new HasString("Read 8 byte(s)")).affirm();
} finally {
logger.removeHandler(handler);
}
}
Aggregations