Search in sources :

Example 16 with HasContent

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

the class TeeInputFromInputTest method copiesFromInputToPath.

@Test
public void copiesFromInputToPath() throws Exception {
    final String input = "Hello, товарищ path #1 äÄ üÜ öÖ and ß";
    final File output = this.folder.newFile();
    new LengthOf(new TeeInput(new InputOf(input), output.toPath())).value();
    new Assertion<>("Must copy from input to the output path", 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 17 with HasContent

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

the class TeeInputFromInputTest method copiesFromInputToWriter.

@Test
public void copiesFromInputToWriter() throws Exception {
    final String input = "Hello, товарищ write #1 äÄ üÜ öÖ and ß";
    final File output = this.folder.newFile();
    new LengthOf(new TeeInput(new InputOf(input), new WriterTo(output))).value();
    new Assertion<>("Must copy from input to the 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 18 with HasContent

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

the class TeeInputFromInputTest method copiesFromInputWithSizeToWriter.

@Test
public void copiesFromInputWithSizeToWriter() throws Exception {
    final String input = "Hello, товарищ writer #2 äÄ üÜ öÖ and ß";
    final File output = this.folder.newFile();
    new LengthOf(new TeeInput(new InputOf(input), new WriterTo(output), input.length())).value();
    new Assertion<>("Must copy from input with size to the 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 19 with HasContent

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

the class TeeInputFromInputTest method copiesFromInputWithCharsetToWriter.

@Test
public void copiesFromInputWithCharsetToWriter() throws Exception {
    final String input = "Hello, товарищ writer #3 äÄ üÜ öÖ and ß";
    final File output = this.folder.newFile();
    new LengthOf(new TeeInput(new InputOf(input), new WriterTo(output), StandardCharsets.UTF_8)).value();
    new Assertion<>("Must copy from input with charset 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 20 with HasContent

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

the class TeeInputFromReaderTest method copiesFromReaderWithCharsetByNameToPath.

@Test
public void copiesFromReaderWithCharsetByNameToPath() throws Exception {
    final String input = "Hello, товарищ path #5 äÄ üÜ öÖ and ß";
    final File output = this.folder.newFile();
    new LengthOf(new TeeInput(new ReaderOf(input), output.toPath(), StandardCharsets.UTF_8.name())).value();
    new Assertion<>("Must copy from reader with charset by name to path.", 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)

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