Skip to content

Commit

Permalink
#1134 polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jul 15, 2022
1 parent 6a94a6c commit eb96bd3
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/test/java/org/takes/http/FtBasicTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.cactoos.io.InputStreamOf;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.mockito.stubbing.Answer;
Expand Down Expand Up @@ -73,13 +72,13 @@ final class FtBasicTest {
@Test
void justWorks() throws Exception {
new FtRemote(
new TkFork(new FkRegex(FtBasicTest.ROOT_PATH, "hello, world!"))
new TkFork(new FkRegex(FtBasicTest.ROOT_PATH, "привет!"))
).exec(
home -> new JdkRequest(home)
.fetch()
.as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.assertBody(Matchers.startsWith("hello"))
.assertBody(Matchers.startsWith("привет"))
);
}

Expand Down Expand Up @@ -109,7 +108,7 @@ void parsesIncomingHttpRequest() throws Exception {
new RqPrint(request).printBody(),
Matchers.containsString("Jeff")
);
return new RsText("works!");
return new RsText("ура!");
};
new FtRemote(take).exec(
home -> new JdkRequest(home)
Expand All @@ -118,6 +117,7 @@ void parsesIncomingHttpRequest() throws Exception {
.fetch()
.as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.assertBody(Matchers.startsWith("ура"))
);
}

Expand All @@ -126,7 +126,6 @@ void parsesIncomingHttpRequest() throws Exception {
* @throws Exception If some problem inside
*/
@Test
@Disabled
void gracefullyHandlesStuckBack() throws Exception {
final Take take = request -> {
final Request req = new RqGreedy(request);
Expand Down Expand Up @@ -163,7 +162,7 @@ void consumesIncomingDataStream() throws Exception {
);
new FtRemote(take).exec(
home -> {
final String body = "here is your data";
final String body = "here is ВАШИ data";
new JdkRequest(home)
.method(RqMethod.POST)
.body().set(body).back()
Expand All @@ -181,7 +180,7 @@ void consumesIncomingDataStream() throws Exception {
*/
@Test
void consumesTwiceInputStreamWithRsText() throws Exception {
final String result = "Hello RsText!";
final String result = "Привет RsText!";
new FtRemote(
new TkFork(
new FkRegex(
Expand Down
37 changes: 37 additions & 0 deletions src/test/java/org/takes/tk/TkGzipTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,22 @@
*/
package org.takes.tk;

import com.jcabi.http.request.JdkRequest;
import com.jcabi.http.response.RestResponse;
import java.io.ByteArrayInputStream;
import java.net.HttpURLConnection;
import java.util.Arrays;
import java.util.zip.GZIPInputStream;
import org.cactoos.text.TextOf;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.llorllale.cactoos.matchers.StartsWith;
import org.takes.http.FtRemote;
import org.takes.rq.RqFake;
import org.takes.rs.RsPrint;
import org.takes.rs.RsText;

/**
* Test case for {@link TkGzip}.
Expand Down Expand Up @@ -81,4 +91,31 @@ void doesntCompressIfNotRequired() throws Exception {
);
}

/**
* Compresses the output over HTTP.
* @throws Exception If there are problems
*/
@Test
@Disabled
void compressesOverHttp() throws Exception {
new FtRemote(new TkGzip(req -> new RsText("Hi, dude!"))).exec(
home -> MatcherAssert.assertThat(
new TextOf(
new GZIPInputStream(
new ByteArrayInputStream(
new JdkRequest(home)
.method("GET")
.header("Accept-Encoding", "gzip")
.fetch()
.as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.binary()
)
)
).asString(),
Matchers.startsWith("Hi, ")
)
);
}

}

1 comment on commit eb96bd3

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on eb96bd3 Jul 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 950-e017cfba disappeared from src/main/java/org/takes/rq/multipart/RqMtBase.java), that's why I closed #1131. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

Please sign in to comment.