use of org.llorllale.cactoos.matchers.HasContent in project cactoos by yegor256.
the class AppendToTest method appendsUnicodeToFile.
/**
* Ensures that AppendTo is appending unicode text to a given file.
* @throws Exception if fails
*/
@Test
public void appendsUnicodeToFile() throws Exception {
final File source = this.folder.newFile();
final String first = "Hello, товарищ output #3 äÄ ";
new OutputTo(source).stream().write(first.getBytes(StandardCharsets.UTF_8));
final String second = "#4 äÄ üÜ öÖ and ß";
new AppendTo(source).stream().write(second.getBytes(StandardCharsets.UTF_8));
new Assertion<>("Can't find expected unicode text content", new InputOf(source), new HasContent(new Concatenated(first, second))).affirm();
}
use of org.llorllale.cactoos.matchers.HasContent in project cactoos by yegor256.
the class AppendToTest method appendsToFile.
/**
* Ensures that AppendTo is appending to a given file.
* @throws Exception if fails
*/
@Test
public void appendsToFile() throws Exception {
final File source = this.folder.newFile();
final String first = "abdcd";
new OutputTo(source).stream().write(first.getBytes());
final String second = "efgh";
new AppendTo(source).stream().write(second.getBytes());
new Assertion<>("Does not contain expected text", new InputOf(source), new HasContent(new Concatenated(first, second))).affirm();
}
use of org.llorllale.cactoos.matchers.HasContent in project cactoos by yegor256.
the class OutputToTest method writesIntoWriter.
@Test
public void writesIntoWriter() throws Exception {
final String txt = "Hello, writer!";
final StringWriter output = new StringWriter();
new LengthOf(new TeeInput(txt, new OutputTo(output))).value();
new Assertion<>("Must write into writer", new InputOf(output.getBuffer()), new HasContent(txt)).affirm();
}
use of org.llorllale.cactoos.matchers.HasContent in project cactoos by yegor256.
the class OutputToTest method writesIntoWriterWithDecoderAndSize.
@Test
public void writesIntoWriterWithDecoderAndSize() throws Exception {
final String txt = "Hello, writer with decoder and size!";
final StringWriter output = new StringWriter();
new LengthOf(new TeeInput(txt, new OutputTo(output, StandardCharsets.UTF_8.newDecoder(), 1))).value();
new Assertion<>("Must write into writer with decoder and size", new InputOf(output.getBuffer()), new HasContent(txt)).affirm();
}
use of org.llorllale.cactoos.matchers.HasContent in project cactoos by yegor256.
the class OutputToTest method writesIntoWriterWithSize.
@Test
public void writesIntoWriterWithSize() throws Exception {
final String txt = "Hello, writer with size!";
final StringWriter output = new StringWriter();
new LengthOf(new TeeInput(txt, new OutputTo(output, 1))).value();
new Assertion<>("Must write into writer with size", new InputOf(output.getBuffer()), new HasContent(txt)).affirm();
}
Aggregations