Search in sources :

Example 26 with HasContent

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

the class TeeInputFromReaderTest method copiesFromReaderWithCharsetAndSizeToPath.

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

Example 27 with HasContent

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

the class TeeInputFromReaderTest method copiesFromReaderWithCharsetToOutput.

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

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

the class TeeInputFromReaderTest method copiesFromReaderWithCharsetByNameToFile.

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

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

the class TeeInputFromReaderTest method copiesFromReaderWithCharsetByNameAndSizeToPath.

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

Example 30 with HasContent

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

the class TeeInputFromBytesTest method copiesFromBytesToFile.

@Test
public void copiesFromBytesToFile() throws Exception {
    final String message = "Hello, товарищ file äÄ üÜ öÖ and ß";
    final File output = this.folder.newFile();
    new LengthOf(new TeeInput(new BytesOf(message), output)).value();
    new Assertion<>("Must copy bytes to file", new InputOf(output), new HasContent(message)).affirm();
}
Also used : HasContent(org.llorllale.cactoos.matchers.HasContent) BytesOf(org.cactoos.bytes.BytesOf) 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