use of org.cactoos.scalar.LengthOf in project cactoos by yegor256.
the class TeeInputFromUrlTest method copiesFromUrlToOutput.
@Test
public void copiesFromUrlToOutput() 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().toURL(), new OutputTo(output))).value();
new Assertion<>("Must copy from URL to output.", new InputOf(output), new HasContent(message)).affirm();
}
use of org.cactoos.scalar.LengthOf in project cactoos by yegor256.
the class TeeInputFromUrlTest method copiesFromUrlToPath.
@Test
public void copiesFromUrlToPath() throws Exception {
final String message = "Hello, товарищ path #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().toURL(), output.toPath())).value();
new Assertion<>("Must copy from URL to path.", new InputOf(output), new HasContent(message)).affirm();
}
use of org.cactoos.scalar.LengthOf in project cactoos by yegor256.
the class WriterAsOutputStreamTest method writesToFileAndRemovesIt.
@Test
public void writesToFileAndRemovesIt() throws Exception {
final Path temp = this.folder.newFile().toPath();
final String content = "Hello, товарищ! How are you?";
try (OutputStreamWriter writer = new OutputStreamWriter(Files.newOutputStream(temp.toAbsolutePath()), StandardCharsets.UTF_8)) {
new LengthOf(new TeeInput(new InputOf(content), new OutputTo(new WriterAsOutputStream(writer, StandardCharsets.UTF_8, // @checkstyle MagicNumber (1 line)
345)))).value();
}
Files.delete(temp);
new Assertion<>("file must not exist anymore", Files.exists(temp), new IsNot<>(new IsTrue())).affirm();
}
use of org.cactoos.scalar.LengthOf in project cactoos by yegor256.
the class TeeInputFromByteArrayTest method copiesFromByteArrayToPath.
@Test
public void copiesFromByteArrayToPath() throws Exception {
final String message = "Hello, товарищ path äÄ üÜ öÖ and ß";
final File output = this.folder.newFile();
new LengthOf(new TeeInput(message.getBytes(StandardCharsets.UTF_8), output.toPath())).value();
new Assertion<>("Must copy bytes to path", new InputOf(output), new HasContent(message)).affirm();
}
use of org.cactoos.scalar.LengthOf in project cactoos by yegor256.
the class TeeInputFromCharArrayTest method copiesFromCharArrayWithCharsetToOutput.
@Test
public void copiesFromCharArrayWithCharsetToOutput() throws Exception {
final String input = "Hello, товарищ output #2 äÄ üÜ öÖ and ß";
final File output = this.folder.newFile();
new LengthOf(new TeeInput(input.toCharArray(), new OutputTo(output), StandardCharsets.UTF_8)).value();
new Assertion<>("char array must be copied to the output with UTF_8 charset", new InputOf(output), new HasContent(input)).affirm();
}
Aggregations