Skip to content

Commit

Permalink
yegor256#865 Fix tests as requested by reviewer
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriciofx committed Jan 23, 2019
1 parent ec5d5d5 commit d847792
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.NoSuchElementException;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.hamcrest.core.IsEqual;
import org.junit.Rule;
import org.junit.jupiter.api.Test;
import org.junit.rules.ExpectedException;
Expand Down Expand Up @@ -98,7 +99,7 @@ public void method() {
MatcherAssert.assertThat(
"Can't get the request method",
new HttpServletRequestFake(new RqFake()).getMethod(),
Matchers.equalTo("GET")
new IsEqual<>("GET")
);
}
}
31 changes: 18 additions & 13 deletions src/test/java/org/takes/servlet/RqFromTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@

package org.takes.servlet;

import com.google.common.base.Joiner;
import java.io.IOException;
import org.cactoos.list.ListOf;
import org.cactoos.text.JoinedText;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.hamcrest.core.StringContains;
import org.hamcrest.core.StringStartsWith;
import org.junit.jupiter.api.Test;
import org.takes.rq.RqFake;
import org.takes.rq.RqPrint;
Expand All @@ -37,6 +38,7 @@
* Test case for {@link RqFrom}.
*
* @since 1.15
* @checkstyle ClassDataAbstractionCouplingCheck (500 lines)
*/
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
public final class RqFromTest {
Expand All @@ -51,7 +53,7 @@ public void method() throws IOException {
)
)
).printHead(),
Matchers.startsWith("GET /")
new StringStartsWith("GET /")
);
}

Expand All @@ -72,14 +74,15 @@ public void header() throws IOException {
)
)
).printHead(),
Matchers.startsWith(
Joiner.on("\r\n").join(
new StringStartsWith(
new JoinedText(
"\r\n",
"GET /a-test",
"Host: localhost",
"foo: bar",
"X-Takes-LocalAddress: 127.0.0.1",
"X-Takes-RemoteAddress: 127.0.0.1"
)
).asString()
)
);
}
Expand All @@ -101,13 +104,14 @@ public void hostInHeader() throws IOException {
)
)
).printHead(),
Matchers.startsWith(
Joiner.on("\r\n").join(
new StringStartsWith(
new JoinedText(
"\r\n",
"GET /one-more-test",
"host: www.thesite.com",
"X-Takes-LocalAddress: 127.0.0.1",
"X-Takes-RemoteAddress: 127.0.0.1"
)
).asString()
)
);
}
Expand All @@ -129,13 +133,14 @@ public void hostAndPortInHeader() throws IOException {
)
)
).printHead(),
Matchers.startsWith(
Joiner.on("\r\n").join(
new StringStartsWith(
new JoinedText(
"\r\n",
"GET /b-test",
"host: 192.168.0.1:12345",
"X-Takes-LocalAddress: 127.0.0.1",
"X-Takes-RemoteAddress: 127.0.0.1"
)
).asString()
)
);
}
Expand All @@ -155,7 +160,7 @@ public void body() throws IOException {
)
)
).printBody(),
Matchers.containsString(content)
new StringContains(content)
);
}
}

0 comments on commit d847792

Please sign in to comment.