Search in sources :

Example 41 with LengthOf

use of org.cactoos.scalar.LengthOf 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 42 with LengthOf

use of org.cactoos.scalar.LengthOf 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)

Example 43 with LengthOf

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

the class TeeInputFromCharArrayTest method copiesFromCharArrayToFile.

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

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

the class TeeInputFromCharArrayTest method copiesFromCharArrayWithCharsetByNameToOutput.

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

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

the class TeeInputFromCharArrayTest method copiesFromCharArrayToPath.

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

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