Search in sources :

Example 46 with HasContent

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

the class InputStreamOfTest method readsSimpleFileContent.

@Test
public void readsSimpleFileContent() throws IOException {
    final Path temp = this.folder.newFile("cactoos-1.txt-1").toPath();
    final String content = "Hello, товарищ!";
    Files.write(temp, content.getBytes(StandardCharsets.UTF_8));
    new Assertion<>("Must read file content", new InputOf(new InputStreamOf(temp)), new HasContent(content)).affirm();
}
Also used : Path(java.nio.file.Path) HasContent(org.llorllale.cactoos.matchers.HasContent) Test(org.junit.Test)

Example 47 with HasContent

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

the class InputOfTest method readsSimpleFileContent.

@Test
void readsSimpleFileContent(@TempDir final Path folder) throws IOException {
    final Path temp = folder.resolve("cactoos-1.txt-1");
    final String content = "Hello, товарищ!";
    Files.write(temp, content.getBytes(StandardCharsets.UTF_8));
    new Assertion<>("must read file content", new InputOf(temp), new HasContent(content)).affirm();
}
Also used : Path(java.nio.file.Path) HasContent(org.llorllale.cactoos.matchers.HasContent) HasString(org.llorllale.cactoos.matchers.HasString) Test(org.junit.jupiter.api.Test)

Example 48 with HasContent

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

the class TeeInputFromCharSequenceTest method copiesFromCharSequenceToFile.

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

Example 49 with HasContent

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

the class TeeInputFromCharSequenceTest method copiesFromCharSequenceWithCharsetByNameToOutput.

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

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

the class TeeInputFromInputTest method copiesFromInputWithCharsetByNameToWriter.

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

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