use of org.cactoos.scalar.LengthOf in project cactoos by yegor256.
the class OutputToTest method writesIntoPath.
@Test
public void writesIntoPath() throws Exception {
final Path temp = this.folder.newFolder("cactoos-1").toPath();
final Path path = temp.resolve("one/two/three/file.txt");
final String content = "Hello, товарищ!";
new LengthOf(new TeeInput(content, new OutputTo(path))).value();
new Assertion<>("Must write into path", new InputOf(path), new HasContent(content)).affirm();
}
use of org.cactoos.scalar.LengthOf in project cactoos by yegor256.
the class OutputToTest method writesIntoWriterWithCharsetAndSize.
@Test
public void writesIntoWriterWithCharsetAndSize() throws Exception {
final String txt = "Hello, writer with charset and size!";
final StringWriter output = new StringWriter();
new LengthOf(new TeeInput(txt, new OutputTo(output, StandardCharsets.UTF_8, 1))).value();
new Assertion<>("Must write into writer with charset and size", new InputOf(output.getBuffer()), new HasContent(txt)).affirm();
}
use of org.cactoos.scalar.LengthOf in project cactoos by yegor256.
the class OutputToTest method writesIntoFile.
@Test
public void writesIntoFile() throws Exception {
final Path temp = this.folder.newFolder("cactoos-2").toPath();
final Path path = temp.resolve("a/b/c/file.txt");
final String txt = "Hello, друг!";
new LengthOf(new TeeInput(txt, new SyncOutput(new OutputTo(path.toFile())))).value();
new Assertion<>("Must write into file", new InputOf(path.toFile()), new HasContent(txt)).affirm();
}
use of org.cactoos.scalar.LengthOf 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.scalar.LengthOf in project cactoos by yegor256.
the class TeeInputFromBytesTest method copiesFromBytesToPath.
@Test
public void copiesFromBytesToPath() throws Exception {
final String message = "Hello, товарищ path äÄ üÜ öÖ and ß";
final File output = this.folder.newFile();
new LengthOf(new TeeInput(new BytesOf(message), output.toPath())).value();
new Assertion<>("Must copy bytes to file path", new InputOf(output), new HasContent(message)).affirm();
}
Aggregations