Search in sources :

Example 61 with HasContent

use of org.llorllale.cactoos.matchers.HasContent in project cactoos by yegor256.

the class TeeInputFromReaderTest method copiesFromReaderWithCharsetByNameAndSizeToOutput.

@Test
public void copiesFromReaderWithCharsetByNameAndSizeToOutput() throws Exception {
    final String input = "Hello, товарищ output #6 äÄ üÜ öÖ and ß";
    final File output = this.folder.newFile();
    new LengthOf(new TeeInput(new ReaderOf(input), new OutputTo(output), StandardCharsets.UTF_8.name(), input.length())).value();
    new Assertion<>("Must copy from reader with charset by name and size to output.", new InputOf(output), new HasContent(input)).affirm();
}
Also used : HasContent(org.llorllale.cactoos.matchers.HasContent) LengthOf(org.cactoos.scalar.LengthOf) File(java.io.File) Test(org.junit.Test)

Example 62 with HasContent

use of org.llorllale.cactoos.matchers.HasContent in project cactoos by yegor256.

the class OutputToTest method writesIntoWriterWithCharset.

@Test
public void writesIntoWriterWithCharset() throws Exception {
    final String txt = "Hello, writer with charset!";
    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", new InputOf(output.getBuffer()), new HasContent(txt)).affirm();
}
Also used : HasContent(org.llorllale.cactoos.matchers.HasContent) StringWriter(java.io.StringWriter) LengthOf(org.cactoos.scalar.LengthOf) Test(org.junit.Test)

Example 63 with HasContent

use of org.llorllale.cactoos.matchers.HasContent in project cactoos by yegor256.

the class OutputToTest method writesIntoWriterWithCharsetByNameAndSize.

@Test
public void writesIntoWriterWithCharsetByNameAndSize() throws Exception {
    final String txt = "Hello, writer with charset by name and size!";
    final StringWriter output = new StringWriter();
    new LengthOf(new TeeInput(txt, new OutputTo(output, StandardCharsets.UTF_8.name(), 1))).value();
    new Assertion<>("Must write into writer with charset by name and size", new InputOf(output.getBuffer()), new HasContent(txt)).affirm();
}
Also used : HasContent(org.llorllale.cactoos.matchers.HasContent) StringWriter(java.io.StringWriter) LengthOf(org.cactoos.scalar.LengthOf) Test(org.junit.Test)

Example 64 with HasContent

use of org.llorllale.cactoos.matchers.HasContent 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();
}
Also used : Path(java.nio.file.Path) HasContent(org.llorllale.cactoos.matchers.HasContent) LengthOf(org.cactoos.scalar.LengthOf) Test(org.junit.Test)

Example 65 with HasContent

use of org.llorllale.cactoos.matchers.HasContent 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();
}
Also used : HasContent(org.llorllale.cactoos.matchers.HasContent) StringWriter(java.io.StringWriter) LengthOf(org.cactoos.scalar.LengthOf) Test(org.junit.Test)

Aggregations

HasContent (org.llorllale.cactoos.matchers.HasContent)91 Test (org.junit.Test)89 LengthOf (org.cactoos.scalar.LengthOf)80 File (java.io.File)73 TextOf (org.cactoos.text.TextOf)15 StringWriter (java.io.StringWriter)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 Path (java.nio.file.Path)5 BytesOf (org.cactoos.bytes.BytesOf)3 Concatenated (org.cactoos.text.Concatenated)2 Test (org.junit.jupiter.api.Test)2 OutputStreamWriter (java.io.OutputStreamWriter)1 Reader (java.io.Reader)1 HasString (org.llorllale.cactoos.matchers.HasString)1