Search in sources :

Example 36 with HasContent

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

the class TeeOutputTest method copiesWithWriterAndCharset.

@Test
public void copiesWithWriterAndCharset() {
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    new Assertion<>("Can't copy Output with writer and charset", new TeeInput(new InputOf("Hello, товарищ! writer and charset"), new TeeOutput(new OutputTo(baos), new WriterTo(new ByteArrayOutputStream()), StandardCharsets.UTF_8)), new HasContent(new TextOf(baos::toByteArray, StandardCharsets.UTF_8))).affirm();
}
Also used : HasContent(org.llorllale.cactoos.matchers.HasContent) TextOf(org.cactoos.text.TextOf) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Example 37 with HasContent

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

the class TeeInputFromTextTest method copiesFromTextWithCharsetToPath.

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

Example 38 with HasContent

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

the class TeeInputFromByteArrayTest method copiesFromByteArrayToOutput.

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

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

the class TeeInputFromByteArrayTest method copiesFromByteArrayToFile.

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

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

the class TeeInputFromCharArrayTest method copiesFromCharArrayWithCharsetToPath.

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

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