Search in sources :

Example 6 with HasContent

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

Example 7 with HasContent

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

the class TeeInputFromTextTest method copiesFromTextWithCharsetByNameToFile.

@Test
public void copiesFromTextWithCharsetByNameToFile() throws Exception {
    final String input = "Hello, товарищ file #3 äÄ üÜ öÖ and ß";
    final File output = this.folder.newFile();
    new LengthOf(new TeeInput(new TextOf(input), output, StandardCharsets.UTF_8.name())).value();
    new Assertion<>("text must be copied to the file with UTF_8 charset's name", new InputOf(output), new HasContent(input)).affirm();
}
Also used : HasContent(org.llorllale.cactoos.matchers.HasContent) LengthOf(org.cactoos.scalar.LengthOf) TextOf(org.cactoos.text.TextOf) File(java.io.File) Test(org.junit.Test)

Example 8 with HasContent

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

the class TeeInputFromTextTest method copiesFromTextToFile.

@Test
public void copiesFromTextToFile() throws Exception {
    final String input = "Hello, товарищ file #1 äÄ üÜ öÖ and ß";
    final File output = this.folder.newFile();
    new LengthOf(new TeeInput(new TextOf(input), output)).value();
    new Assertion<>("text must be copied to the file", new InputOf(output), new HasContent(input)).affirm();
}
Also used : HasContent(org.llorllale.cactoos.matchers.HasContent) LengthOf(org.cactoos.scalar.LengthOf) TextOf(org.cactoos.text.TextOf) File(java.io.File) Test(org.junit.Test)

Example 9 with HasContent

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

the class TeeInputFromTextTest method copiesFromTextWithCharsetByNameToPath.

@Test
public void copiesFromTextWithCharsetByNameToPath() throws Exception {
    final String input = "Hello, товарищ path #3 äÄ üÜ öÖ and ß";
    final File output = this.folder.newFile();
    new LengthOf(new TeeInput(new TextOf(input), output.toPath(), StandardCharsets.UTF_8.name())).value();
    new Assertion<>("text must be copied to the path with UTF_8 charset's name", new InputOf(output), new HasContent(input)).affirm();
}
Also used : HasContent(org.llorllale.cactoos.matchers.HasContent) LengthOf(org.cactoos.scalar.LengthOf) TextOf(org.cactoos.text.TextOf) File(java.io.File) Test(org.junit.Test)

Example 10 with HasContent

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