use of org.cactoos.scalar.LengthOf in project cactoos by yegor256.
the class InputStreamOfTest method readsFromUrl.
@Test
public void readsFromUrl() throws Exception {
final String content = "Content for reading through URL";
final File file = this.folder.newFile("readFromUrl.txt-4");
new LengthOf(new TeeInput(content, file)).value();
new Assertion<>("Must read from URL", new TextOf(new InputStreamOf(file.toURI().toURL())), new IsText(content)).affirm();
}
use of org.cactoos.scalar.LengthOf 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.cactoos.scalar.LengthOf 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.cactoos.scalar.LengthOf in project cactoos by yegor256.
the class TeeInputFromBytesTest method copiesFromBytesToFile.
@Test
public void copiesFromBytesToFile() throws Exception {
final String message = "Hello, товарищ file äÄ üÜ öÖ and ß";
final File output = this.folder.newFile();
new LengthOf(new TeeInput(new BytesOf(message), output)).value();
new Assertion<>("Must copy bytes to file", new InputOf(output), new HasContent(message)).affirm();
}
use of org.cactoos.scalar.LengthOf in project cactoos by yegor256.
the class TeeInputFromBytesTest method copiesFromBytesToOutput.
@Test
public void copiesFromBytesToOutput() throws Exception {
final String message = "Hello, товарищ output äÄ üÜ öÖ and ß";
final File output = this.folder.newFile();
new LengthOf(new TeeInput(new BytesOf(message), new OutputTo(output))).value();
new Assertion<>("Must bytes to output", new InputOf(output), new HasContent(message)).affirm();
}
Aggregations