use of org.llorllale.cactoos.matchers.IsText in project cactoos by yegor256.
the class InputOfTest method readsStringFromReader.
@Test
void readsStringFromReader() throws Exception {
final String source = "hello, source!";
new Assertion<>("must read string through a reader", new TextOf(new InputOf(new StringReader(source))), new IsText(source)).affirm();
}
use of org.llorllale.cactoos.matchers.IsText in project cactoos by yegor256.
the class InputOfTest method readsEncodedStringFromReader.
@Test
void readsEncodedStringFromReader() throws Exception {
final String source = "hello, друг!";
new Assertion<>("must read encoded string through a reader", new TextOf(new BytesOf(new InputOf(new StringReader(source), StandardCharsets.UTF_8))), new IsText(source)).affirm();
}
use of org.llorllale.cactoos.matchers.IsText in project cactoos by yegor256.
the class GzipInputTest method readFromGzipInput.
@Test
public void readFromGzipInput() throws Exception {
final String content = "Hello!";
final ByteArrayOutputStream out = new ByteArrayOutputStream();
try (Writer writer = new BufferedWriter(new OutputStreamWriter(new GZIPOutputStream(out)))) {
writer.write(content);
}
final byte[] bytes = out.toByteArray();
new Assertion<>("Can't read from a gzip input", new TextOf(new GzipInput(new InputOf(bytes))), new IsText(content)).affirm();
}
use of org.llorllale.cactoos.matchers.IsText in project cactoos by yegor256.
the class InputStreamOfTest method readsFileContent.
@Test
public void readsFileContent() throws Exception {
final File file = this.folder.newFile("readFileContent.txt-2");
final String content = "Content in a file";
new LengthOf(new TeeInput(content, file)).value();
new Assertion<>("Must read from file", new TextOf(new InputStreamOf(file)), new IsText(content)).affirm();
}
use of org.llorllale.cactoos.matchers.IsText in project cactoos by yegor256.
the class InputStreamOfTest method readsFromUrl.
@Test
public void readsFromUrl() throws Exception {
final String content = "Content for reading through URL";
final File file = this.folder.newFile("readFromUrl.txt-4");
new LengthOf(new TeeInput(content, file)).value();
new Assertion<>("Must read from URL", new TextOf(new InputStreamOf(file.toURI().toURL())), new IsText(content)).affirm();
}
Aggregations