Search in sources :

Example 66 with TextOf

use of org.cactoos.text.TextOf in project cactoos by yegor256.

the class TeeOutputTest method copiesWithOutputStream.

@Test
public void copiesWithOutputStream() {
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    new Assertion<>("Can't copy Output with output stream", new TeeInput(new InputOf("Hello, товарищ! with output stream"), new TeeOutput(new OutputTo(baos), new ByteArrayOutputStream())), 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 67 with TextOf

use of org.cactoos.text.TextOf in project cactoos by yegor256.

the class TeeInputFromTextTest method copiesFromTextToPath.

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

Example 68 with TextOf

use of org.cactoos.text.TextOf in project cactoos by yegor256.

the class OutputStreamToTest method writesLargeContentToFile.

@Test
public void writesLargeContentToFile() throws IOException {
    final Path temp = this.folder.newFile("cactoos-1.txt-1").toPath();
    new Assertion<>("Must copy Input to Output and return Input", new TextOf(new Sticky(new TeeInput(new ResourceOf("org/cactoos/large-text.txt"), new OutputTo(new OutputStreamTo(temp))))), new IsText(new TextOf(temp))).affirm();
}
Also used : Path(java.nio.file.Path) IsText(org.llorllale.cactoos.matchers.IsText) TextOf(org.cactoos.text.TextOf) Test(org.junit.Test)

Example 69 with TextOf

use of org.cactoos.text.TextOf in project cactoos by yegor256.

the class ReaderOfTest method readsUrl.

@Test
public void readsUrl() throws Exception {
    final String message = "URL on äÄ üÜ öÖ ß жш";
    final File input = this.folder.newFile();
    Files.write(input.toPath(), message.getBytes(StandardCharsets.UTF_8));
    new Assertion<>("Must read from url", new TextOf(new ReaderOf(input.toURI().toURL())), new IsText(message)).affirm();
}
Also used : IsText(org.llorllale.cactoos.matchers.IsText) TextOf(org.cactoos.text.TextOf) File(java.io.File) Test(org.junit.Test)

Example 70 with TextOf

use of org.cactoos.text.TextOf in project cactoos by yegor256.

the class ReaderOfTest method readsPath.

@Test
public void readsPath() throws Exception {
    final String message = "path on äÄ üÜ öÖ ß жш";
    final File input = this.folder.newFile();
    Files.write(input.toPath(), message.getBytes(StandardCharsets.UTF_8));
    new Assertion<>("Must read from path", new TextOf(new ReaderOf(input)), new IsText(message)).affirm();
}
Also used : IsText(org.llorllale.cactoos.matchers.IsText) TextOf(org.cactoos.text.TextOf) File(java.io.File) Test(org.junit.Test)

Aggregations

TextOf (org.cactoos.text.TextOf)74 Test (org.junit.Test)41 Test (org.junit.jupiter.api.Test)32 IsText (org.llorllale.cactoos.matchers.IsText)25 File (java.io.File)20 LengthOf (org.cactoos.scalar.LengthOf)20 HasString (org.llorllale.cactoos.matchers.HasString)17 HasContent (org.llorllale.cactoos.matchers.HasContent)15 ByteArrayOutputStream (java.io.ByteArrayOutputStream)14 Logger (java.util.logging.Logger)10 Text (org.cactoos.Text)9 AllOf (org.hamcrest.core.AllOf)7 IsEqual (org.hamcrest.core.IsEqual)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 StringReader (java.io.StringReader)5 Path (java.nio.file.Path)5 MatcherOf (org.cactoos.matchers.MatcherOf)5 InputStream (java.io.InputStream)4 OutputStreamWriter (java.io.OutputStreamWriter)4 BytesOf (org.cactoos.bytes.BytesOf)4