Skip to content

Commit d09c484

Browse files
committed
#1134 polishing
1 parent eb96bd3 commit d09c484

File tree

5 files changed

+40
-10
lines changed

5 files changed

+40
-10
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ SOFTWARE.
116116
https://github.com/yegor256/takes/pull/886#issuecomment-446030223
117117
for details.
118118
-->
119-
<version>0.50.1</version>
119+
<version>0.51.0</version>
120120
</dependency>
121121
<dependency>
122122
<groupId>xml-apis</groupId>

src/main/java/org/takes/facets/auth/PsBasic.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
import java.util.regex.Pattern;
3636
import javax.xml.bind.DatatypeConverter;
3737
import lombok.EqualsAndHashCode;
38+
import org.cactoos.text.IoCheckedText;
3839
import org.cactoos.text.TextOf;
3940
import org.cactoos.text.Trimmed;
40-
import org.cactoos.text.UncheckedText;
4141
import org.takes.Request;
4242
import org.takes.Response;
4343
import org.takes.facets.flash.RsFlash;
@@ -103,7 +103,7 @@ public Opt<Identity> enter(final Request request) throws IOException {
103103
new RqHref.Base(request).href()
104104
);
105105
}
106-
final String decoded = new UncheckedText(
106+
final String decoded = new IoCheckedText(
107107
new Trimmed(
108108
new TextOf(
109109
DatatypeConverter.parseBase64Binary(

src/main/java/org/takes/rq/RqPrint.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
import org.cactoos.io.OutputTo;
3434
import org.cactoos.io.TeeInput;
3535
import org.cactoos.io.WriterTo;
36+
import org.cactoos.scalar.IoChecked;
3637
import org.cactoos.scalar.LengthOf;
37-
import org.cactoos.scalar.Unchecked;
3838
import org.cactoos.text.Sticky;
3939
import org.cactoos.text.TextOf;
4040
import org.takes.Request;
@@ -88,9 +88,10 @@ public String print() throws IOException {
8888
/**
8989
* Print it all.
9090
* @param output Output stream
91+
* @throws IOException If fails
9192
*/
92-
public void print(final OutputStream output) {
93-
new Unchecked<>(
93+
public void print(final OutputStream output) throws IOException {
94+
new IoChecked<>(
9495
new LengthOf(new TeeInput(this.text, new OutputTo(output)))
9596
).value();
9697
}

src/main/java/org/takes/rq/RqRequestLine.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
import java.util.regex.Matcher;
2929
import java.util.regex.Pattern;
3030
import lombok.EqualsAndHashCode;
31+
import org.cactoos.text.IoCheckedText;
3132
import org.cactoos.text.TextOf;
3233
import org.cactoos.text.Trimmed;
33-
import org.cactoos.text.UncheckedText;
3434
import org.takes.HttpException;
3535
import org.takes.Request;
3636

@@ -236,8 +236,10 @@ private static String validated(final String line)
236236
* @param value Token value
237237
* @param token Token
238238
* @return Trimmed token value
239+
* @throws IOException If fails
239240
*/
240-
private static String trimmed(final String value, final RqRequestLine.Base.Token token) {
241+
private static String trimmed(final String value,
242+
final RqRequestLine.Base.Token token) throws IOException {
241243
if (value == null) {
242244
throw new IllegalArgumentException(
243245
String.format(
@@ -246,7 +248,7 @@ private static String trimmed(final String value, final RqRequestLine.Base.Token
246248
)
247249
);
248250
}
249-
return new UncheckedText(
251+
return new IoCheckedText(
250252
new Trimmed(new TextOf(value))
251253
).asString();
252254
}

src/test/java/org/takes/tk/TkGzipTest.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
/**
4444
* Test case for {@link TkGzip}.
4545
* @since 0.17
46+
* @checkstyle ClassDataAbstractionCouplingCheck (500 lines)
4647
*/
4748
final class TkGzipTest {
4849

@@ -91,6 +92,33 @@ void doesntCompressIfNotRequired() throws Exception {
9192
);
9293
}
9394

95+
/**
96+
* Compresses the output over HTTP.
97+
* @throws Exception If there are problems
98+
*/
99+
@Test
100+
void returnsExactlyGzipBody() throws Exception {
101+
final String body = "Halo, Siñor!"
102+
new FtRemote(new TkGzip(req -> new RsText("Hi, dude!"))).exec(
103+
home -> MatcherAssert.assertThat(
104+
new TextOf(
105+
new GZIPInputStream(
106+
new ByteArrayInputStream(
107+
new JdkRequest(home)
108+
.method("GET")
109+
.header("Accept-Encoding", "gzip")
110+
.fetch()
111+
.as(RestResponse.class)
112+
.assertStatus(HttpURLConnection.HTTP_OK)
113+
.binary()
114+
)
115+
)
116+
).asString(),
117+
Matchers.startsWith("Hi, ")
118+
)
119+
);
120+
}
121+
94122
/**
95123
* Compresses the output over HTTP.
96124
* @throws Exception If there are problems
@@ -117,5 +145,4 @@ void compressesOverHttp() throws Exception {
117145
)
118146
);
119147
}
120-
121148
}

0 commit comments

Comments
 (0)