Search in sources :

Example 31 with HasContent

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

the class TeeInputFromBytesTest method copiesFromBytesToOutput.

@Test
public void copiesFromBytesToOutput() throws Exception {
    final String message = "Hello, товарищ output äÄ üÜ öÖ and ß";
    final File output = this.folder.newFile();
    new LengthOf(new TeeInput(new BytesOf(message), new OutputTo(output))).value();
    new Assertion<>("Must bytes to output", 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)

Example 32 with HasContent

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

the class TeeInputFromCharSequenceTest method copiesFromCharSequenceWithCharsetByNameToFile.

@Test
public void copiesFromCharSequenceWithCharsetByNameToFile() throws Exception {
    final String input = "Hello, товарищ file #3 äÄ üÜ öÖ and ß";
    final File output = this.folder.newFile();
    new LengthOf(new TeeInput(input, output, StandardCharsets.UTF_8.name())).value();
    new Assertion<>("char sequence 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) File(java.io.File) Test(org.junit.Test)

Example 33 with HasContent

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

the class TeeInputFromCharSequenceTest method copiesFromCharSequenceToOutput.

@Test
public void copiesFromCharSequenceToOutput() throws Exception {
    final String input = "Hello, товарищ output #1 äÄ üÜ öÖ and ß";
    final File output = this.folder.newFile();
    new LengthOf(new TeeInput(input, new OutputTo(output))).value();
    new Assertion<>("char sequence must be copied 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 34 with HasContent

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

the class TeeInputFromCharSequenceTest method copiesFromCharSequenceWithCharsetToOutput.

@Test
public void copiesFromCharSequenceWithCharsetToOutput() throws Exception {
    final String input = "Hello, товарищ output #2 äÄ üÜ öÖ and ß";
    final File output = this.folder.newFile();
    new LengthOf(new TeeInput(input, new OutputTo(output), StandardCharsets.UTF_8)).value();
    new Assertion<>("char sequence must be copied to the output with UTF_8 charset", 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 35 with HasContent

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

the class TeeInputFromUriTest method copiesFromUriToOutput.

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