use of org.cactoos.text.TextOf 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();
}
use of org.cactoos.text.TextOf in project cactoos by yegor256.
the class LoggingInputTest method logMarkSupportedFromLargeTextFile.
@Test
void logMarkSupportedFromLargeTextFile() throws Exception {
final Logger logger = new FakeLogger();
new LoggingInput(new ResourceOf("org/cactoos/large-text.txt"), "text file", logger).stream().markSupported();
new Assertion<>("Must log mark and reset are not supported from text file", new TextOf(logger.toString()), new HasString("Mark and reset are supported from text file")).affirm();
}
use of org.cactoos.text.TextOf in project cactoos by yegor256.
the class LoggingInputTest method logAvailableFromLargeTextFile.
@Test
void logAvailableFromLargeTextFile() throws Exception {
final Logger logger = new FakeLogger();
new LoggingInput(new ResourceOf("org/cactoos/large-text.txt"), "text file", logger).stream().available();
new Assertion<>("Must log avaliable byte(s) from text file", new TextOf(logger.toString()), new HasString("There is(are) 74536 byte(s) available from text file")).affirm();
}
use of org.cactoos.text.TextOf in project cactoos by yegor256.
the class SlowInputTest method calculatesLength.
@Test
void calculatesLength() throws Exception {
final String text = "What's up, друг?";
new Assertion<>("Can't calculate the length of Input", new LengthOf(new SlowInput(new InputOf(new TextOf(text)))), new HasValue<>((long) text.getBytes(StandardCharsets.UTF_8).length)).affirm();
}
use of org.cactoos.text.TextOf in project cactoos by yegor256.
the class CloseShieldOutputStreamTest method writesContentToFile.
@Test
void writesContentToFile(@TempDir final Path tempdir) throws IOException {
final File file = new File(tempdir.toFile(), "cactoos-1.txt-1");
file.createNewFile();
final Path temp = file.toPath();
try (OutputStream out = new OutputStreamTo(temp)) {
new Assertion<>("Must copy Input to Output and return Input", new TextOf(new Sticky(new TeeInput(new ResourceOf("org/cactoos/small-text.txt"), new OutputTo(new CloseShieldOutputStream(out))))), new IsText(new TextOf(temp))).affirm();
}
}
Aggregations