use of org.llorllale.cactoos.matchers.HasContent in project cactoos by yegor256.
the class TeeInputFromUrlTest method copiesFromUrlToFile.
@Test
public void copiesFromUrlToFile() throws Exception {
final String message = "Hello, товарищ file #1 äÄ üÜ öÖ and ß";
final File input = this.folder.newFile();
Files.write(input.toPath(), message.getBytes(StandardCharsets.UTF_8));
final File output = this.folder.newFile();
new LengthOf(new TeeInput(input.toURI().toURL(), output)).value();
new Assertion<>("Must copy from URL to file.", new InputOf(output), new HasContent(message)).affirm();
}
use of org.llorllale.cactoos.matchers.HasContent in project cactoos by yegor256.
the class TeeReaderTest method testTeeReader.
@Test
void testTeeReader() throws IOException {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final String content = "Hello, товарищ!";
final Reader reader = new TeeReader(new ReaderOf(content), new WriterTo(baos));
int done = 0;
while (done >= 0) {
done = reader.read();
}
reader.close();
new Assertion<>("Must read content", new InputOf(new ReaderOf(baos.toByteArray())), new HasContent(content)).affirm();
}
use of org.llorllale.cactoos.matchers.HasContent in project cactoos by yegor256.
the class WriterAsOutputStreamTest method writesToByteArray.
@Test
public void writesToByteArray() {
final String content = "Hello, товарищ! How are you?";
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
new Assertion<>("Can't copy Input to Writer", new TeeInput(new InputOf(content), new OutputTo(new WriterAsOutputStream(new OutputStreamWriter(baos, StandardCharsets.UTF_8), StandardCharsets.UTF_8, // @checkstyle MagicNumber (1 line)
13))), new HasContent(new TextOf(baos::toByteArray, StandardCharsets.UTF_8))).affirm();
}
use of org.llorllale.cactoos.matchers.HasContent in project cactoos by yegor256.
the class TeeInputFromCharSequenceTest method copiesFromCharSequenceWithCharsetToFile.
@Test
public void copiesFromCharSequenceWithCharsetToFile() throws Exception {
final String input = "Hello, товарищ file #2 äÄ üÜ öÖ and ß";
final File output = this.folder.newFile();
new LengthOf(new TeeInput(input, output, StandardCharsets.UTF_8)).value();
new Assertion<>("char sequence must be copied to the file with UTF_8 charset", new InputOf(output), new HasContent(input)).affirm();
}
use of org.llorllale.cactoos.matchers.HasContent in project cactoos by yegor256.
the class TeeInputFromCharSequenceTest method copiesFromCharSequenceWithCharsetByNameToPath.
@Test
public void copiesFromCharSequenceWithCharsetByNameToPath() throws Exception {
final String input = "Hello, товарищ path #3 äÄ üÜ öÖ and ß";
final File output = this.folder.newFile();
new LengthOf(new TeeInput(input, output.toPath(), StandardCharsets.UTF_8.name())).value();
new Assertion<>("char sequence must be copied to the path with UTF_8 charset's name", new InputOf(output), new HasContent(input)).affirm();
}
Aggregations