use of org.cactoos.text.TextOf in project cactoos by yegor256.
the class TeeInputFromTextTest method copiesFromTextWithCharsetToFile.
@Test
public void copiesFromTextWithCharsetToFile() throws Exception {
final String input = "Hello, товарищ file #2 äÄ üÜ öÖ and ß";
final File output = this.folder.newFile();
new LengthOf(new TeeInput(new TextOf(input), output, StandardCharsets.UTF_8)).value();
new Assertion<>("text must be copied to the file with UTF_8 charset", new InputOf(output), new HasContent(input)).affirm();
}
use of org.cactoos.text.TextOf in project cactoos by yegor256.
the class WriterAsOutputStreamTest method writesToByteArray.
@Test
public void writesToByteArray() {
final String content = "Hello, товарищ! How are you?";
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
new Assertion<>("Can't copy Input to Writer", new TeeInput(new InputOf(content), new OutputTo(new WriterAsOutputStream(new OutputStreamWriter(baos, StandardCharsets.UTF_8), StandardCharsets.UTF_8, // @checkstyle MagicNumber (1 line)
13))), new HasContent(new TextOf(baos::toByteArray, StandardCharsets.UTF_8))).affirm();
}
use of org.cactoos.text.TextOf in project cactoos by yegor256.
the class TeeInputStreamTest method copiesContentByteByByte.
@Test
@SuppressWarnings("unchecked")
void copiesContentByteByByte() throws Exception {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final String content = "Hello, товарищ!";
new Assertion<>("Must copy InputStream to OutputStream byte by byte", new TextOf(new ReaderOf(new TeeInputStream(new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8)), baos))).asString(), new AllOf<>(new IsEqual<String>(content), new IsEqual<String>(new String(baos.toByteArray(), StandardCharsets.UTF_8)))).affirm();
}
use of org.cactoos.text.TextOf in project cactoos by yegor256.
the class TeeOutputTest method copiesWithWriterAndCharset.
@Test
public void copiesWithWriterAndCharset() {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
new Assertion<>("Can't copy Output with writer and charset", new TeeInput(new InputOf("Hello, товарищ! writer and charset"), new TeeOutput(new OutputTo(baos), new WriterTo(new ByteArrayOutputStream()), StandardCharsets.UTF_8)), new HasContent(new TextOf(baos::toByteArray, StandardCharsets.UTF_8))).affirm();
}
use of org.cactoos.text.TextOf in project cactoos by yegor256.
the class TeeOutputTest method copiesWithFile.
@Test
public void copiesWithFile() throws Exception {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final File file = this.folder.newFile();
new Assertion<>("Must copy Output with file", new TextOf(new TeeInput(new InputOf("Hello, товарищ! with file"), new TeeOutput(new OutputTo(baos), file))), new IsText(new TextOf(file.toPath()))).affirm();
}
Aggregations