use of org.cactoos.scalar.LengthOf in project cactoos by yegor256.
the class OutputToTest method writesIntoWriterWithCharsetByName.
@Test
public void writesIntoWriterWithCharsetByName() throws Exception {
final String txt = "Hello, writer with charset by name!";
final StringWriter output = new StringWriter();
new LengthOf(new TeeInput(txt, new OutputTo(output, StandardCharsets.UTF_8))).value();
new Assertion<>("Must write into writer with charset by name", new InputOf(output.getBuffer()), new HasContent(txt)).affirm();
}
use of org.cactoos.scalar.LengthOf in project cactoos by yegor256.
the class TeeInputFromUriTest method copiesFromUriToFile.
@Test
public void copiesFromUriToFile() throws Exception {
final String message = "Hello, товарищ file #1 äÄ üÜ öÖ and ß";
final File input = this.folder.newFile();
Files.write(input.toPath(), message.getBytes(StandardCharsets.UTF_8));
final File output = this.folder.newFile();
new LengthOf(new TeeInput(input.toURI(), output)).value();
new Assertion<>("Must copy from URI to file.", new InputOf(output), new HasContent(message)).affirm();
}
use of org.cactoos.scalar.LengthOf in project cactoos by yegor256.
the class TeeInputFromUriTest method copiesFromUriToOutput.
@Test
public void copiesFromUriToOutput() throws Exception {
final String message = "Hello, товарищ output #1 äÄ üÜ öÖ and ß";
final File input = this.folder.newFile();
Files.write(input.toPath(), message.getBytes(StandardCharsets.UTF_8));
final File output = this.folder.newFile();
new LengthOf(new TeeInput(input.toURI(), new OutputTo(output))).value();
new Assertion<>("Must copy from URI to output.", new InputOf(output), new HasContent(message)).affirm();
}
use of org.cactoos.scalar.LengthOf in project cactoos by yegor256.
the class StickyTest method readsFileContentSlowlyAndCountsLength.
@Test
void readsFileContentSlowlyAndCountsLength() throws Exception {
final long size = 100_000L;
new Assertion<>("Must read bytes from a large source slowly and count length", new LengthOf(new Sticky(new SlowInput(size))).value(), new IsEqual<>(size)).affirm();
}
use of org.cactoos.scalar.LengthOf in project cactoos by yegor256.
the class TeeInputFromByteArrayTest method copiesFromByteArrayToOutput.
@Test
public void copiesFromByteArrayToOutput() throws Exception {
final String message = "Hello, товарищ output äÄ üÜ öÖ and ß";
final File output = this.folder.newFile();
new LengthOf(new TeeInput(message.getBytes(StandardCharsets.UTF_8), new OutputTo(output))).value();
new Assertion<>("Must copy bytes to output", new InputOf(output), new HasContent(message)).affirm();
}
Aggregations