Search in sources :

Example 26 with IsText

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

the class CloseShieldOutputStreamTest method writesContentToFile.

@Test
void writesContentToFile(@TempDir final Path tempdir) throws IOException {
    final File file = new File(tempdir.toFile(), "cactoos-1.txt-1");
    file.createNewFile();
    final Path temp = file.toPath();
    try (OutputStream out = new OutputStreamTo(temp)) {
        new Assertion<>("Must copy Input to Output and return Input", new TextOf(new Sticky(new TeeInput(new ResourceOf("org/cactoos/small-text.txt"), new OutputTo(new CloseShieldOutputStream(out))))), new IsText(new TextOf(temp))).affirm();
    }
}
Also used : Path(java.nio.file.Path) OutputStream(java.io.OutputStream) IsText(org.llorllale.cactoos.matchers.IsText) TextOf(org.cactoos.text.TextOf) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 27 with IsText

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

the class BytesOfTest method readsFromReader.

@Test
void readsFromReader() throws Exception {
    final String source = "hello, друг!";
    new Assertion<>("must read string through a reader", new TextOf(new Sticky(new InputOf(new BytesOf(new StringReader(source), StandardCharsets.UTF_8, // @checkstyle MagicNumberCheck (1 line)
    16 << 10)))), new IsText(source)).affirm();
}
Also used : StringReader(java.io.StringReader) IsText(org.llorllale.cactoos.matchers.IsText) TextOf(org.cactoos.text.TextOf) HasString(org.llorllale.cactoos.matchers.HasString) InputOf(org.cactoos.io.InputOf) Sticky(org.cactoos.io.Sticky) Test(org.junit.jupiter.api.Test)

Example 28 with IsText

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

the class TextOfTest method readsReaderIntoTextWithSmallBuffer.

@Test
void readsReaderIntoTextWithSmallBuffer() {
    final String text = "Hi there! with small buffer";
    new Assertion<>("Can't read text from Reader with a small reading buffer", new TextOf(new StringReader(text), 2, StandardCharsets.UTF_8), new IsText(text)).affirm();
}
Also used : StringReader(java.io.StringReader) IsText(org.llorllale.cactoos.matchers.IsText) HasString(org.llorllale.cactoos.matchers.HasString) Test(org.junit.jupiter.api.Test)

Example 29 with IsText

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

the class TextOfTest method readsFromReaderWithDefaultEncoding.

@Test
void readsFromReaderWithDefaultEncoding() {
    final String source = "hello, друг! with default encoding";
    new Assertion<>("Can't read string with default encoding through a reader", new TextOf(new StringReader(source)), new IsText(source)).affirm();
}
Also used : StringReader(java.io.StringReader) IsText(org.llorllale.cactoos.matchers.IsText) HasString(org.llorllale.cactoos.matchers.HasString) Test(org.junit.jupiter.api.Test)

Example 30 with IsText

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

the class TextOfTest method readsFromReader.

@Test
void readsFromReader() {
    final String source = "hello, друг!";
    new Assertion<>("Can't read string through a reader", new TextOf(new StringReader(source), StandardCharsets.UTF_8), new IsText(source)).affirm();
}
Also used : StringReader(java.io.StringReader) IsText(org.llorllale.cactoos.matchers.IsText) HasString(org.llorllale.cactoos.matchers.HasString) Test(org.junit.jupiter.api.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