Search in sources :

Example 71 with HasContent

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

the class TeeInputFromTextTest method copiesFromTextToOutput.

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

Example 72 with HasContent

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

the class TeeInputFromTextTest method copiesFromTextWithCharsetByNameToOutput.

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

Example 73 with HasContent

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

the class TeeInputFromUrlTest method copiesFromUrlToOutput.

@Test
public void copiesFromUrlToOutput() 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().toURL(), new OutputTo(output))).value();
    new Assertion<>("Must copy from URL 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)

Example 74 with HasContent

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

the class TeeInputFromUrlTest method copiesFromUrlToPath.

@Test
public void copiesFromUrlToPath() throws Exception {
    final String message = "Hello, товарищ path #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().toURL(), output.toPath())).value();
    new Assertion<>("Must copy from URL to path.", 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)

Example 75 with HasContent

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

the class WriterToTest method writesLargeContentToFile.

@Test
public void writesLargeContentToFile() throws IOException {
    final Path temp = this.folder.newFile("cactoos-1.txt-1").toPath();
    new Assertion<>("Can't copy Input to Output and return Input", new TeeInput(new ResourceOf("org/cactoos/large-text.txt"), new WriterAsOutput(new WriterTo(temp))), new HasContent(new TextOf(temp))).affirm();
}
Also used : Path(java.nio.file.Path) HasContent(org.llorllale.cactoos.matchers.HasContent) TextOf(org.cactoos.text.TextOf) 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