use of org.llorllale.cactoos.matchers.IsText in project cactoos by yegor256.
the class InputStreamOfTest method readsBytesArray.
@Test
public void readsBytesArray() throws Exception {
final String content = "Bytes array content";
final byte[] bytes = new BytesOf(content).asBytes();
new Assertion<>("Must read from byte array", new TextOf(new InputStreamOf(bytes)), new IsText(content)).affirm();
}
use of org.llorllale.cactoos.matchers.IsText in project cactoos by yegor256.
the class TeeOutputTest method copiesWithFile.
@Test
public void copiesWithFile() throws Exception {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final File file = this.folder.newFile();
new Assertion<>("Must copy Output with file", new TextOf(new TeeInput(new InputOf("Hello, товарищ! with file"), new TeeOutput(new OutputTo(baos), file))), new IsText(new TextOf(file.toPath()))).affirm();
}
use of org.llorllale.cactoos.matchers.IsText in project cactoos by yegor256.
the class HeadInputStreamTest method testSkippingMoreThanTotal.
@Test
void testSkippingMoreThanTotal() throws Exception {
final HeadInputStream stream = new HeadInputStream(new InputOf("testSkippingMoreThanTotal").stream(), 5);
final long skipped = stream.skip(7L);
new Assertion<>("Incorrect number of bytes skipped", skipped, new IsEqual<>(5L)).affirm();
final String input = new TextOf(stream).asString();
new Assertion<>("The result text wasn't empty", new TextOf(input), new IsText("")).affirm();
}
use of org.llorllale.cactoos.matchers.IsText in project cactoos by yegor256.
the class InputStreamOfTest method readsFromTextWithCharset.
@Test
public void readsFromTextWithCharset() throws Exception {
final File file = this.folder.newFile("readTextWithCharset.txt-5");
final String content = "Content for reading text with charset";
new LengthOf(new TeeInput(content, file)).value();
new Assertion<>("Must read from text with charset", new TextOf(new InputStreamOf(new TextOf(file), StandardCharsets.UTF_8.name())), new IsText(content)).affirm();
}
use of org.llorllale.cactoos.matchers.IsText in project cactoos by yegor256.
the class InputStreamOfTest method readsFromUri.
@Test
public void readsFromUri() throws Exception {
final String content = "Content for reading through URI";
final File file = this.folder.newFile("readFromUri.txt-3");
new LengthOf(new TeeInput(content, file)).value();
new Assertion<>("Must read from URI", new TextOf(new InputStreamOf(file.toURI())), new IsText(content)).affirm();
}
Aggregations