Search in sources :

Example 1 with Concatenated

use of org.cactoos.text.Concatenated in project cactoos by yegor256.

the class BytesOfTest method readsLargeInMemoryContent.

@Test
void readsLargeInMemoryContent() throws Exception {
    final int multiplier = 5_000;
    final String body = "1234567890";
    new Assertion<>("must read large content from in-memory Input", new BytesOf(new InputOf(new Concatenated(new HeadOf<>(multiplier, new Endless<>(new TextOf(body)))))).asBytes().length, new IsEqual<>(body.length() * multiplier)).affirm();
}
Also used : Endless(org.cactoos.iterable.Endless) Concatenated(org.cactoos.text.Concatenated) TextOf(org.cactoos.text.TextOf) HasString(org.llorllale.cactoos.matchers.HasString) InputOf(org.cactoos.io.InputOf) IsEqual(org.hamcrest.core.IsEqual) Test(org.junit.jupiter.api.Test)

Example 2 with Concatenated

use of org.cactoos.text.Concatenated 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();
}
Also used : HasContent(org.llorllale.cactoos.matchers.HasContent) Concatenated(org.cactoos.text.Concatenated) File(java.io.File) Test(org.junit.Test)

Example 3 with Concatenated

use of org.cactoos.text.Concatenated 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();
}
Also used : HasContent(org.llorllale.cactoos.matchers.HasContent) Concatenated(org.cactoos.text.Concatenated) File(java.io.File) Test(org.junit.Test)

Aggregations

Concatenated (org.cactoos.text.Concatenated)3 File (java.io.File)2 Test (org.junit.Test)2 HasContent (org.llorllale.cactoos.matchers.HasContent)2 InputOf (org.cactoos.io.InputOf)1 Endless (org.cactoos.iterable.Endless)1 TextOf (org.cactoos.text.TextOf)1 IsEqual (org.hamcrest.core.IsEqual)1 Test (org.junit.jupiter.api.Test)1 HasString (org.llorllale.cactoos.matchers.HasString)1