Skip to content

Commit

Permalink
Refactored AppendToTest (#939)
Browse files Browse the repository at this point in the history
  • Loading branch information
igor committed Jan 27, 2019
1 parent 43b4f6d commit ccc8b4c
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/test/java/org/cactoos/io/AppendToTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import org.cactoos.text.FormattedText;
import org.cactoos.text.JoinedText;
import org.cactoos.text.RandomText;
import org.cactoos.text.TextOf;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.llorllale.cactoos.matchers.Assertion;
import org.llorllale.cactoos.matchers.TextIs;
import org.llorllale.cactoos.matchers.InputHasContent;
import org.llorllale.cactoos.matchers.Throws;

/**
Expand Down Expand Up @@ -84,8 +84,8 @@ public void appendsToFile() throws Exception {
new AppendTo(source).stream().write(second.getBytes());
new Assertion<>(
"Does not contain expected text",
() -> new TextOf(source),
new TextIs(new JoinedText("", first, second))
() -> new InputOf(source),
new InputHasContent(new JoinedText("", first, second))
).affirm();
}

Expand All @@ -96,14 +96,18 @@ public void appendsToFile() throws Exception {
@Test
public void appendsUnicodeToFile() throws Exception {
final File source = this.folder.newFile();
final String first = "\\u0026\\u2022";
new OutputTo(source).stream().write(first.getBytes());
final String second = "\\u25E6";
new AppendTo(source).stream().write(second.getBytes());
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 TextOf(source),
new TextIs(new JoinedText("", first, second))
() -> new InputOf(source),
new InputHasContent(new JoinedText("", first, second))
).affirm();
}
}

0 comments on commit ccc8b4c

Please sign in to comment.