Search in sources :

Example 1 with IsText

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

the class TextOfTest method readsEmptyInputStream.

@Test
void readsEmptyInputStream() throws Exception {
    final String content = "";
    final InputStream stream = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8.name()));
    new Assertion<>("Can't read empty input stream", new TextOf(stream), new IsText(content)).affirm();
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) IsText(org.llorllale.cactoos.matchers.IsText) HasString(org.llorllale.cactoos.matchers.HasString) Test(org.junit.jupiter.api.Test)

Example 2 with IsText

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

the class TextOfTest method readsClosedInputStream.

@Test
void readsClosedInputStream() throws Exception {
    final String content = "content";
    final InputStream stream = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8.name()));
    stream.close();
    new Assertion<>("Can't read closed input stream", new TextOf(stream), new IsText(content)).affirm();
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) IsText(org.llorllale.cactoos.matchers.IsText) HasString(org.llorllale.cactoos.matchers.HasString) Test(org.junit.jupiter.api.Test)

Example 3 with IsText

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

the class TextOfTest method readsAnArrayOfBytes.

@Test
void readsAnArrayOfBytes() {
    final byte[] bytes = new byte[] { (byte) 0xCA, (byte) 0xFE };
    new Assertion<>("Can't read array of bytes", new TextOf(bytes), new IsText(new String(bytes, StandardCharsets.UTF_8))).affirm();
}
Also used : IsText(org.llorllale.cactoos.matchers.IsText) HasString(org.llorllale.cactoos.matchers.HasString) Test(org.junit.jupiter.api.Test)

Example 4 with IsText

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

the class TextOfTest method readsMultilineInputStream.

@Test
void readsMultilineInputStream() throws Exception {
    final String content = "line1-\nline2";
    final InputStream stream = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8.name()));
    new Assertion<>("Can't read multiline inputStream", new TextOf(stream), new IsText(content)).affirm();
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) IsText(org.llorllale.cactoos.matchers.IsText) HasString(org.llorllale.cactoos.matchers.HasString) Test(org.junit.jupiter.api.Test)

Example 5 with IsText

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

the class TextOfTest method readsMultilineInputStreamWithCarriageReturn.

@Test
void readsMultilineInputStreamWithCarriageReturn() throws Exception {
    final String content = "line1-\rline2";
    final InputStream stream = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8.name()));
    new Assertion<>("Can't read multiline inputStream with carriage return", new TextOf(stream), new IsText(content)).affirm();
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) 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