Search in sources :

Example 6 with LengthOf

use of org.cactoos.scalar.LengthOf in project cactoos by yegor256.

the class TeeInputFromReaderTest method copiesFromReaderWithSizeToFile.

@Test
public void copiesFromReaderWithSizeToFile() throws Exception {
    final String input = "Hello, товарищ file #2 äÄ üÜ öÖ and ß";
    final File output = this.folder.newFile();
    new LengthOf(new TeeInput(new ReaderOf(input), output, input.length())).value();
    new Assertion<>("Must copy from reader with size to 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 7 with LengthOf

use of org.cactoos.scalar.LengthOf in project cactoos by yegor256.

the class TeeInputFromReaderTest method copiesFromReaderWithCharsetToFile.

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

use of org.cactoos.scalar.LengthOf in project cactoos by yegor256.

the class TeeInputFromReaderTest method copiesFromReaderWithCharsetAndSizeToPath.

@Test
public void copiesFromReaderWithCharsetAndSizeToPath() throws Exception {
    final String input = "Hello, товарищ path #4 äÄ üÜ öÖ and ß";
    final File output = this.folder.newFile();
    new LengthOf(new TeeInput(new ReaderOf(input), output.toPath(), StandardCharsets.UTF_8, input.length())).value();
    new Assertion<>("Must copy from reader with charset and size to 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 9 with LengthOf

use of org.cactoos.scalar.LengthOf in project cactoos by yegor256.

the class TeeInputFromReaderTest method copiesFromReaderWithCharsetToOutput.

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

Example 10 with LengthOf

use of org.cactoos.scalar.LengthOf in project cactoos by yegor256.

the class TeeInputFromReaderTest method copiesFromReaderWithCharsetByNameToFile.

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

Aggregations

LengthOf (org.cactoos.scalar.LengthOf)103 Test (org.junit.Test)92 HasContent (org.llorllale.cactoos.matchers.HasContent)80 File (java.io.File)75 TextOf (org.cactoos.text.TextOf)20 Test (org.junit.jupiter.api.Test)11 Logger (java.util.logging.Logger)9 StringWriter (java.io.StringWriter)7 HasString (org.llorllale.cactoos.matchers.HasString)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 Path (java.nio.file.Path)5 OutputStream (java.io.OutputStream)4 AllOf (org.hamcrest.core.AllOf)4 IsEqual (org.hamcrest.core.IsEqual)4 IsText (org.llorllale.cactoos.matchers.IsText)4 BytesOf (org.cactoos.bytes.BytesOf)3 StringContains (org.hamcrest.core.StringContains)3 OutputStreamWriter (java.io.OutputStreamWriter)2 GZIPOutputStream (java.util.zip.GZIPOutputStream)2 BufferedWriter (java.io.BufferedWriter)1