Skip to content

Commit

Permalink
#1517: fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jan 10, 2021
1 parent bafb969 commit bc60ff8
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions src/test/java/org/cactoos/io/ResourceOfTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import java.io.IOException;
import java.util.Arrays;
import org.cactoos.Text;
import org.cactoos.text.FormattedText;
import org.cactoos.text.TextOf;
import org.hamcrest.Matchers;
Expand Down Expand Up @@ -64,30 +65,20 @@ public void readsBinaryResource() throws Exception {
}

@Test
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
public void readsTextResource() throws Exception {
new Assertion<>(
"Can't read a text resource from classpath",
new TextOf(
new ResourceOf(
"org/cactoos/large-text.txt"
)
),
"Must read a text resource from classpath",
ResourceOfTest.large(),
new EndsWith("est laborum.\n")
).affirm();
}

@Test
public void readsTextResourceThroughClassloader() throws Exception {
new Assertion<>(
"Can't read a text resource from classloader",
new TextOf(
new ResourceOf(
"org/cactoos/large-text.txt",
ResourceOfTest.class
)
).asString(),
Matchers.endsWith(" laborum.\n")
"Must read a text resource from classloader",
ResourceOfTest.large(),
new EndsWith(" laborum.\n")
).affirm();
}

Expand Down Expand Up @@ -143,4 +134,17 @@ public void acceptsTextsAsResourceNameAndFallback() throws Exception {
).affirm();
}

/**
* Large text resource.
* @return The content of the large resource
*/
private static Text large() {
return new TextOf(
new ResourceOf(
"org/cactoos/large-text.txt",
ResourceOfTest.class
)
);
}

}

0 comments on commit bc60ff8

Please sign in to comment.