Search in sources :

Example 66 with HasContent

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

the class OutputToTest method writesIntoFile.

@Test
public void writesIntoFile() throws Exception {
    final Path temp = this.folder.newFolder("cactoos-2").toPath();
    final Path path = temp.resolve("a/b/c/file.txt");
    final String txt = "Hello, друг!";
    new LengthOf(new TeeInput(txt, new SyncOutput(new OutputTo(path.toFile())))).value();
    new Assertion<>("Must write into file", new InputOf(path.toFile()), new HasContent(txt)).affirm();
}
Also used : Path(java.nio.file.Path) HasContent(org.llorllale.cactoos.matchers.HasContent) LengthOf(org.cactoos.scalar.LengthOf) Test(org.junit.Test)

Example 67 with HasContent

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

the class TeeInputFromBytesTest method copiesFromBytesToPath.

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

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

the class TeeInputFromCharSequenceTest method copiesFromCharSequenceWithCharsetToPath.

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

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

the class TeeInputFromCharSequenceTest method copiesFromCharSequenceToPath.

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

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

the class TeeInputFromTextTest method copiesFromTextWithCharsetToOutput.

@Test
public void copiesFromTextWithCharsetToOutput() throws Exception {
    final String input = "Hello, товарищ output #2 äÄ üÜ öÖ and ß";
    final File output = this.folder.newFile();
    new LengthOf(new TeeInput(new TextOf(input), new OutputTo(output), StandardCharsets.UTF_8)).value();
    new Assertion<>("text 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) 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