Search in sources :

Example 31 with IsText

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

the class TeeOutputTest method copiesWithPath.

@Test
public void copiesWithPath() throws Exception {
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final File file = this.folder.newFile();
    new Assertion<>("Must copy Output with path", new TextOf(new TeeInput(new InputOf("Hello, товарищ! with path"), new TeeOutput(new OutputTo(baos), file.toPath()))), new IsText(new TextOf(file.toPath()))).affirm();
}
Also used : IsText(org.llorllale.cactoos.matchers.IsText) TextOf(org.cactoos.text.TextOf) ByteArrayOutputStream(java.io.ByteArrayOutputStream) File(java.io.File) Test(org.junit.Test)

Example 32 with IsText

use of org.llorllale.cactoos.matchers.IsText 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 33 with IsText

use of org.llorllale.cactoos.matchers.IsText 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 34 with IsText

use of org.llorllale.cactoos.matchers.IsText 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)

Example 35 with IsText

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

the class ImmutableTest method decoratesToString.

@Test
public void decoratesToString() throws Exception {
    final String string = new Randomized().asString();
    final Iterator<Object> iterator = new Iterator<Object>() {

        public Object next() {
            return new Object();
        }

        public boolean hasNext() {
            return false;
        }

        public String toString() {
            return string;
        }
    };
    final Iterator<Object> immutable = new Immutable<>(iterator);
    new Assertion<>("must delegate toString to decorated iterator", new TextOf(immutable.toString()), new IsText(iterator.toString())).affirm();
}
Also used : Randomized(org.cactoos.text.Randomized) Iterator(java.util.Iterator) IsText(org.llorllale.cactoos.matchers.IsText) TextOf(org.cactoos.text.TextOf) Test(org.junit.Test)

Aggregations

IsText (org.llorllale.cactoos.matchers.IsText)51 Test (org.junit.jupiter.api.Test)35 TextOf (org.cactoos.text.TextOf)22 Test (org.junit.Test)16 HasString (org.llorllale.cactoos.matchers.HasString)12 File (java.io.File)11 StringReader (java.io.StringReader)6 Text (org.cactoos.Text)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 InputStream (java.io.InputStream)5 LengthOf (org.cactoos.scalar.LengthOf)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 LocalDate (java.time.LocalDate)3 LocalDateTime (java.time.LocalDateTime)3 OffsetDateTime (java.time.OffsetDateTime)3 ZonedDateTime (java.time.ZonedDateTime)3 Calendar (java.util.Calendar)3 Path (java.nio.file.Path)2 BytesOf (org.cactoos.bytes.BytesOf)2 BufferedWriter (java.io.BufferedWriter)1