use of org.cactoos.text.TextOf in project cactoos by yegor256.
the class TeeOutputStreamTest method copiesContentByteByByte.
@Test
@SuppressWarnings("unchecked")
void copiesContentByteByByte() throws Exception {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final ByteArrayOutputStream copy = new ByteArrayOutputStream();
final String content = "Hello, товарищ!";
new Assertion<>("Must copy OutputStream to OutputStream byte by byte", new TextOf(new ReaderOf(new TeeInputStream(new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8)), new TeeOutputStream(baos, copy)))).asString(), new AllOf<>(new IsEqual<String>(content), new IsEqual<String>(new String(baos.toByteArray(), StandardCharsets.UTF_8)), new IsEqual<String>(new String(copy.toByteArray(), StandardCharsets.UTF_8)))).affirm();
}
use of org.cactoos.text.TextOf in project cactoos by yegor256.
the class WriterToTest method writesLargeContentToFile.
@Test
public void writesLargeContentToFile() throws IOException {
final Path temp = this.folder.newFile("cactoos-1.txt-1").toPath();
new Assertion<>("Can't copy Input to Output and return Input", new TeeInput(new ResourceOf("org/cactoos/large-text.txt"), new WriterAsOutput(new WriterTo(temp))), new HasContent(new TextOf(temp))).affirm();
}
use of org.cactoos.text.TextOf in project cactoos by yegor256.
the class TeeOutputTest method copiesWithWriter.
@Test
public void copiesWithWriter() {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
new Assertion<>("Can't copy Output with writer", new TeeInput(new InputOf("Hello, товарищ! writer"), new TeeOutput(new OutputTo(baos), new WriterTo(new ByteArrayOutputStream()))), 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 copiesWithPath.
@Test
public void copiesWithPath() throws Exception {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final File file = this.folder.newFile();
new Assertion<>("Must copy Output with path", new TextOf(new TeeInput(new InputOf("Hello, товарищ! with path"), new TeeOutput(new OutputTo(baos), file.toPath()))), new IsText(new TextOf(file.toPath()))).affirm();
}
use of org.cactoos.text.TextOf in project cactoos by yegor256.
the class TeeOutputTest method copiesContent.
@Test
public void copiesContent() {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
new Assertion<>("Can't copy Output to Output and return Input", new TeeInput(new InputOf("Hello, товарищ!"), new TeeOutput(new OutputTo(baos), new OutputTo(new ByteArrayOutputStream()))), new HasContent(new TextOf(baos::toByteArray, StandardCharsets.UTF_8))).affirm();
}
Aggregations