Skip to content

Commit

Permalink
(#42) HtHead can be broken. (tests to use Assertion)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyakharlamov committed Jan 21, 2019
1 parent 8915ec4 commit 7858809
Showing 1 changed file with 42 additions and 46 deletions.
88 changes: 42 additions & 46 deletions src/test/java/org/cactoos/http/HtHeadTest.java
Expand Up @@ -54,20 +54,19 @@ public final class HtHeadTest {
public void takesHeadOutOfHttpResponse() throws IOException {
new Assertion<>(
"Header does not have 'text/plain'",
() ->
new TextOf(
new HtHead(
new InputOf(
new JoinedText(
"\r\n",
"HTTP/1.1 200 OK",
"Content-type: text/plain",
"",
"Hello, dude!"
)
() -> new TextOf(
new HtHead(
new InputOf(
new JoinedText(
"\r\n",
"HTTP/1.1 200 OK",
"Content-type: text/plain",
"",
"Hello, dude!"
)
)
),
)
),
new EndsWith("text/plain")
).affirm();
}
Expand All @@ -76,19 +75,18 @@ public void takesHeadOutOfHttpResponse() throws IOException {
public void emptyHeadOfHttpResponse() throws IOException {
new Assertion<>(
"Text does not have an empty string",
() ->
new TextOf(
new HtHead(
new InputOf(
new JoinedText(
"\r\n",
"",
"",
"Body"
)
() -> new TextOf(
new HtHead(
new InputOf(
new JoinedText(
"\r\n",
"",
"",
"Body"
)
)
),
)
),
new TextHasString("")
).affirm();
}
Expand All @@ -100,20 +98,19 @@ public void largeText() throws IOException {
new Random().nextBytes(bytes);
new Assertion<>(
"Header does not have text/plain header",
() ->
new TextOf(
new HtHead(
new InputOf(
new JoinedText(
"\r\n",
"HTTP/1.1 200 OK",
"Content-type: text/plain",
"",
new TextOf(new BytesOf(bytes)).asString()
)
() -> new TextOf(
new HtHead(
new InputOf(
new JoinedText(
"\r\n",
"HTTP/1.1 200 OK",
"Content-type: text/plain",
"",
new TextOf(new BytesOf(bytes)).asString()
)
)
),
)
),
new EndsWith("text/plain")
).affirm();
}
Expand Down Expand Up @@ -145,19 +142,18 @@ public void edgeOfTheBlockTearing() throws IOException {
).affirm();
new Assertion<>(
String.format("Edge of the block tearing for size: %s", size),
() ->
new TextOf(
new HtHead(
new InputOf(
new JoinedText(
"\r\n",
block.asString(),
"",
"body here"
)
() -> new TextOf(
new HtHead(
new InputOf(
new JoinedText(
"\r\n",
block.asString(),
"",
"body here"
)
)
),
)
),
Matchers.allOf(
new StartsWith("HTTP"),
new TextHasString("OK\r\nReferer"),
Expand Down

0 comments on commit 7858809

Please sign in to comment.