From 5f38b61caeee4587a08bded4c005a9e1709bdb43 Mon Sep 17 00:00:00 2001 From: Piotr Kotlicki Date: Fri, 7 Jun 2019 00:17:48 +0200 Subject: [PATCH] #872 Take throws Exception --- README.md | 4 +- .../src/main/java/org/takes/it/fm/App.java | 2 +- src/main/java/org/takes/Take.java | 6 +- src/main/java/org/takes/facets/auth/Pass.java | 9 ++- .../java/org/takes/facets/auth/PsAll.java | 8 +-- .../java/org/takes/facets/auth/PsByFlag.java | 3 +- .../java/org/takes/facets/auth/PsChain.java | 5 +- .../java/org/takes/facets/auth/PsToken.java | 2 +- .../java/org/takes/facets/auth/TkAuth.java | 7 +-- .../java/org/takes/facets/auth/TkSecure.java | 3 +- .../takes/facets/cookies/TkJoinedCookies.java | 7 +-- .../org/takes/facets/fallback/Fallback.java | 5 +- .../org/takes/facets/fallback/FbChain.java | 3 +- .../org/takes/facets/fallback/FbFixed.java | 3 +- .../org/takes/facets/fallback/FbStatus.java | 7 +-- .../org/takes/facets/fallback/FbWrap.java | 3 +- .../org/takes/facets/fallback/TkFallback.java | 59 ++++++++++++------- .../java/org/takes/facets/flash/TkFlash.java | 3 +- .../java/org/takes/facets/fork/FkAgent.java | 2 +- .../org/takes/facets/fork/FkAnonymous.java | 3 +- .../takes/facets/fork/FkAuthenticated.java | 3 +- .../java/org/takes/facets/fork/FkChain.java | 3 +- .../org/takes/facets/fork/FkContentType.java | 2 +- .../java/org/takes/facets/fork/FkFixed.java | 4 +- .../org/takes/facets/fork/FkHitRefresh.java | 2 +- .../java/org/takes/facets/fork/FkHost.java | 3 +- .../java/org/takes/facets/fork/FkMethods.java | 3 +- .../java/org/takes/facets/fork/FkParams.java | 3 +- .../java/org/takes/facets/fork/FkRegex.java | 4 +- .../java/org/takes/facets/fork/FkTypes.java | 2 +- .../java/org/takes/facets/fork/FkWrap.java | 4 +- src/main/java/org/takes/facets/fork/Fork.java | 5 +- .../java/org/takes/facets/fork/RsFork.java | 12 +++- .../java/org/takes/facets/fork/TkFork.java | 3 +- .../java/org/takes/facets/fork/TkRegex.java | 7 +-- .../org/takes/facets/forward/TkForward.java | 2 +- .../org/takes/facets/previous/TkPrevious.java | 3 +- .../java/org/takes/facets/ret/TkReturn.java | 3 +- src/main/java/org/takes/http/FtCli.java | 2 +- src/main/java/org/takes/http/FtRemote.java | 8 +-- src/main/java/org/takes/servlet/SrvTake.java | 4 +- src/main/java/org/takes/tk/TkCors.java | 3 +- src/main/java/org/takes/tk/TkGreedy.java | 3 +- src/main/java/org/takes/tk/TkGzip.java | 3 +- src/main/java/org/takes/tk/TkMeasured.java | 3 +- src/main/java/org/takes/tk/TkOnce.java | 3 +- src/main/java/org/takes/tk/TkProxy.java | 7 +-- src/main/java/org/takes/tk/TkReadAlways.java | 3 +- src/main/java/org/takes/tk/TkRetry.java | 14 +++-- src/main/java/org/takes/tk/TkSlf4j.java | 2 +- src/main/java/org/takes/tk/TkSslOnly.java | 3 +- src/main/java/org/takes/tk/TkVerbose.java | 3 +- src/main/java/org/takes/tk/TkVersioned.java | 3 +- src/main/java/org/takes/tk/TkWithHeader.java | 3 +- src/main/java/org/takes/tk/TkWithHeaders.java | 3 +- src/main/java/org/takes/tk/TkWithType.java | 3 +- src/main/java/org/takes/tk/TkWrap.java | 3 +- .../org/takes/facets/auth/PsByFlagTest.java | 8 +-- .../org/takes/facets/auth/PsChainTest.java | 9 ++- .../org/takes/facets/auth/TkAuthTest.java | 13 ++-- .../org/takes/facets/auth/TkSecureTest.java | 9 ++- .../facets/auth/social/PsGithubTest.java | 12 ++-- .../facets/auth/social/PsLinkedinTest.java | 4 +- .../facets/auth/social/PsTwitterTest.java | 5 +- .../facets/cookies/TkJoinedCookiesTest.java | 5 +- .../takes/facets/fallback/FbChainTest.java | 5 +- .../takes/facets/fallback/TkFallbackTest.java | 15 ++--- .../org/takes/facets/flash/TkFlashTest.java | 5 +- .../org/takes/facets/fork/FkAgentTest.java | 3 +- .../takes/facets/fork/FkAnonymousTest.java | 5 +- .../facets/fork/FkAuthenticatedTest.java | 5 +- .../takes/facets/fork/FkContentTypeTest.java | 20 +++---- .../org/takes/facets/fork/FkHostTest.java | 5 +- .../org/takes/facets/fork/FkMethodsTest.java | 5 +- .../org/takes/facets/fork/FkParamsTest.java | 5 +- .../org/takes/facets/fork/FkRegexTest.java | 9 ++- .../org/takes/facets/fork/FkTypesTest.java | 21 ++++--- .../org/takes/facets/fork/TkConsumesTest.java | 9 ++- .../org/takes/facets/fork/TkForkTest.java | 5 +- .../org/takes/facets/fork/TkMethodsTest.java | 9 ++- .../org/takes/facets/fork/TkProducesTest.java | 9 ++- .../takes/facets/forward/TkForwardTest.java | 8 +-- .../takes/facets/hamcrest/HmRsStatusTest.java | 9 ++- .../takes/facets/previous/TkPreviousTest.java | 5 +- .../org/takes/facets/ret/TkReturnTest.java | 5 +- src/test/java/org/takes/http/BkBasicTest.java | 4 +- src/test/java/org/takes/http/FtBasicTest.java | 8 +-- .../java/org/takes/http/FtRemoteTest.java | 4 +- .../org/takes/rq/multipart/RqMtSmartTest.java | 4 +- .../java/org/takes/tk/TkClasspathTest.java | 9 ++- src/test/java/org/takes/tk/TkFilesTest.java | 9 ++- src/test/java/org/takes/tk/TkGzipTest.java | 9 ++- src/test/java/org/takes/tk/TkHtmlTest.java | 9 ++- .../java/org/takes/tk/TkMeasuredTest.java | 9 ++- src/test/java/org/takes/tk/TkProxyTest.java | 10 ++-- .../java/org/takes/tk/TkRedirectTest.java | 13 ++-- .../java/org/takes/tk/TkSlf4jRemoteTest.java | 4 +- src/test/java/org/takes/tk/TkSlf4jTest.java | 12 ++-- .../org/takes/tk/TkSmartRedirectTest.java | 9 ++- src/test/java/org/takes/tk/TkTextTest.java | 9 ++- src/test/java/org/takes/tk/TkVerboseTest.java | 4 +- .../java/org/takes/tk/TkVersionedTest.java | 5 +- .../java/org/takes/tk/TkWithHeadersTest.java | 5 +- 103 files changed, 302 insertions(+), 349 deletions(-) diff --git a/README.md b/README.md index ef63ea322..9ad264613 100755 --- a/README.md +++ b/README.md @@ -194,7 +194,7 @@ public final class TkApp implements Take { } @Override - public Response act(final Request req) throws IOException { + public Response act(final Request req) throws Exception { return new RsText("Hello servlet!"); } } @@ -349,7 +349,7 @@ new TkFork( "/file/(?[^/]+)", new TkRegex() { @Override - public Response act(final RqRegex request) throws IOException { + public Response act(final RqRegex request) throws Exception { final File file = new File( request.matcher().group("path") ); diff --git a/src/it/file-manager/src/main/java/org/takes/it/fm/App.java b/src/it/file-manager/src/main/java/org/takes/it/fm/App.java index ac61b74ab..224763984 100644 --- a/src/it/file-manager/src/main/java/org/takes/it/fm/App.java +++ b/src/it/file-manager/src/main/java/org/takes/it/fm/App.java @@ -69,7 +69,7 @@ public static void main(final String... args) throws IOException { } @Override - public Response act(final Request request) throws IOException { + public Response act(final Request request) throws Exception { return new TkFork( new FkRegex("/", new TkRedirect("/f")), new FkRegex( diff --git a/src/main/java/org/takes/Take.java b/src/main/java/org/takes/Take.java index 4bb85bb51..2de6d925b 100644 --- a/src/main/java/org/takes/Take.java +++ b/src/main/java/org/takes/Take.java @@ -23,8 +23,6 @@ */ package org.takes; -import java.io.IOException; - /** * Take. * @@ -72,8 +70,8 @@ public interface Take { * Convert request to response. * @param req Request to process * @return Response - * @throws IOException If fails + * @throws Exception If fails */ - Response act(Request req) throws IOException; + Response act(Request req) throws Exception; } diff --git a/src/main/java/org/takes/facets/auth/Pass.java b/src/main/java/org/takes/facets/auth/Pass.java index debc673b9..8b6f809fd 100644 --- a/src/main/java/org/takes/facets/auth/Pass.java +++ b/src/main/java/org/takes/facets/auth/Pass.java @@ -23,7 +23,6 @@ */ package org.takes.facets.auth; -import java.io.IOException; import org.takes.Request; import org.takes.Response; import org.takes.misc.Opt; @@ -41,17 +40,17 @@ public interface Pass { * Authenticate the user by the request. * @param request The request * @return Identity of the user found - * @throws IOException If fails + * @throws Exception If fails */ - Opt enter(Request request) throws IOException; + Opt enter(Request request) throws Exception; /** * Wrap the response with the user. * @param response Response * @param identity Identity * @return New response - * @throws IOException If fails + * @throws Exception If fails */ - Response exit(Response response, Identity identity) throws IOException; + Response exit(Response response, Identity identity) throws Exception; } diff --git a/src/main/java/org/takes/facets/auth/PsAll.java b/src/main/java/org/takes/facets/auth/PsAll.java index 357cdc4dd..60730c167 100644 --- a/src/main/java/org/takes/facets/auth/PsAll.java +++ b/src/main/java/org/takes/facets/auth/PsAll.java @@ -58,7 +58,7 @@ public PsAll(final List passes, final int identity) { } @Override - public Opt enter(final Request request) throws IOException { + public Opt enter(final Request request) throws Exception { final Opt result; if (this.allMatch(request)) { result = this.all.get(this.index).enter(request); @@ -70,7 +70,7 @@ public Opt enter(final Request request) throws IOException { @Override public Response exit(final Response response, final Identity identity) - throws IOException { + throws Exception { if (this.index >= this.all.size()) { throw new IOException( "Index of identity is greater than Pass collection size" @@ -107,9 +107,9 @@ private int validated(final int idx) { * Checks if you can enter every Pass with a request. * @param request Request that is used to enter Passes. * @return True if every request can be entered, false otherwise - * @throws IOException If any of enter attempts fail + * @throws Exception If any of enter attempts fail */ - private boolean allMatch(final Request request) throws IOException { + private boolean allMatch(final Request request) throws Exception { boolean success = true; for (final Pass pass : this.all) { if (!pass.enter(request).has()) { diff --git a/src/main/java/org/takes/facets/auth/PsByFlag.java b/src/main/java/org/takes/facets/auth/PsByFlag.java index 1bd95d497..6d10af022 100644 --- a/src/main/java/org/takes/facets/auth/PsByFlag.java +++ b/src/main/java/org/takes/facets/auth/PsByFlag.java @@ -23,7 +23,6 @@ */ package org.takes.facets.auth; -import java.io.IOException; import java.util.AbstractMap; import java.util.Collections; import java.util.HashMap; @@ -94,7 +93,7 @@ public PsByFlag(final String flg, final Map map) { } @Override - public Opt enter(final Request req) throws IOException { + public Opt enter(final Request req) throws Exception { final Iterator flg = new RqHref.Base(req).href() .param(this.flag).iterator(); Opt user = new Opt.Empty<>(); diff --git a/src/main/java/org/takes/facets/auth/PsChain.java b/src/main/java/org/takes/facets/auth/PsChain.java index 2636f2332..7db3acc84 100644 --- a/src/main/java/org/takes/facets/auth/PsChain.java +++ b/src/main/java/org/takes/facets/auth/PsChain.java @@ -23,7 +23,6 @@ */ package org.takes.facets.auth; -import java.io.IOException; import java.util.Arrays; import lombok.EqualsAndHashCode; import org.takes.Request; @@ -62,7 +61,7 @@ public PsChain(final Iterable list) { } @Override - public Opt enter(final Request req) throws IOException { + public Opt enter(final Request req) throws Exception { Opt user = new Opt.Empty<>(); for (final Pass pass : this.passes) { user = pass.enter(req); @@ -75,7 +74,7 @@ public Opt enter(final Request req) throws IOException { @Override public Response exit(final Response response, - final Identity identity) throws IOException { + final Identity identity) throws Exception { Response res = response; for (final Pass pass : this.passes) { res = pass.exit(res, identity); diff --git a/src/main/java/org/takes/facets/auth/PsToken.java b/src/main/java/org/takes/facets/auth/PsToken.java index 759baf5c9..a03d67ba8 100644 --- a/src/main/java/org/takes/facets/auth/PsToken.java +++ b/src/main/java/org/takes/facets/auth/PsToken.java @@ -161,7 +161,7 @@ public Opt enter(final Request req) throws IOException { @Override public Response exit(final Response res, - final Identity idt) throws IOException { + final Identity idt) throws Exception { final byte[] jwtheader = new Token.Jose( this.signature.bitlength() ).encoded(); diff --git a/src/main/java/org/takes/facets/auth/TkAuth.java b/src/main/java/org/takes/facets/auth/TkAuth.java index 1cc020890..ffd152da4 100644 --- a/src/main/java/org/takes/facets/auth/TkAuth.java +++ b/src/main/java/org/takes/facets/auth/TkAuth.java @@ -23,7 +23,6 @@ */ package org.takes.facets.auth; -import java.io.IOException; import lombok.EqualsAndHashCode; import lombok.ToString; import org.takes.Request; @@ -80,7 +79,7 @@ public TkAuth(final Take take, final Pass pss, final String hdr) { } @Override - public Response act(final Request request) throws IOException { + public Response act(final Request request) throws Exception { final Opt user = this.pass.enter(request); final Response response; if (user.has()) { @@ -96,10 +95,10 @@ public Response act(final Request request) throws IOException { * @param req Request * @param identity Identity * @return Take - * @throws IOException If fails + * @throws Exception If fails */ private Response act(final Request req, final Identity identity) - throws IOException { + throws Exception { Request wrap = new RqWithoutHeader(req, this.header); if (!identity.equals(Identity.ANONYMOUS)) { wrap = new RqWithAuth(identity, this.header, wrap); diff --git a/src/main/java/org/takes/facets/auth/TkSecure.java b/src/main/java/org/takes/facets/auth/TkSecure.java index b40d82e83..6d757ce1f 100644 --- a/src/main/java/org/takes/facets/auth/TkSecure.java +++ b/src/main/java/org/takes/facets/auth/TkSecure.java @@ -23,7 +23,6 @@ */ package org.takes.facets.auth; -import java.io.IOException; import java.util.logging.Level; import lombok.EqualsAndHashCode; import lombok.ToString; @@ -74,7 +73,7 @@ public TkSecure(final Take take, final String location) { } @Override - public Response act(final Request request) throws IOException { + public Response act(final Request request) throws Exception { if (new RqAuth(request).identity().equals(Identity.ANONYMOUS)) { throw new RsForward( new RsFlash("access denied", Level.WARNING), diff --git a/src/main/java/org/takes/facets/cookies/TkJoinedCookies.java b/src/main/java/org/takes/facets/cookies/TkJoinedCookies.java index fbbd74c31..5dd304815 100644 --- a/src/main/java/org/takes/facets/cookies/TkJoinedCookies.java +++ b/src/main/java/org/takes/facets/cookies/TkJoinedCookies.java @@ -23,7 +23,6 @@ */ package org.takes.facets.cookies; -import java.io.IOException; import java.util.regex.Matcher; import java.util.regex.Pattern; import lombok.EqualsAndHashCode; @@ -67,7 +66,7 @@ public TkJoinedCookies(final Take take) { super( new Take() { @Override - public Response act(final Request req) throws IOException { + public Response act(final Request req) throws Exception { return TkJoinedCookies.join(take.act(req)); } } @@ -78,9 +77,9 @@ public Response act(final Request req) throws IOException { * Join them. * @param response The response * @return New response - * @throws IOException If fails + * @throws Exception If fails */ - private static Response join(final Response response) throws IOException { + private static Response join(final Response response) throws Exception { final StringBuilder cookies = new StringBuilder(); for (final String header : response.head()) { final Matcher matcher = diff --git a/src/main/java/org/takes/facets/fallback/Fallback.java b/src/main/java/org/takes/facets/fallback/Fallback.java index 064830fdc..9a454f882 100644 --- a/src/main/java/org/takes/facets/fallback/Fallback.java +++ b/src/main/java/org/takes/facets/fallback/Fallback.java @@ -23,7 +23,6 @@ */ package org.takes.facets.fallback; -import java.io.IOException; import org.takes.Response; import org.takes.misc.Opt; @@ -41,8 +40,8 @@ public interface Fallback { * Dispatch this request and either swallow it or ignore. * @param req Request * @return An iterator of responses or an empty iterator - * @throws IOException If fails + * @throws Exception If fails */ - Opt route(RqFallback req) throws IOException; + Opt route(RqFallback req) throws Exception; } diff --git a/src/main/java/org/takes/facets/fallback/FbChain.java b/src/main/java/org/takes/facets/fallback/FbChain.java index 87bba9e96..4d6e56ef8 100644 --- a/src/main/java/org/takes/facets/fallback/FbChain.java +++ b/src/main/java/org/takes/facets/fallback/FbChain.java @@ -23,7 +23,6 @@ */ package org.takes.facets.fallback; -import java.io.IOException; import java.util.Arrays; import lombok.EqualsAndHashCode; import org.takes.Response; @@ -63,7 +62,7 @@ public FbChain(final Iterable fallbacks) { new Fallback() { @Override public Opt route(final RqFallback req) - throws IOException { + throws Exception { Opt rsp = new Opt.Empty<>(); for (final Fallback fbk : fallbacks) { final Opt opt = fbk.route(req); diff --git a/src/main/java/org/takes/facets/fallback/FbFixed.java b/src/main/java/org/takes/facets/fallback/FbFixed.java index e819f056f..5a77452d4 100644 --- a/src/main/java/org/takes/facets/fallback/FbFixed.java +++ b/src/main/java/org/takes/facets/fallback/FbFixed.java @@ -23,7 +23,6 @@ */ package org.takes.facets.fallback; -import java.io.IOException; import lombok.EqualsAndHashCode; import org.takes.Response; import org.takes.Take; @@ -58,7 +57,7 @@ public FbFixed(final Take take) { new Fallback() { @Override public Opt route(final RqFallback req) - throws IOException { + throws Exception { return new Opt.Single<>(take.act(req)); } } diff --git a/src/main/java/org/takes/facets/fallback/FbStatus.java b/src/main/java/org/takes/facets/fallback/FbStatus.java index 156af42f6..8c7094ef9 100644 --- a/src/main/java/org/takes/facets/fallback/FbStatus.java +++ b/src/main/java/org/takes/facets/fallback/FbStatus.java @@ -23,7 +23,6 @@ */ package org.takes.facets.fallback; -import java.io.IOException; import java.util.regex.Pattern; import lombok.EqualsAndHashCode; import org.cactoos.iterable.Filtered; @@ -71,7 +70,7 @@ public FbStatus(final Iterable check) { this(check, new Fallback() { @Override public Opt route(final RqFallback req) - throws IOException { + throws Exception { final Response res = new RsWithStatus(req.code()); return new Opt.Single<>( new RsWithType( @@ -111,7 +110,7 @@ public FbStatus(final int code, final Take take) { new Fallback() { @Override public Opt route(final RqFallback req) - throws IOException { + throws Exception { return new Opt.Single<>(take.act(req)); } } @@ -177,7 +176,7 @@ public FbStatus(final Iterable check, new Fallback() { @Override public Opt route(final RqFallback req) - throws IOException { + throws Exception { Opt rsp = new Opt.Empty<>(); if (new ListOf<>(check).contains(req.code())) { rsp = fallback.get().route(req); diff --git a/src/main/java/org/takes/facets/fallback/FbWrap.java b/src/main/java/org/takes/facets/fallback/FbWrap.java index 182b91f06..b7ada0804 100644 --- a/src/main/java/org/takes/facets/fallback/FbWrap.java +++ b/src/main/java/org/takes/facets/fallback/FbWrap.java @@ -23,7 +23,6 @@ */ package org.takes.facets.fallback; -import java.io.IOException; import lombok.EqualsAndHashCode; import org.takes.Response; import org.takes.misc.Opt; @@ -53,7 +52,7 @@ public FbWrap(final Fallback fbk) { @Override public final Opt route(final RqFallback req) - throws IOException { + throws Exception { return this.origin.route(req); } } diff --git a/src/main/java/org/takes/facets/fallback/TkFallback.java b/src/main/java/org/takes/facets/fallback/TkFallback.java index 8bb0cb119..f80d33eaa 100644 --- a/src/main/java/org/takes/facets/fallback/TkFallback.java +++ b/src/main/java/org/takes/facets/fallback/TkFallback.java @@ -60,7 +60,7 @@ public TkFallback(final Take take, final Fallback fbk) { super( new Take() { @Override - public Response act(final Request req) throws IOException { + public Response act(final Request req) throws Exception { return TkFallback.route(take, fbk, req); } } @@ -73,10 +73,10 @@ public Response act(final Request req) throws IOException { * @param fbk Fallback * @param req Request * @return Response - * @throws IOException If fails + * @throws Exception If fails */ private static Response route(final Take take, final Fallback fbk, - final Request req) throws IOException { + final Request req) throws Exception { final long start = System.currentTimeMillis(); Response res; try { @@ -146,6 +146,7 @@ private static RqFallback.Fake fallback(final Request req, final long start, * @param req Request * @return Response */ + @SuppressWarnings("PMD.AvoidCatchingGenericException") private static Response wrap(final Response res, final Fallback fbk, final Request req) { // @checkstyle AnonInnerLengthCheck (50 lines) @@ -157,16 +158,24 @@ public Iterable head() throws IOException { try { head = res.head(); } catch (final HttpException ex) { - head = fbk.route( - TkFallback.fallback(req, start, ex, ex.code()) - ).get().head(); + try { + head = fbk.route( + TkFallback.fallback(req, start, ex, ex.code()) + ).get().head(); + } catch (final Exception exx) { + throw (IOException) new IOException(exx).initCause(ex); + } } catch (final Throwable ex) { - head = fbk.route( - TkFallback.fallback( - req, start, ex, - HttpURLConnection.HTTP_INTERNAL_ERROR - ) - ).get().head(); + try { + head = fbk.route( + TkFallback.fallback( + req, start, ex, + HttpURLConnection.HTTP_INTERNAL_ERROR + ) + ).get().head(); + } catch (final Exception exx) { + throw (IOException) new IOException(exx).initCause(ex); + } } return head; } @@ -178,16 +187,24 @@ public InputStream body() throws IOException { try { body = res.body(); } catch (final HttpException ex) { - body = fbk.route( - TkFallback.fallback(req, start, ex, ex.code()) - ).get().body(); + try { + body = fbk.route( + TkFallback.fallback(req, start, ex, ex.code()) + ).get().body(); + } catch (final Exception exx) { + throw (IOException) new IOException(exx).initCause(ex); + } } catch (final Throwable ex) { - body = fbk.route( - TkFallback.fallback( - req, start, ex, - HttpURLConnection.HTTP_INTERNAL_ERROR - ) - ).get().body(); + try { + body = fbk.route( + TkFallback.fallback( + req, start, ex, + HttpURLConnection.HTTP_INTERNAL_ERROR + ) + ).get().body(); + } catch (final Exception exx) { + throw (IOException) new IOException(exx).initCause(ex); + } } return body; } diff --git a/src/main/java/org/takes/facets/flash/TkFlash.java b/src/main/java/org/takes/facets/flash/TkFlash.java index 5d3200b28..801d4be1f 100644 --- a/src/main/java/org/takes/facets/flash/TkFlash.java +++ b/src/main/java/org/takes/facets/flash/TkFlash.java @@ -23,7 +23,6 @@ */ package org.takes.facets.flash; -import java.io.IOException; import java.util.Iterator; import lombok.EqualsAndHashCode; import lombok.ToString; @@ -90,7 +89,7 @@ public TkFlash(final Take take, final String name) { } @Override - public Response act(final Request request) throws IOException { + public Response act(final Request request) throws Exception { final RqCookies cookies = new RqCookies.Base(request); final Iterator values = cookies.cookie(this.cookie).iterator(); final Response response; diff --git a/src/main/java/org/takes/facets/fork/FkAgent.java b/src/main/java/org/takes/facets/fork/FkAgent.java index 59826a255..113a4a9e2 100644 --- a/src/main/java/org/takes/facets/fork/FkAgent.java +++ b/src/main/java/org/takes/facets/fork/FkAgent.java @@ -74,7 +74,7 @@ public FkAgent(final Take take, final AgentMatch match) { @Override @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops") - public Opt route(final Request req) throws IOException { + public Opt route(final Request req) throws Exception { final List tokens = FkAgent.tokens(req); Opt resp = new Opt.Empty<>(); for (final String token : tokens) { diff --git a/src/main/java/org/takes/facets/fork/FkAnonymous.java b/src/main/java/org/takes/facets/fork/FkAnonymous.java index cbe79480b..09debc027 100644 --- a/src/main/java/org/takes/facets/fork/FkAnonymous.java +++ b/src/main/java/org/takes/facets/fork/FkAnonymous.java @@ -23,7 +23,6 @@ */ package org.takes.facets.fork; -import java.io.IOException; import lombok.EqualsAndHashCode; import org.takes.Request; import org.takes.Response; @@ -88,7 +87,7 @@ public FkAnonymous(final Scalar tke) { } @Override - public Opt route(final Request req) throws IOException { + public Opt route(final Request req) throws Exception { final Identity identity = new RqAuth(req).identity(); final Opt resp; if (identity.equals(Identity.ANONYMOUS)) { diff --git a/src/main/java/org/takes/facets/fork/FkAuthenticated.java b/src/main/java/org/takes/facets/fork/FkAuthenticated.java index dd1fa0013..33e4316c8 100644 --- a/src/main/java/org/takes/facets/fork/FkAuthenticated.java +++ b/src/main/java/org/takes/facets/fork/FkAuthenticated.java @@ -23,7 +23,6 @@ */ package org.takes.facets.fork; -import java.io.IOException; import lombok.EqualsAndHashCode; import org.takes.Request; import org.takes.Response; @@ -88,7 +87,7 @@ public FkAuthenticated(final Scalar tke) { } @Override - public Opt route(final Request req) throws IOException { + public Opt route(final Request req) throws Exception { final Identity identity = new RqAuth(req).identity(); final Opt resp; if (identity.equals(Identity.ANONYMOUS)) { diff --git a/src/main/java/org/takes/facets/fork/FkChain.java b/src/main/java/org/takes/facets/fork/FkChain.java index 4c2921cbd..b499d859b 100644 --- a/src/main/java/org/takes/facets/fork/FkChain.java +++ b/src/main/java/org/takes/facets/fork/FkChain.java @@ -23,7 +23,6 @@ */ package org.takes.facets.fork; -import java.io.IOException; import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -67,7 +66,7 @@ public FkChain(final Collection forks) { } @Override - public Opt route(final Request request) throws IOException { + public Opt route(final Request request) throws Exception { Opt response = new Opt.Empty<>(); for (final Fork fork : this.forks) { final Opt current = fork.route(request); diff --git a/src/main/java/org/takes/facets/fork/FkContentType.java b/src/main/java/org/takes/facets/fork/FkContentType.java index bd0e62973..7824b0df6 100644 --- a/src/main/java/org/takes/facets/fork/FkContentType.java +++ b/src/main/java/org/takes/facets/fork/FkContentType.java @@ -73,7 +73,7 @@ public FkContentType(final String atype, final Take take) { } @Override - public Opt route(final Request req) throws IOException { + public Opt route(final Request req) throws Exception { final Opt resp; if (FkContentType.getType(req).contains(this.type)) { resp = new Opt.Single<>(this.take.act(req)); diff --git a/src/main/java/org/takes/facets/fork/FkFixed.java b/src/main/java/org/takes/facets/fork/FkFixed.java index 17a883cc1..f21fe535e 100644 --- a/src/main/java/org/takes/facets/fork/FkFixed.java +++ b/src/main/java/org/takes/facets/fork/FkFixed.java @@ -23,7 +23,6 @@ */ package org.takes.facets.fork; -import java.io.IOException; import lombok.EqualsAndHashCode; import org.takes.Request; import org.takes.Response; @@ -49,8 +48,7 @@ public FkFixed(final Take take) { super( new Fork() { @Override - public Opt route(final Request req) - throws IOException { + public Opt route(final Request req) throws Exception { return new Opt.Single<>(take.act(req)); } } diff --git a/src/main/java/org/takes/facets/fork/FkHitRefresh.java b/src/main/java/org/takes/facets/fork/FkHitRefresh.java index 2cc122949..6421ccd5e 100644 --- a/src/main/java/org/takes/facets/fork/FkHitRefresh.java +++ b/src/main/java/org/takes/facets/fork/FkHitRefresh.java @@ -123,7 +123,7 @@ private FkHitRefresh(final Runnable cmd, final Take tke, } @Override - public Opt route(final Request req) throws IOException { + public Opt route(final Request req) throws Exception { final Iterator header = new RqHeaders.Base(req).header("X-Takes-HitRefresh").iterator(); final Opt resp; diff --git a/src/main/java/org/takes/facets/fork/FkHost.java b/src/main/java/org/takes/facets/fork/FkHost.java index 74826d7c1..a47bcbdf7 100644 --- a/src/main/java/org/takes/facets/fork/FkHost.java +++ b/src/main/java/org/takes/facets/fork/FkHost.java @@ -23,7 +23,6 @@ */ package org.takes.facets.fork; -import java.io.IOException; import lombok.EqualsAndHashCode; import org.takes.Request; import org.takes.Response; @@ -69,7 +68,7 @@ public FkHost(final String host, final Take take) { private static Fork fork(final String host, final Take take) { return new Fork() { @Override - public Opt route(final Request req) throws IOException { + public Opt route(final Request req) throws Exception { final String hst = new RqHeaders.Smart( new RqHeaders.Base(req) ).single("host"); diff --git a/src/main/java/org/takes/facets/fork/FkMethods.java b/src/main/java/org/takes/facets/fork/FkMethods.java index 7d8841d2c..4144148be 100644 --- a/src/main/java/org/takes/facets/fork/FkMethods.java +++ b/src/main/java/org/takes/facets/fork/FkMethods.java @@ -23,7 +23,6 @@ */ package org.takes.facets.fork; -import java.io.IOException; import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -94,7 +93,7 @@ public FkMethods(final Collection mtds, final Take tke) { } @Override - public Opt route(final Request req) throws IOException { + public Opt route(final Request req) throws Exception { final String mtd = new RqMethod.Base(req).method(); final Opt resp; if (this.methods.contains(mtd)) { diff --git a/src/main/java/org/takes/facets/fork/FkParams.java b/src/main/java/org/takes/facets/fork/FkParams.java index 9978678c4..58df1a688 100644 --- a/src/main/java/org/takes/facets/fork/FkParams.java +++ b/src/main/java/org/takes/facets/fork/FkParams.java @@ -23,7 +23,6 @@ */ package org.takes.facets.fork; -import java.io.IOException; import java.util.Iterator; import java.util.regex.Pattern; import lombok.EqualsAndHashCode; @@ -82,7 +81,7 @@ public FkParams(final String param, final Pattern ptn, final Take tke) { } @Override - public Opt route(final Request req) throws IOException { + public Opt route(final Request req) throws Exception { final Iterator params = new RqHref.Base(req).href() .param(this.name).iterator(); final Opt resp; diff --git a/src/main/java/org/takes/facets/fork/FkRegex.java b/src/main/java/org/takes/facets/fork/FkRegex.java index c49299d11..6199a0bce 100644 --- a/src/main/java/org/takes/facets/fork/FkRegex.java +++ b/src/main/java/org/takes/facets/fork/FkRegex.java @@ -148,7 +148,7 @@ public FkRegex(final Pattern ptn, final Take tke) { ptn, new TkRegex() { @Override - public Response act(final RqRegex req) throws IOException { + public Response act(final RqRegex req) throws Exception { return tke.act(req); } } @@ -196,7 +196,7 @@ public FkRegex(final Pattern ptn, final Scalar tke) { } @Override - public Opt route(final Request req) throws IOException { + public Opt route(final Request req) throws Exception { String path = new RqHref.Base(req).href().path(); if (path.length() > 1 && path.charAt(path.length() - 1) == '/') { path = path.substring(0, path.length() - 1); diff --git a/src/main/java/org/takes/facets/fork/FkTypes.java b/src/main/java/org/takes/facets/fork/FkTypes.java index b5e0b4f07..06195f547 100644 --- a/src/main/java/org/takes/facets/fork/FkTypes.java +++ b/src/main/java/org/takes/facets/fork/FkTypes.java @@ -89,7 +89,7 @@ private FkTypes(final String list, final Opt resp, } @Override - public Opt route(final Request req) throws IOException { + public Opt route(final Request req) throws Exception { final Opt resp; if (FkTypes.accepted(req).contains(this.types)) { if (this.response.has()) { diff --git a/src/main/java/org/takes/facets/fork/FkWrap.java b/src/main/java/org/takes/facets/fork/FkWrap.java index e66d2a8f0..427ad6d66 100644 --- a/src/main/java/org/takes/facets/fork/FkWrap.java +++ b/src/main/java/org/takes/facets/fork/FkWrap.java @@ -23,7 +23,6 @@ */ package org.takes.facets.fork; -import java.io.IOException; import lombok.EqualsAndHashCode; import org.takes.Request; import org.takes.Response; @@ -54,8 +53,7 @@ public FkWrap(final Fork fork) { } @Override - public final Opt route(final Request req) - throws IOException { + public final Opt route(final Request req) throws Exception { return this.origin.route(req); } diff --git a/src/main/java/org/takes/facets/fork/Fork.java b/src/main/java/org/takes/facets/fork/Fork.java index a77d33212..a48425a21 100644 --- a/src/main/java/org/takes/facets/fork/Fork.java +++ b/src/main/java/org/takes/facets/fork/Fork.java @@ -23,7 +23,6 @@ */ package org.takes.facets.fork; -import java.io.IOException; import org.takes.Request; import org.takes.Response; import org.takes.misc.Opt; @@ -41,8 +40,8 @@ public interface Fork { * Process this request or ignore it. * @param req Request * @return Non-empty list of responses if it was processed - * @throws IOException If fails + * @throws Exception If fails */ - Opt route(Request req) throws IOException; + Opt route(Request req) throws Exception; } diff --git a/src/main/java/org/takes/facets/fork/RsFork.java b/src/main/java/org/takes/facets/fork/RsFork.java index 9b16df4ce..875794db8 100644 --- a/src/main/java/org/takes/facets/fork/RsFork.java +++ b/src/main/java/org/takes/facets/fork/RsFork.java @@ -83,12 +83,18 @@ public InputStream body() throws IOException { * @return Response * @throws IOException If fails */ + @SuppressWarnings("PMD.AvoidCatchingGenericException") private static Response pick(final Request req, final Iterable forks) throws IOException { for (final Fork fork : forks) { - final Opt rsps = fork.route(req); - if (rsps.has()) { - return rsps.get(); + try { + final Opt rsps = fork.route(req); + if (rsps.has()) { + return rsps.get(); + } + //@checkstyle IllegalCatch (1 line) + } catch (final Exception ex) { + throw new IOException(ex); } } throw new HttpException(HttpURLConnection.HTTP_NOT_FOUND); diff --git a/src/main/java/org/takes/facets/fork/TkFork.java b/src/main/java/org/takes/facets/fork/TkFork.java index 5daeb6af9..953e1a082 100644 --- a/src/main/java/org/takes/facets/fork/TkFork.java +++ b/src/main/java/org/takes/facets/fork/TkFork.java @@ -23,7 +23,6 @@ */ package org.takes.facets.fork; -import java.io.IOException; import java.net.HttpURLConnection; import java.util.Arrays; import java.util.Collection; @@ -94,7 +93,7 @@ public TkFork(final Collection frks) { } @Override - public Response act(final Request request) throws IOException { + public Response act(final Request request) throws Exception { final Opt response = new FkChain(this.forks).route(request); if (response.has()) { return response.get(); diff --git a/src/main/java/org/takes/facets/fork/TkRegex.java b/src/main/java/org/takes/facets/fork/TkRegex.java index 9fec68585..12611fdf0 100644 --- a/src/main/java/org/takes/facets/fork/TkRegex.java +++ b/src/main/java/org/takes/facets/fork/TkRegex.java @@ -23,7 +23,6 @@ */ package org.takes.facets.fork; -import java.io.IOException; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.takes.Request; @@ -43,9 +42,9 @@ public interface TkRegex { * Route this request. * @param req Request * @return Take - * @throws IOException If fails + * @throws Exception If fails */ - Response act(RqRegex req) throws IOException; + Response act(RqRegex req) throws Exception; /** * Fake of {@link TkRegex} as {@link org.takes.Take}. @@ -84,7 +83,7 @@ public Fake(final TkRegex rgx, final Matcher mtr) { } @Override - public Response act(final Request req) throws IOException { + public Response act(final Request req) throws Exception { return this.origin.act(new RqRegex.Fake(req, this.matcher)); } } diff --git a/src/main/java/org/takes/facets/forward/TkForward.java b/src/main/java/org/takes/facets/forward/TkForward.java index bf3e4356f..97354c74a 100644 --- a/src/main/java/org/takes/facets/forward/TkForward.java +++ b/src/main/java/org/takes/facets/forward/TkForward.java @@ -60,7 +60,7 @@ public TkForward(final Take take) { } @Override - public Response act(final Request req) throws IOException { + public Response act(final Request req) throws Exception { Response res; try { res = this.origin.act(req); diff --git a/src/main/java/org/takes/facets/previous/TkPrevious.java b/src/main/java/org/takes/facets/previous/TkPrevious.java index 8ae8a321a..ed402ed5f 100644 --- a/src/main/java/org/takes/facets/previous/TkPrevious.java +++ b/src/main/java/org/takes/facets/previous/TkPrevious.java @@ -23,7 +23,6 @@ */ package org.takes.facets.previous; -import java.io.IOException; import java.net.URLDecoder; import java.util.Iterator; import lombok.EqualsAndHashCode; @@ -60,7 +59,7 @@ public TkPrevious(final Take take) { } @Override - public Response act(final Request req) throws IOException { + public Response act(final Request req) throws Exception { final Iterator cookies = new RqCookies.Base(req) .cookie(TkPrevious.class.getSimpleName()) .iterator(); diff --git a/src/main/java/org/takes/facets/ret/TkReturn.java b/src/main/java/org/takes/facets/ret/TkReturn.java index e0a914890..c3765344d 100644 --- a/src/main/java/org/takes/facets/ret/TkReturn.java +++ b/src/main/java/org/takes/facets/ret/TkReturn.java @@ -23,7 +23,6 @@ */ package org.takes.facets.ret; -import java.io.IOException; import java.net.URLDecoder; import java.nio.charset.Charset; import java.util.Iterator; @@ -76,7 +75,7 @@ public TkReturn(final Take take, final String name) { } @Override - public Response act(final Request request) throws IOException { + public Response act(final Request request) throws Exception { final RqCookies cookies = new RqCookies.Base(request); final Iterator values = cookies.cookie(this.cookie).iterator(); final Response response; diff --git a/src/main/java/org/takes/http/FtCli.java b/src/main/java/org/takes/http/FtCli.java index a4aab315f..641eefd62 100644 --- a/src/main/java/org/takes/http/FtCli.java +++ b/src/main/java/org/takes/http/FtCli.java @@ -93,7 +93,7 @@ public void start(final Exit exit) throws IOException { if (this.options.hitRefresh()) { tks = new Take() { @Override - public Response act(final Request request) throws IOException { + public Response act(final Request request) throws Exception { return FtCli.this.take.act( new RqWithHeader( request, "X-Takes-HitRefresh: yes" diff --git a/src/main/java/org/takes/http/FtRemote.java b/src/main/java/org/takes/http/FtRemote.java index fa6731637..94da5fd8e 100644 --- a/src/main/java/org/takes/http/FtRemote.java +++ b/src/main/java/org/takes/http/FtRemote.java @@ -108,9 +108,9 @@ public void start(final Exit exit) throws IOException { /** * Execute this script against a running front. * @param script Script to run - * @throws IOException If fails + * @throws Exception If fails */ - public void exec(final FtRemote.Script script) throws IOException { + public void exec(final FtRemote.Script script) throws Exception { final AtomicBoolean exit = new AtomicBoolean(); final CountDownLatch latch = new CountDownLatch(1); final Thread thread = new Thread( @@ -186,8 +186,8 @@ public interface Script { /** * Execute it against this URI. * @param home URI of the running front - * @throws IOException If fails + * @throws Exception If fails */ - void exec(URI home) throws IOException; + void exec(URI home) throws Exception; } } diff --git a/src/main/java/org/takes/servlet/SrvTake.java b/src/main/java/org/takes/servlet/SrvTake.java index 9fdd5ff62..0787f3ede 100644 --- a/src/main/java/org/takes/servlet/SrvTake.java +++ b/src/main/java/org/takes/servlet/SrvTake.java @@ -125,6 +125,7 @@ public void init() throws ServletException { } @Override + @SuppressWarnings("PMD.AvoidCatchingGenericException") public void service( final HttpServletRequest req, final HttpServletResponse resp @@ -134,7 +135,8 @@ public void service( .applyTo(resp); } catch (final HttpException err) { resp.sendError(err.code(), err.getMessage()); - } catch (final IOException ignored) { + //@checkstyle IllegalCatch (1 line) + } catch (final Exception ignored) { resp.sendError( HttpURLConnection.HTTP_INTERNAL_ERROR, "Internal error" diff --git a/src/main/java/org/takes/tk/TkCors.java b/src/main/java/org/takes/tk/TkCors.java index 97cbdd497..eeaf6af08 100644 --- a/src/main/java/org/takes/tk/TkCors.java +++ b/src/main/java/org/takes/tk/TkCors.java @@ -23,7 +23,6 @@ */ package org.takes.tk; -import java.io.IOException; import java.net.HttpURLConnection; import java.util.Arrays; import java.util.HashSet; @@ -74,7 +73,7 @@ public TkCors(final Take take, final String... domains) { } @Override - public Response act(final Request req) throws IOException { + public Response act(final Request req) throws Exception { final Response response; final String domain = new RqHeaders.Smart( new RqHeaders.Base(req) diff --git a/src/main/java/org/takes/tk/TkGreedy.java b/src/main/java/org/takes/tk/TkGreedy.java index cf382be94..8cd8a62c9 100644 --- a/src/main/java/org/takes/tk/TkGreedy.java +++ b/src/main/java/org/takes/tk/TkGreedy.java @@ -23,7 +23,6 @@ */ package org.takes.tk; -import java.io.IOException; import lombok.EqualsAndHashCode; import lombok.ToString; import org.takes.Request; @@ -50,7 +49,7 @@ public TkGreedy(final Take take) { super( new Take() { @Override - public Response act(final Request request) throws IOException { + public Response act(final Request request) throws Exception { return take.act(new RqGreedy(request)); } } diff --git a/src/main/java/org/takes/tk/TkGzip.java b/src/main/java/org/takes/tk/TkGzip.java index 80e1b6914..e455a35b6 100644 --- a/src/main/java/org/takes/tk/TkGzip.java +++ b/src/main/java/org/takes/tk/TkGzip.java @@ -23,7 +23,6 @@ */ package org.takes.tk; -import java.io.IOException; import lombok.EqualsAndHashCode; import lombok.ToString; import org.takes.Request; @@ -52,7 +51,7 @@ public TkGzip(final Take take) { super( new Take() { @Override - public Response act(final Request req) throws IOException { + public Response act(final Request req) throws Exception { final Response response = take.act(req); return new RsFork( req, diff --git a/src/main/java/org/takes/tk/TkMeasured.java b/src/main/java/org/takes/tk/TkMeasured.java index fca4f5de4..f05602c8e 100644 --- a/src/main/java/org/takes/tk/TkMeasured.java +++ b/src/main/java/org/takes/tk/TkMeasured.java @@ -23,7 +23,6 @@ */ package org.takes.tk; -import java.io.IOException; import lombok.EqualsAndHashCode; import lombok.ToString; import org.takes.Request; @@ -60,7 +59,7 @@ public TkMeasured(final Take take, final String header) { super( new Take() { @Override - public Response act(final Request req) throws IOException { + public Response act(final Request req) throws Exception { final long start = System.currentTimeMillis(); final Response res = take.act(req); return new RsWithHeader( diff --git a/src/main/java/org/takes/tk/TkOnce.java b/src/main/java/org/takes/tk/TkOnce.java index 0297ea3f5..6c78fefde 100644 --- a/src/main/java/org/takes/tk/TkOnce.java +++ b/src/main/java/org/takes/tk/TkOnce.java @@ -23,7 +23,6 @@ */ package org.takes.tk; -import java.io.IOException; import lombok.EqualsAndHashCode; import lombok.ToString; import org.takes.Request; @@ -50,7 +49,7 @@ public TkOnce(final Take take) { super( new Take() { @Override - public Response act(final Request request) throws IOException { + public Response act(final Request request) throws Exception { return take.act(new RqGreedy(request)); } } diff --git a/src/main/java/org/takes/tk/TkProxy.java b/src/main/java/org/takes/tk/TkProxy.java index 187dc01b6..9e3527fa4 100644 --- a/src/main/java/org/takes/tk/TkProxy.java +++ b/src/main/java/org/takes/tk/TkProxy.java @@ -25,7 +25,6 @@ import com.jcabi.http.request.JdkRequest; import java.io.ByteArrayOutputStream; -import java.io.IOException; import java.net.URI; import java.util.Collection; import java.util.LinkedList; @@ -111,7 +110,7 @@ public TkProxy(final URI tgt, final String mark) { } @Override - public Response act(final Request req) throws IOException { + public Response act(final Request req) throws Exception { final String input = new RqRequestLine.Base(req).uri(); final URI output = this.target.resolve(URI.create(input)); return this.response( @@ -126,11 +125,11 @@ public Response act(final Request req) throws IOException { * @param req Original request * @param dest Destination URL * @return Request to be forwarded - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops") private com.jcabi.http.Request request(final Request req, - final URI dest) throws IOException { + final URI dest) throws Exception { final String method = new RqMethod.Base(req).method(); com.jcabi.http.Request proxied = new JdkRequest(dest).method(method); final RqHeaders headers = new RqHeaders.Base(req); diff --git a/src/main/java/org/takes/tk/TkReadAlways.java b/src/main/java/org/takes/tk/TkReadAlways.java index e1151dfd2..a0c77ccec 100644 --- a/src/main/java/org/takes/tk/TkReadAlways.java +++ b/src/main/java/org/takes/tk/TkReadAlways.java @@ -23,7 +23,6 @@ */ package org.takes.tk; -import java.io.IOException; import lombok.EqualsAndHashCode; import lombok.ToString; import org.takes.Request; @@ -55,7 +54,7 @@ public TkReadAlways(final Take take) { } @Override - public Response act(final Request req) throws IOException { + public Response act(final Request req) throws Exception { final Response res = this.origin.act(req); for (int count = req.body().available(); count > 0; count = req.body().available()) { diff --git a/src/main/java/org/takes/tk/TkRetry.java b/src/main/java/org/takes/tk/TkRetry.java index a85d95393..dec3b699b 100644 --- a/src/main/java/org/takes/tk/TkRetry.java +++ b/src/main/java/org/takes/tk/TkRetry.java @@ -36,7 +36,7 @@ import org.takes.misc.TransformAction; /** - * Decorator TkRetry, which will not fail immediately on IOException, but + * Decorator TkRetry, which will not fail immediately on Exception, but * will retry a few times. * * @since 0.28.3 @@ -72,6 +72,7 @@ public TkRetry(final int retries, final int wait, final Take original) { } @Override + @SuppressWarnings("PMD.AvoidCatchingGenericException") public Response act(final Request req) throws IOException { if (this.count <= 0) { throw new IllegalArgumentException( @@ -79,11 +80,12 @@ public Response act(final Request req) throws IOException { ); } int attempts = 0; - final List failures = new ArrayList<>(this.count); + final List failures = new ArrayList<>(this.count); while (attempts < this.count) { try { return this.take.act(req); - } catch (final IOException ex) { + //@checkstyle IllegalCatch (1 line) + } catch (final Exception ex) { ++attempts; failures.add(ex); this.sleep(); @@ -104,13 +106,13 @@ public Response act(final Request req) throws IOException { * @param failures Input : a list of exceptions. * @return A list of exceptions messages. */ - private static List strings(final List failures) { + private static List strings(final List failures) { final List result = new ArrayList<>(failures.size()); final Iterable transform = new Transform<>( failures, - new TransformAction() { + new TransformAction() { @Override - public String transform(final IOException element) { + public String transform(final Exception element) { final Opt message = new Opt.Single<>( element.getMessage() ); diff --git a/src/main/java/org/takes/tk/TkSlf4j.java b/src/main/java/org/takes/tk/TkSlf4j.java index 18b1df9d2..685fb925f 100644 --- a/src/main/java/org/takes/tk/TkSlf4j.java +++ b/src/main/java/org/takes/tk/TkSlf4j.java @@ -85,7 +85,7 @@ public TkSlf4j(final Take take, final String tgt) { @Override @SuppressWarnings("PMD.AvoidCatchingGenericException") - public Response act(final Request req) throws IOException { + public Response act(final Request req) throws Exception { final long start = System.currentTimeMillis(); final Logger logger = LoggerFactory.getLogger(this.target); try { diff --git a/src/main/java/org/takes/tk/TkSslOnly.java b/src/main/java/org/takes/tk/TkSslOnly.java index 7ed992f7c..5006dd229 100644 --- a/src/main/java/org/takes/tk/TkSslOnly.java +++ b/src/main/java/org/takes/tk/TkSslOnly.java @@ -23,7 +23,6 @@ */ package org.takes.tk; -import java.io.IOException; import lombok.EqualsAndHashCode; import lombok.ToString; import org.takes.Request; @@ -59,7 +58,7 @@ public TkSslOnly(final Take take) { @Override @SuppressWarnings("PMD.AvoidDuplicateLiterals") - public Response act(final Request req) throws IOException { + public Response act(final Request req) throws Exception { final String href = new RqHref.Base(req).href().toString(); final String proto = new RqHeaders.Smart( new RqHeaders.Base(req) diff --git a/src/main/java/org/takes/tk/TkVerbose.java b/src/main/java/org/takes/tk/TkVerbose.java index 729876e22..4ae7032d3 100644 --- a/src/main/java/org/takes/tk/TkVerbose.java +++ b/src/main/java/org/takes/tk/TkVerbose.java @@ -23,7 +23,6 @@ */ package org.takes.tk; -import java.io.IOException; import lombok.EqualsAndHashCode; import lombok.ToString; import org.takes.HttpException; @@ -52,7 +51,7 @@ public TkVerbose(final Take take) { super( new Take() { @Override - public Response act(final Request request) throws IOException { + public Response act(final Request request) throws Exception { try { return take.act(request); } catch (final HttpException ex) { diff --git a/src/main/java/org/takes/tk/TkVersioned.java b/src/main/java/org/takes/tk/TkVersioned.java index d9db9eacc..f4ef8dedc 100644 --- a/src/main/java/org/takes/tk/TkVersioned.java +++ b/src/main/java/org/takes/tk/TkVersioned.java @@ -23,7 +23,6 @@ */ package org.takes.tk; -import java.io.IOException; import java.util.ResourceBundle; import lombok.EqualsAndHashCode; import lombok.ToString; @@ -66,7 +65,7 @@ public TkVersioned(final Take take, final String header) { super( new Take() { @Override - public Response act(final Request req) throws IOException { + public Response act(final Request req) throws Exception { return new RsWithHeader( take.act(req), header, TkVersioned.VERSION ); diff --git a/src/main/java/org/takes/tk/TkWithHeader.java b/src/main/java/org/takes/tk/TkWithHeader.java index 83731a5da..71b29172c 100644 --- a/src/main/java/org/takes/tk/TkWithHeader.java +++ b/src/main/java/org/takes/tk/TkWithHeader.java @@ -23,7 +23,6 @@ */ package org.takes.tk; -import java.io.IOException; import lombok.EqualsAndHashCode; import lombok.ToString; import org.takes.Request; @@ -64,7 +63,7 @@ public TkWithHeader(final Take take, final String header) { super( new Take() { @Override - public Response act(final Request req) throws IOException { + public Response act(final Request req) throws Exception { return new RsWithHeader(take.act(req), header); } } diff --git a/src/main/java/org/takes/tk/TkWithHeaders.java b/src/main/java/org/takes/tk/TkWithHeaders.java index ded2c303e..eb05f8184 100644 --- a/src/main/java/org/takes/tk/TkWithHeaders.java +++ b/src/main/java/org/takes/tk/TkWithHeaders.java @@ -23,7 +23,6 @@ */ package org.takes.tk; -import java.io.IOException; import java.util.Arrays; import java.util.Collection; import lombok.EqualsAndHashCode; @@ -65,7 +64,7 @@ public TkWithHeaders(final Take take, final Collection headers) { super( new Take() { @Override - public Response act(final Request req) throws IOException { + public Response act(final Request req) throws Exception { return new RsWithHeaders(take.act(req), headers); } } diff --git a/src/main/java/org/takes/tk/TkWithType.java b/src/main/java/org/takes/tk/TkWithType.java index f968d0efb..10681aaa5 100644 --- a/src/main/java/org/takes/tk/TkWithType.java +++ b/src/main/java/org/takes/tk/TkWithType.java @@ -23,7 +23,6 @@ */ package org.takes.tk; -import java.io.IOException; import lombok.EqualsAndHashCode; import lombok.ToString; import org.takes.Request; @@ -54,7 +53,7 @@ public TkWithType(final Take take, final String type) { super( new Take() { @Override - public Response act(final Request req) throws IOException { + public Response act(final Request req) throws Exception { return new RsWithType(take.act(req), type); } } diff --git a/src/main/java/org/takes/tk/TkWrap.java b/src/main/java/org/takes/tk/TkWrap.java index e11354767..87683e85c 100644 --- a/src/main/java/org/takes/tk/TkWrap.java +++ b/src/main/java/org/takes/tk/TkWrap.java @@ -23,7 +23,6 @@ */ package org.takes.tk; -import java.io.IOException; import lombok.EqualsAndHashCode; import lombok.ToString; import org.takes.Request; @@ -55,7 +54,7 @@ public TkWrap(final Take take) { } @Override - public final Response act(final Request req) throws IOException { + public final Response act(final Request req) throws Exception { return this.origin.act(req); } } diff --git a/src/test/java/org/takes/facets/auth/PsByFlagTest.java b/src/test/java/org/takes/facets/auth/PsByFlagTest.java index 6dfa02ba9..ad11ce206 100644 --- a/src/test/java/org/takes/facets/auth/PsByFlagTest.java +++ b/src/test/java/org/takes/facets/auth/PsByFlagTest.java @@ -46,10 +46,10 @@ public final class PsByFlagTest { /** * PsByFlag can skip if nothing found. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void skipsIfNothingFound() throws IOException { + public void skipsIfNothingFound() throws Exception { MatcherAssert.assertThat( new PsByFlag( new PsByFlag.Pair( @@ -64,10 +64,10 @@ public void skipsIfNothingFound() throws IOException { /** * PsByFlag finds flag and authenticates user. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void flagIsFoundUserAuthenticated() throws IOException { + public void flagIsFoundUserAuthenticated() throws Exception { MatcherAssert.assertThat( new PsByFlag( new PsByFlag.Pair( diff --git a/src/test/java/org/takes/facets/auth/PsChainTest.java b/src/test/java/org/takes/facets/auth/PsChainTest.java index 52b1303fe..1fa76ce3a 100644 --- a/src/test/java/org/takes/facets/auth/PsChainTest.java +++ b/src/test/java/org/takes/facets/auth/PsChainTest.java @@ -23,7 +23,6 @@ */ package org.takes.facets.auth; -import java.io.IOException; import org.hamcrest.MatcherAssert; import org.hamcrest.core.IsEqual; import org.hamcrest.core.StringContains; @@ -39,10 +38,10 @@ public final class PsChainTest { /** * PsChain returns proper identity. - * @throws IOException if some problems inside + * @throws Exception if some problems inside */ @Test - public void chainExecutionTest() throws IOException { + public void chainExecutionTest() throws Exception { MatcherAssert.assertThat( new PsChain( new PsLogout(), @@ -54,10 +53,10 @@ public void chainExecutionTest() throws IOException { /** * PsChain returns proper response. - * @throws IOException if some problems inside + * @throws Exception if some problems inside */ @Test - public void exitChainTest() throws IOException { + public void exitChainTest() throws Exception { MatcherAssert.assertThat( new PsChain( new PsFake(true) diff --git a/src/test/java/org/takes/facets/auth/TkAuthTest.java b/src/test/java/org/takes/facets/auth/TkAuthTest.java index 2ac97c900..eb789e609 100644 --- a/src/test/java/org/takes/facets/auth/TkAuthTest.java +++ b/src/test/java/org/takes/facets/auth/TkAuthTest.java @@ -23,7 +23,6 @@ */ package org.takes.facets.auth; -import java.io.IOException; import org.cactoos.iterable.IterableOf; import org.cactoos.text.FormattedText; import org.hamcrest.MatcherAssert; @@ -54,10 +53,10 @@ public final class TkAuthTest { /** * TkAuth can login a user. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void logsUserIn() throws IOException { + public void logsUserIn() throws Exception { final Pass pass = new PsFixed(new Identity.Simple("urn:test:1")); final Take take = Mockito.mock(Take.class); Mockito.doReturn(new RsText()).when(take) @@ -112,10 +111,10 @@ public void logsInUserViaCookie() throws Exception { /** * TkAuth can logout a user. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void logsUserOut() throws IOException { + public void logsUserOut() throws Exception { final Pass pass = new PsLogout(); final Take take = Mockito.mock(Take.class); Mockito.doReturn(new RsText()).when(take) @@ -140,10 +139,10 @@ public void logsUserOut() throws IOException { /** * TkAuth can logout a user when a login cookie is present. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void logsUserOutWithCookiePresent() throws IOException { + public void logsUserOutWithCookiePresent() throws Exception { new Assertion<>( "Response with header setting empty cookie", new RsPrint( diff --git a/src/test/java/org/takes/facets/auth/TkSecureTest.java b/src/test/java/org/takes/facets/auth/TkSecureTest.java index f39004e0d..cb11fb3fe 100644 --- a/src/test/java/org/takes/facets/auth/TkSecureTest.java +++ b/src/test/java/org/takes/facets/auth/TkSecureTest.java @@ -23,7 +23,6 @@ */ package org.takes.facets.auth; -import java.io.IOException; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Test; @@ -44,10 +43,10 @@ public final class TkSecureTest { /** * TkSecure can fail on anonymous access. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test(expected = RsForward.class) - public void failsOnAnonymous() throws IOException { + public void failsOnAnonymous() throws Exception { new TkSecure( new Take() { @Override @@ -60,10 +59,10 @@ public Response act(final Request request) { /** * TkSecure can pass on registered user. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void passesOnRegisteredUser() throws IOException { + public void passesOnRegisteredUser() throws Exception { MatcherAssert.assertThat( new TkSecure( new Take() { diff --git a/src/test/java/org/takes/facets/auth/social/PsGithubTest.java b/src/test/java/org/takes/facets/auth/social/PsGithubTest.java index 179c55f37..fa810231f 100644 --- a/src/test/java/org/takes/facets/auth/social/PsGithubTest.java +++ b/src/test/java/org/takes/facets/auth/social/PsGithubTest.java @@ -89,20 +89,20 @@ public final class PsGithubTest { /** * PsGithub can fail on no access token. - * @throws IOException If some problem inside. + * @throws Exception If some problem inside. */ @Test - public void failsOnNoAccessToken() throws IOException { + public void failsOnNoAccessToken() throws Exception { this.thrown.expect(AssertionError.class); this.performLogin(PsGithubTest.directiveWithoutAccessToken()); } /** * PsGithub can login. - * @throws IOException If some problem inside. + * @throws Exception If some problem inside. */ @Test - public void canLogin() throws IOException { + public void canLogin() throws Exception { this.performLogin( PsGithubTest.directiveWithoutAccessToken() .add(PsGithubTest.ACCESS_TOKEN) @@ -113,9 +113,9 @@ public void canLogin() throws IOException { /** * Performs the basic login. * @param directive The directive object. - * @throws IOException If some problem inside. + * @throws Exception If some problem inside. */ - private void performLogin(final Directives directive) throws IOException { + private void performLogin(final Directives directive) throws Exception { final String app = "app"; final String key = "key"; final Take take = new TkFork( diff --git a/src/test/java/org/takes/facets/auth/social/PsLinkedinTest.java b/src/test/java/org/takes/facets/auth/social/PsLinkedinTest.java index 84bfa8b98..794d86f5b 100644 --- a/src/test/java/org/takes/facets/auth/social/PsLinkedinTest.java +++ b/src/test/java/org/takes/facets/auth/social/PsLinkedinTest.java @@ -54,10 +54,10 @@ public final class PsLinkedinTest { /** * PsLinkedin can login. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void logins() throws IOException { + public void logins() throws Exception { final String tokenpath = "/uas/oauth2/accessToken"; final String firstname = "firstName"; final String lastname = "lastName"; diff --git a/src/test/java/org/takes/facets/auth/social/PsTwitterTest.java b/src/test/java/org/takes/facets/auth/social/PsTwitterTest.java index 644d1cc58..64c08126f 100644 --- a/src/test/java/org/takes/facets/auth/social/PsTwitterTest.java +++ b/src/test/java/org/takes/facets/auth/social/PsTwitterTest.java @@ -25,7 +25,6 @@ package org.takes.facets.auth.social; import com.jcabi.http.request.FakeRequest; -import java.io.IOException; import java.util.Collections; import java.util.Map; import javax.json.Json; @@ -48,10 +47,10 @@ public final class PsTwitterTest { /** * PsTwitter can login. - * @throws IOException If error occurs in the process + * @throws Exception If error occurs in the process */ @Test - public void logsIn() throws IOException { + public void logsIn() throws Exception { final int tid = RandomUtils.nextInt(1000); final String randname = RandomStringUtils.randomAlphanumeric(10); final String picture = RandomStringUtils.randomAlphanumeric(10); diff --git a/src/test/java/org/takes/facets/cookies/TkJoinedCookiesTest.java b/src/test/java/org/takes/facets/cookies/TkJoinedCookiesTest.java index 1b7b9fb36..f91dd8447 100644 --- a/src/test/java/org/takes/facets/cookies/TkJoinedCookiesTest.java +++ b/src/test/java/org/takes/facets/cookies/TkJoinedCookiesTest.java @@ -23,7 +23,6 @@ */ package org.takes.facets.cookies; -import java.io.IOException; import org.junit.Test; import org.llorllale.cactoos.matchers.Assertion; import org.llorllale.cactoos.matchers.TextHasString; @@ -43,10 +42,10 @@ public final class TkJoinedCookiesTest { /** * TkJoinedCookies can join cookies. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void joinsCookies() throws IOException { + public void joinsCookies() throws Exception { new Assertion<>( "Response with joined cookies", new RsPrint( diff --git a/src/test/java/org/takes/facets/fallback/FbChainTest.java b/src/test/java/org/takes/facets/fallback/FbChainTest.java index 78609d015..09423b708 100644 --- a/src/test/java/org/takes/facets/fallback/FbChainTest.java +++ b/src/test/java/org/takes/facets/fallback/FbChainTest.java @@ -23,7 +23,6 @@ */ package org.takes.facets.fallback; -import java.io.IOException; import java.net.HttpURLConnection; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; @@ -39,10 +38,10 @@ public final class FbChainTest { /** * FbChain can chain fallbacks. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void chainsFallbacks() throws IOException { + public void chainsFallbacks() throws Exception { final RqFallback req = new RqFallback.Fake( HttpURLConnection.HTTP_NOT_FOUND ); diff --git a/src/test/java/org/takes/facets/fallback/TkFallbackTest.java b/src/test/java/org/takes/facets/fallback/TkFallbackTest.java index 2705fbb7b..7aeefa2f7 100644 --- a/src/test/java/org/takes/facets/fallback/TkFallbackTest.java +++ b/src/test/java/org/takes/facets/fallback/TkFallbackTest.java @@ -23,7 +23,6 @@ */ package org.takes.facets.fallback; -import java.io.IOException; import java.io.InputStream; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; @@ -46,10 +45,10 @@ public final class TkFallbackTest { /** * TkFallback can fall back. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void fallsBack() throws IOException { + public void fallsBack() throws Exception { final String err = "message"; MatcherAssert.assertThat( new RsPrint( @@ -71,10 +70,10 @@ public Opt route(final RqFallback req) { /** * TkFallback can fall back. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void fallsBackInsideResponse() throws IOException { + public void fallsBackInsideResponse() throws Exception { MatcherAssert.assertThat( new RsPrint( new TkFallback( @@ -104,9 +103,10 @@ public InputStream body() { } /** - * TkFallback can throw an IOException when no fallback is available. + * TkFallback can throw an Exception when no fallback is available. */ @Test + @SuppressWarnings("PMD.AvoidCatchingGenericException") public void fallsBackWithProperMessage() { try { new TkFallback( @@ -114,7 +114,8 @@ public void fallsBackWithProperMessage() { new FbChain() ).act(new RqFake()); MatcherAssert.assertThat("Must throw exception", false); - } catch (final IOException exception) { + //@checkstyle IllegalCatch (1 line) + } catch (final Exception exception) { MatcherAssert.assertThat( exception.getMessage(), Matchers.containsString("fallback ") diff --git a/src/test/java/org/takes/facets/flash/TkFlashTest.java b/src/test/java/org/takes/facets/flash/TkFlashTest.java index 8ef5f3276..452ba8f29 100644 --- a/src/test/java/org/takes/facets/flash/TkFlashTest.java +++ b/src/test/java/org/takes/facets/flash/TkFlashTest.java @@ -23,7 +23,6 @@ */ package org.takes.facets.flash; -import java.io.IOException; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Test; @@ -40,10 +39,10 @@ public final class TkFlashTest { /** * TkFlash can remove a flash cookie. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void removesFlashCookie() throws IOException { + public void removesFlashCookie() throws Exception { final Take take = new TkFlash(new TkEmpty()); MatcherAssert.assertThat( take.act( diff --git a/src/test/java/org/takes/facets/fork/FkAgentTest.java b/src/test/java/org/takes/facets/fork/FkAgentTest.java index 2713f0bcf..31d7252f0 100644 --- a/src/test/java/org/takes/facets/fork/FkAgentTest.java +++ b/src/test/java/org/takes/facets/fork/FkAgentTest.java @@ -23,7 +23,6 @@ */ package org.takes.facets.fork; -import java.io.IOException; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Test; @@ -40,7 +39,7 @@ public final class FkAgentTest { @Test - public void matchesByVersionGreater() throws IOException { + public void matchesByVersionGreater() throws Exception { final String header = "User-Agent"; final String agent = "Chrome"; MatcherAssert.assertThat( diff --git a/src/test/java/org/takes/facets/fork/FkAnonymousTest.java b/src/test/java/org/takes/facets/fork/FkAnonymousTest.java index 55bf74799..441e34dc8 100644 --- a/src/test/java/org/takes/facets/fork/FkAnonymousTest.java +++ b/src/test/java/org/takes/facets/fork/FkAnonymousTest.java @@ -23,7 +23,6 @@ */ package org.takes.facets.fork; -import java.io.IOException; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Test; @@ -38,10 +37,10 @@ public final class FkAnonymousTest { /** * FkAnonymous can match by user status. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void matchesIfAnonymousUser() throws IOException { + public void matchesIfAnonymousUser() throws Exception { MatcherAssert.assertThat( new FkAnonymous(new TkEmpty()).route( new RqFake("GET", "/hel?a=1") diff --git a/src/test/java/org/takes/facets/fork/FkAuthenticatedTest.java b/src/test/java/org/takes/facets/fork/FkAuthenticatedTest.java index 41df92b7b..7a6ec893e 100644 --- a/src/test/java/org/takes/facets/fork/FkAuthenticatedTest.java +++ b/src/test/java/org/takes/facets/fork/FkAuthenticatedTest.java @@ -23,7 +23,6 @@ */ package org.takes.facets.fork; -import java.io.IOException; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Test; @@ -42,10 +41,10 @@ public final class FkAuthenticatedTest { /** * FkAuthenticated can match by user status. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void matchesIfAuthenticatedUser() throws IOException { + public void matchesIfAuthenticatedUser() throws Exception { MatcherAssert.assertThat( new FkAuthenticated(new TkEmpty()).route( new RqFake("GET", "/hel?a=1") diff --git a/src/test/java/org/takes/facets/fork/FkContentTypeTest.java b/src/test/java/org/takes/facets/fork/FkContentTypeTest.java index 13915f330..4e2a1eb3e 100644 --- a/src/test/java/org/takes/facets/fork/FkContentTypeTest.java +++ b/src/test/java/org/takes/facets/fork/FkContentTypeTest.java @@ -55,10 +55,10 @@ public final class FkContentTypeTest { /** * FkContentType can match by Content-Type header with any of types. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void matchesWithAnyTypes() throws IOException { + public void matchesWithAnyTypes() throws Exception { MatcherAssert.assertThat( new FkContentType("text/xml", new RsEmpty()).route( new RqWithHeader( @@ -73,10 +73,10 @@ public void matchesWithAnyTypes() throws IOException { /** * FkContentType can match by Content-Type header with different types. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void matchesDifferentTypes() throws IOException { + public void matchesDifferentTypes() throws Exception { MatcherAssert.assertThat( new FkContentType( "application/json charset=utf-8", @@ -94,10 +94,10 @@ public void matchesDifferentTypes() throws IOException { /** * FkContentType can match by Content-Type header with identical types. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void matchesIdenticalTypes() throws IOException { + public void matchesIdenticalTypes() throws Exception { MatcherAssert.assertThat( new FkContentType( FkContentTypeTest.CTYPE, @@ -115,10 +115,10 @@ public void matchesIdenticalTypes() throws IOException { /** * FkContentType can match by Content-Type header with empty type. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void matchesEmptyType() throws IOException { + public void matchesEmptyType() throws Exception { MatcherAssert.assertThat( new FkContentType( "*/*", @@ -133,10 +133,10 @@ public void matchesEmptyType() throws IOException { /** * FkContentType can match by Content-Type header with different encodings. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void matchesDifferentEncodingsTypes() throws IOException { + public void matchesDifferentEncodingsTypes() throws Exception { MatcherAssert.assertThat( new FkContentType( FkContentTypeTest.CTYPE, diff --git a/src/test/java/org/takes/facets/fork/FkHostTest.java b/src/test/java/org/takes/facets/fork/FkHostTest.java index 38abab938..bf4806801 100644 --- a/src/test/java/org/takes/facets/fork/FkHostTest.java +++ b/src/test/java/org/takes/facets/fork/FkHostTest.java @@ -23,7 +23,6 @@ */ package org.takes.facets.fork; -import java.io.IOException; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Test; @@ -38,10 +37,10 @@ public final class FkHostTest { /** * FkHost can match a host. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void matchesByHost() throws IOException { + public void matchesByHost() throws Exception { MatcherAssert.assertThat( new FkHost("www.example.com", new TkEmpty()).route( new RqFake("GET", "/hel?a=1") diff --git a/src/test/java/org/takes/facets/fork/FkMethodsTest.java b/src/test/java/org/takes/facets/fork/FkMethodsTest.java index 21c9dd43f..5ffed3611 100644 --- a/src/test/java/org/takes/facets/fork/FkMethodsTest.java +++ b/src/test/java/org/takes/facets/fork/FkMethodsTest.java @@ -23,7 +23,6 @@ */ package org.takes.facets.fork; -import java.io.IOException; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Test; @@ -38,10 +37,10 @@ public final class FkMethodsTest { /** * FkMethods can match by method. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void matchesByRegularExpression() throws IOException { + public void matchesByRegularExpression() throws Exception { MatcherAssert.assertThat( new FkMethods("PUT,GET", new TkEmpty()).route( new RqFake("GET", "/hel?a=1") diff --git a/src/test/java/org/takes/facets/fork/FkParamsTest.java b/src/test/java/org/takes/facets/fork/FkParamsTest.java index 23a65fd4b..bcbd7c956 100644 --- a/src/test/java/org/takes/facets/fork/FkParamsTest.java +++ b/src/test/java/org/takes/facets/fork/FkParamsTest.java @@ -23,7 +23,6 @@ */ package org.takes.facets.fork; -import java.io.IOException; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Test; @@ -38,10 +37,10 @@ public final class FkParamsTest { /** * FkParams can match by param regex. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void matchesByRegularExpression() throws IOException { + public void matchesByRegularExpression() throws Exception { MatcherAssert.assertThat( new FkParams("a", "[0-9]+", new TkEmpty()).route( new RqFake("GET", "/hel?a=1") diff --git a/src/test/java/org/takes/facets/fork/FkRegexTest.java b/src/test/java/org/takes/facets/fork/FkRegexTest.java index be2bdad39..6d43b81c6 100644 --- a/src/test/java/org/takes/facets/fork/FkRegexTest.java +++ b/src/test/java/org/takes/facets/fork/FkRegexTest.java @@ -23,7 +23,6 @@ */ package org.takes.facets.fork; -import java.io.IOException; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Test; @@ -38,10 +37,10 @@ public final class FkRegexTest { /** * FkRegex can match by regular expression. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void matchesByRegularExpression() throws IOException { + public void matchesByRegularExpression() throws Exception { MatcherAssert.assertThat( new FkRegex("/h[a-z]{2}", new TkEmpty()).route( new RqFake("GET", "/hel?a=1") @@ -58,10 +57,10 @@ public void matchesByRegularExpression() throws IOException { /** * FkRegex can remove trailing slash from URI. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void removesTrailingSlash() throws IOException { + public void removesTrailingSlash() throws Exception { MatcherAssert.assertThat( new FkRegex("/h/tail", new TkEmpty()).route( new RqFake("POST", "/h/tail/") diff --git a/src/test/java/org/takes/facets/fork/FkTypesTest.java b/src/test/java/org/takes/facets/fork/FkTypesTest.java index ff2374d6f..00a0174e7 100644 --- a/src/test/java/org/takes/facets/fork/FkTypesTest.java +++ b/src/test/java/org/takes/facets/fork/FkTypesTest.java @@ -23,7 +23,6 @@ */ package org.takes.facets.fork; -import java.io.IOException; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Test; @@ -40,10 +39,10 @@ public final class FkTypesTest { /** * FkTypes can match by Accept header. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void matchesByAcceptHeader() throws IOException { + public void matchesByAcceptHeader() throws Exception { final String accept = "Accept"; MatcherAssert.assertThat( new FkTypes("text/xml", new RsEmpty()).route( @@ -67,10 +66,10 @@ public void matchesByAcceptHeader() throws IOException { /** * FkTypes can match by Accept header. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void matchesByCompositeType() throws IOException { + public void matchesByCompositeType() throws Exception { MatcherAssert.assertThat( new FkTypes("text/xml,text/json", new RsEmpty()).route( new RqWithHeader(new RqFake(), "Accept ", "text/json") @@ -81,10 +80,10 @@ public void matchesByCompositeType() throws IOException { /** * FkTypes can ignore if no Accept header present. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void ignoresWithoutHeader() throws IOException { + public void ignoresWithoutHeader() throws Exception { MatcherAssert.assertThat( new FkTypes("text/plain", new RsEmpty()).route( new RqFake() @@ -95,10 +94,10 @@ public void ignoresWithoutHeader() throws IOException { /** * FkTypes can match if no Accept header present. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void matchesWithoutHeader() throws IOException { + public void matchesWithoutHeader() throws Exception { MatcherAssert.assertThat( new FkTypes("text/plain,*/*", new RsEmpty()).route( new RqFake() @@ -109,10 +108,10 @@ public void matchesWithoutHeader() throws IOException { /** * FkTypes can rely on a Take to provide the response. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void reliesOnTake() throws IOException { + public void reliesOnTake() throws Exception { MatcherAssert.assertThat( new FkTypes("*/*,text/plain", new TkEmpty()).route( new RqFake() diff --git a/src/test/java/org/takes/facets/fork/TkConsumesTest.java b/src/test/java/org/takes/facets/fork/TkConsumesTest.java index 33c1e72c0..79aad6c4b 100644 --- a/src/test/java/org/takes/facets/fork/TkConsumesTest.java +++ b/src/test/java/org/takes/facets/fork/TkConsumesTest.java @@ -23,7 +23,6 @@ */ package org.takes.facets.fork; -import java.io.IOException; import java.util.Arrays; import nl.jqno.equalsverifier.EqualsVerifier; import nl.jqno.equalsverifier.Warning; @@ -54,10 +53,10 @@ public final class TkConsumesTest { /** * TkConsumes can accept request with certain Content-Type. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void acceptsCorrectContentTypeRequest() throws IOException { + public void acceptsCorrectContentTypeRequest() throws Exception { final String contenttype = "Content-Type: application/json"; final Take consumes = new TkConsumes( new TkFixed(new RsJson(new RsEmpty())), @@ -86,10 +85,10 @@ public void acceptsCorrectContentTypeRequest() throws IOException { /** * TkConsumes can fail on unsupported Content-Type header. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test(expected = HttpException.class) - public void failsOnUnsupportedAcceptHeader() throws IOException { + public void failsOnUnsupportedAcceptHeader() throws Exception { final Take consumes = new TkConsumes( new TkFixed(new RsJson(new RsEmpty())), TkConsumesTest.APPLICATION_JSON diff --git a/src/test/java/org/takes/facets/fork/TkForkTest.java b/src/test/java/org/takes/facets/fork/TkForkTest.java index 41b547c7a..b352c1499 100644 --- a/src/test/java/org/takes/facets/fork/TkForkTest.java +++ b/src/test/java/org/takes/facets/fork/TkForkTest.java @@ -23,7 +23,6 @@ */ package org.takes.facets.fork; -import java.io.IOException; import org.cactoos.text.JoinedText; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; @@ -39,10 +38,10 @@ public final class TkForkTest { /** * TkFork can dispatch by regular expression. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void dispatchesByRegularExpression() throws IOException { + public void dispatchesByRegularExpression() throws Exception { final String body = "hello, world!"; MatcherAssert.assertThat( new RsPrint( diff --git a/src/test/java/org/takes/facets/fork/TkMethodsTest.java b/src/test/java/org/takes/facets/fork/TkMethodsTest.java index c5c617a37..7433809b5 100644 --- a/src/test/java/org/takes/facets/fork/TkMethodsTest.java +++ b/src/test/java/org/takes/facets/fork/TkMethodsTest.java @@ -25,7 +25,6 @@ import com.jcabi.http.request.JdkRequest; import com.jcabi.http.response.RestResponse; -import java.io.IOException; import java.net.HttpURLConnection; import org.junit.Test; import org.mockito.Mockito; @@ -56,11 +55,11 @@ public void callsActOnProperMethods() throws Exception { /** * TkMethods can throw HttpExcection when acting on unproper method. - * @throws IOException if any I/O error occurs. + * @throws Exception if any I/O error occurs. */ @Test(expected = HttpException.class) public void throwsExceptionOnActinOnUnproperMethod() throws - IOException { + Exception { new TkMethods(Mockito.mock(Take.class), RqMethod.POST).act( new RqFake(RqMethod.GET) ); @@ -68,11 +67,11 @@ public void throwsExceptionOnActinOnUnproperMethod() throws /** * TkMethods can return 405 status when acting on unknown method. - * @throws IOException If any I/O error occurs + * @throws Exception If any I/O error occurs */ @Test public void returnsMethodIsNotAllowedForUnsupportedMethods() throws - IOException { + Exception { new FtRemote(new TkMethods(new TkEmpty(), RqMethod.PUT)).exec( url -> new JdkRequest(url) .method(RqMethod.POST) diff --git a/src/test/java/org/takes/facets/fork/TkProducesTest.java b/src/test/java/org/takes/facets/fork/TkProducesTest.java index 5ebe22e8f..9e56f9f32 100644 --- a/src/test/java/org/takes/facets/fork/TkProducesTest.java +++ b/src/test/java/org/takes/facets/fork/TkProducesTest.java @@ -23,7 +23,6 @@ */ package org.takes.facets.fork; -import java.io.IOException; import java.util.Arrays; import org.cactoos.text.JoinedText; import org.hamcrest.MatcherAssert; @@ -48,10 +47,10 @@ public final class TkProducesTest { /** * TkProduces can fail on unsupported Accept header. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test(expected = HttpException.class) - public void failsOnUnsupportedAcceptHeader() throws IOException { + public void failsOnUnsupportedAcceptHeader() throws Exception { final Take produces = new TkProduces( new TkEmpty(), "text/json,application/json" @@ -70,10 +69,10 @@ public void failsOnUnsupportedAcceptHeader() throws IOException { /** * TkProduce can produce correct type response. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void producesCorrectContentTypeResponse() throws IOException { + public void producesCorrectContentTypeResponse() throws Exception { final Take produces = new TkProduces( new TkFixed(new RsJson(new RsEmpty())), "text/json" diff --git a/src/test/java/org/takes/facets/forward/TkForwardTest.java b/src/test/java/org/takes/facets/forward/TkForwardTest.java index c52143aa9..ff69cac36 100644 --- a/src/test/java/org/takes/facets/forward/TkForwardTest.java +++ b/src/test/java/org/takes/facets/forward/TkForwardTest.java @@ -43,10 +43,10 @@ public final class TkForwardTest { /** * TkForward can catch RsForward. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void catchesExceptionCorrectly() throws IOException { + public void catchesExceptionCorrectly() throws Exception { final Take take = new Take() { @Override public Response act(final Request request) throws RsForward { @@ -63,10 +63,10 @@ public Response act(final Request request) throws RsForward { /** * TkForward can catch RsForward throws by Response. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void catchesExceptionThrownByResponse() throws IOException { + public void catchesExceptionThrownByResponse() throws Exception { final Take take = new Take() { @Override public Response act(final Request request) { diff --git a/src/test/java/org/takes/facets/hamcrest/HmRsStatusTest.java b/src/test/java/org/takes/facets/hamcrest/HmRsStatusTest.java index 113701d0a..02f8e86df 100644 --- a/src/test/java/org/takes/facets/hamcrest/HmRsStatusTest.java +++ b/src/test/java/org/takes/facets/hamcrest/HmRsStatusTest.java @@ -23,7 +23,6 @@ */ package org.takes.facets.hamcrest; -import java.io.IOException; import java.net.HttpURLConnection; import org.hamcrest.MatcherAssert; import org.hamcrest.core.IsNot; @@ -40,10 +39,10 @@ public final class HmRsStatusTest { /** * HmRsStatus can test status HTTP_OK. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void testsStatusOk() throws IOException { + public void testsStatusOk() throws Exception { MatcherAssert.assertThat( new TkHtml("").act(new RqFake()), new HmRsStatus(HttpURLConnection.HTTP_OK) @@ -56,10 +55,10 @@ public void testsStatusOk() throws IOException { /** * HmRsStatus can test status HTTP_NOT_FOUND. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void testsStatusNotFound() throws IOException { + public void testsStatusNotFound() throws Exception { MatcherAssert.assertThat( new TkHtml("").act(new RqFake()), new IsNot<>( diff --git a/src/test/java/org/takes/facets/previous/TkPreviousTest.java b/src/test/java/org/takes/facets/previous/TkPreviousTest.java index e71a91426..dd05d2a5f 100644 --- a/src/test/java/org/takes/facets/previous/TkPreviousTest.java +++ b/src/test/java/org/takes/facets/previous/TkPreviousTest.java @@ -23,7 +23,6 @@ */ package org.takes.facets.previous; -import java.io.IOException; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Test; @@ -40,10 +39,10 @@ public final class TkPreviousTest { /** * TkPrevious can redirect. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void redirectsOnCookie() throws IOException { + public void redirectsOnCookie() throws Exception { MatcherAssert.assertThat( new RsPrint( new TkPrevious(new TkText("")).act( diff --git a/src/test/java/org/takes/facets/ret/TkReturnTest.java b/src/test/java/org/takes/facets/ret/TkReturnTest.java index 57967b233..f51971316 100644 --- a/src/test/java/org/takes/facets/ret/TkReturnTest.java +++ b/src/test/java/org/takes/facets/ret/TkReturnTest.java @@ -23,7 +23,6 @@ */ package org.takes.facets.ret; -import java.io.IOException; import java.net.URLEncoder; import java.nio.charset.Charset; import org.hamcrest.MatcherAssert; @@ -43,10 +42,10 @@ public final class TkReturnTest { /** * TkReturn can redirect to return location * and remove a return cookie. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void redirectsAndRemovesCookie() throws IOException { + public void redirectsAndRemovesCookie() throws Exception { final Take take = new TkReturn(new TkEmpty()); final String destination = "/return/to"; MatcherAssert.assertThat( diff --git a/src/test/java/org/takes/http/BkBasicTest.java b/src/test/java/org/takes/http/BkBasicTest.java index 8e4f676ee..103871afc 100644 --- a/src/test/java/org/takes/http/BkBasicTest.java +++ b/src/test/java/org/takes/http/BkBasicTest.java @@ -100,10 +100,10 @@ public void handlesSocket() throws Exception { /** * BkBasic can return HTTP status 404 when accessing invalid URL. * - * @throws IOException if any I/O error occurs. + * @throws Exception if any I/O error occurs. */ @Test - public void returnsProperResponseCodeOnInvalidUrl() throws IOException { + public void returnsProperResponseCodeOnInvalidUrl() throws Exception { new FtRemote( new TkFork( new FkRegex("/path/a", new TkText("a")), diff --git a/src/test/java/org/takes/http/FtBasicTest.java b/src/test/java/org/takes/http/FtBasicTest.java index 80f464a22..a9845db58 100644 --- a/src/test/java/org/takes/http/FtBasicTest.java +++ b/src/test/java/org/takes/http/FtBasicTest.java @@ -214,10 +214,10 @@ public void exec(final URI home) throws IOException { /** * FtBasic can consume twice the input stream in case of a RsText. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void consumesTwiceInputStreamWithRsText() throws IOException { + public void consumesTwiceInputStreamWithRsText() throws Exception { final String result = "Hello RsText!"; new FtRemote( new TkFork( @@ -251,10 +251,10 @@ public void exec(final URI home) throws IOException { /** * FtBasic can consume twice the input stream in case of a RsHTML. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void consumesTwiceInputStreamWithRsHtml() throws IOException { + public void consumesTwiceInputStreamWithRsHtml() throws Exception { final String result = "Hello RsHTML!"; new FtRemote( new TkFork( diff --git a/src/test/java/org/takes/http/FtRemoteTest.java b/src/test/java/org/takes/http/FtRemoteTest.java index ffc40d6c7..892e52216 100644 --- a/src/test/java/org/takes/http/FtRemoteTest.java +++ b/src/test/java/org/takes/http/FtRemoteTest.java @@ -131,11 +131,11 @@ public void exec(final URI home) throws IOException { /** * FtRemote can return empty response body for {@link TkEmpty}. - * @throws IOException If some problems inside + * @throws Exception If some problems inside */ @Ignore @Test - public void returnsAnEmptyResponseBody() throws IOException { + public void returnsAnEmptyResponseBody() throws Exception { new FtRemote( new TkEmpty() ).exec( diff --git a/src/test/java/org/takes/rq/multipart/RqMtSmartTest.java b/src/test/java/org/takes/rq/multipart/RqMtSmartTest.java index d2785f724..3662215e0 100644 --- a/src/test/java/org/takes/rq/multipart/RqMtSmartTest.java +++ b/src/test/java/org/takes/rq/multipart/RqMtSmartTest.java @@ -181,10 +181,10 @@ public void identifiesBoundary() throws IOException { /** * RqMtSmart can work in integration mode. - * @throws IOException if some problem inside + * @throws Exception if some problem inside */ @Test - public void consumesHttpRequest() throws IOException { + public void consumesHttpRequest() throws Exception { final String part = "f-1"; final Take take = new Take() { @Override diff --git a/src/test/java/org/takes/tk/TkClasspathTest.java b/src/test/java/org/takes/tk/TkClasspathTest.java index d50ec798c..8bdcc41dd 100644 --- a/src/test/java/org/takes/tk/TkClasspathTest.java +++ b/src/test/java/org/takes/tk/TkClasspathTest.java @@ -23,7 +23,6 @@ */ package org.takes.tk; -import java.io.IOException; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Test; @@ -39,10 +38,10 @@ public final class TkClasspathTest { /** * TkClasspath can dispatch by resource name. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void dispatchesByResourceName() throws IOException { + public void dispatchesByResourceName() throws Exception { MatcherAssert.assertThat( new RsPrint( new TkClasspath().act( @@ -57,10 +56,10 @@ public void dispatchesByResourceName() throws IOException { /** * TkClasspath can throw when resource not found. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test(expected = HttpException.class) - public void throwsWhenResourceNotFound() throws IOException { + public void throwsWhenResourceNotFound() throws Exception { new TkClasspath().act( new RqFake("PUT", "/something-else", "") ); diff --git a/src/test/java/org/takes/tk/TkFilesTest.java b/src/test/java/org/takes/tk/TkFilesTest.java index 740dfdcf8..c5dc89765 100644 --- a/src/test/java/org/takes/tk/TkFilesTest.java +++ b/src/test/java/org/takes/tk/TkFilesTest.java @@ -23,7 +23,6 @@ */ package org.takes.tk; -import java.io.IOException; import java.nio.charset.StandardCharsets; import org.apache.commons.io.FileUtils; import org.hamcrest.MatcherAssert; @@ -49,10 +48,10 @@ public final class TkFilesTest { /** * TkFiles can dispatch by file name. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void dispatchesByFileName() throws IOException { + public void dispatchesByFileName() throws Exception { FileUtils.write( this.temp.newFile("a.txt"), "hello, world!", StandardCharsets.UTF_8 ); @@ -70,10 +69,10 @@ public void dispatchesByFileName() throws IOException { /** * TkFiles can throw when file not found. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test(expected = HttpException.class) - public void throwsWhenResourceNotFound() throws IOException { + public void throwsWhenResourceNotFound() throws Exception { new TkFiles("/absent-dir-for-sure").act( new RqFake("PUT", "/something-else.txt", "") ); diff --git a/src/test/java/org/takes/tk/TkGzipTest.java b/src/test/java/org/takes/tk/TkGzipTest.java index bf7825e1a..2f4c1a5bc 100644 --- a/src/test/java/org/takes/tk/TkGzipTest.java +++ b/src/test/java/org/takes/tk/TkGzipTest.java @@ -23,7 +23,6 @@ */ package org.takes.tk; -import java.io.IOException; import java.util.Arrays; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; @@ -39,10 +38,10 @@ public final class TkGzipTest { /** * TkGzip can compress on demand only. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void compressesOnDemandOnly() throws IOException { + public void compressesOnDemandOnly() throws Exception { MatcherAssert.assertThat( new RsPrint( new TkGzip(new TkClasspath()).act( @@ -62,10 +61,10 @@ public void compressesOnDemandOnly() throws IOException { /** * TkGzip can return uncompressed content. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void doesntCompressIfNotRequired() throws IOException { + public void doesntCompressIfNotRequired() throws Exception { MatcherAssert.assertThat( new RsPrint( new TkGzip(new TkClasspath()).act( diff --git a/src/test/java/org/takes/tk/TkHtmlTest.java b/src/test/java/org/takes/tk/TkHtmlTest.java index f564cac81..ba2051172 100644 --- a/src/test/java/org/takes/tk/TkHtmlTest.java +++ b/src/test/java/org/takes/tk/TkHtmlTest.java @@ -23,7 +23,6 @@ */ package org.takes.tk; -import java.io.IOException; import org.cactoos.text.JoinedText; import org.hamcrest.MatcherAssert; import org.junit.Test; @@ -41,10 +40,10 @@ public final class TkHtmlTest { /** * TkHTML can create a text. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void createsTextResponse() throws IOException { + public void createsTextResponse() throws Exception { final String body = "hello, world!"; MatcherAssert.assertThat( new RsPrint(new TkHtml(body).act(new RqFake())), @@ -63,10 +62,10 @@ public void createsTextResponse() throws IOException { /** * TkHTML can print multiple times. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void printsResourceMultipleTimes() throws IOException { + public void printsResourceMultipleTimes() throws Exception { final String body = "hello, dude!"; final Take take = new TkHtml(body); MatcherAssert.assertThat( diff --git a/src/test/java/org/takes/tk/TkMeasuredTest.java b/src/test/java/org/takes/tk/TkMeasuredTest.java index 8ed60aa73..40549e5a3 100644 --- a/src/test/java/org/takes/tk/TkMeasuredTest.java +++ b/src/test/java/org/takes/tk/TkMeasuredTest.java @@ -23,7 +23,6 @@ */ package org.takes.tk; -import java.io.IOException; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Test; @@ -38,10 +37,10 @@ public final class TkMeasuredTest { /** * TkMeasured can create a response with HTTP header "X-Take-Millis". - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void createsMeasuredResponse() throws IOException { + public void createsMeasuredResponse() throws Exception { final String header = "X-Takes-Millis"; MatcherAssert.assertThat( new RsPrint( @@ -55,10 +54,10 @@ public void createsMeasuredResponse() throws IOException { /** * TkMeasured can create a response with custom HTTP header. - * @throws IOException If some problem occurs + * @throws Exception If some problem occurs */ @Test - public void createsMeasuredResponseWithCustomHeader() throws IOException { + public void createsMeasuredResponseWithCustomHeader() throws Exception { final String header = "X-Custom-Take-Millis"; MatcherAssert.assertThat( new RsPrint( diff --git a/src/test/java/org/takes/tk/TkProxyTest.java b/src/test/java/org/takes/tk/TkProxyTest.java index b72c94d81..52f183cc4 100644 --- a/src/test/java/org/takes/tk/TkProxyTest.java +++ b/src/test/java/org/takes/tk/TkProxyTest.java @@ -114,7 +114,7 @@ public void justWorks() throws Exception { ).exec( new FtRemote.Script() { @Override - public void exec(final URI home) throws IOException { + public void exec(final URI home) throws Exception { MatcherAssert.assertThat( new RsPrint( new TkProxy(home).act( @@ -150,7 +150,7 @@ public Response act(final Request req) throws IOException { ).exec( new FtRemote.Script() { @Override - public void exec(final URI home) throws IOException { + public void exec(final URI home) throws Exception { MatcherAssert.assertThat( new RsPrint( new TkProxy(home).act( @@ -186,7 +186,7 @@ public void modifiesHost() throws Exception { // @checkstyle AnonInnerLengthCheck (100 lines) new FtRemote.Script() { @Override - public void exec(final URI home) throws IOException { + public void exec(final URI home) throws Exception { MatcherAssert.assertThat( new RsPrint(new TkProxy( home.toURL().toString() @@ -232,7 +232,7 @@ public void addsSpecificHeader() throws Exception { // @checkstyle AnonInnerLengthCheck (100 lines) new FtRemote.Script() { @Override - public void exec(final URI home) throws IOException { + public void exec(final URI home) throws Exception { MatcherAssert.assertThat( new RsPrint(new TkProxy( home.toURL().toString(), @@ -278,7 +278,7 @@ public void addsAllInitialHeaders() throws Exception { // @checkstyle AnonInnerLengthCheck (100 lines) new FtRemote.Script() { @Override - public void exec(final URI home) throws IOException { + public void exec(final URI home) throws Exception { MatcherAssert.assertThat( new RsPrint( new TkProxy(home).act( diff --git a/src/test/java/org/takes/tk/TkRedirectTest.java b/src/test/java/org/takes/tk/TkRedirectTest.java index a6e449fb6..049bfe33b 100644 --- a/src/test/java/org/takes/tk/TkRedirectTest.java +++ b/src/test/java/org/takes/tk/TkRedirectTest.java @@ -23,7 +23,6 @@ */ package org.takes.tk; -import java.io.IOException; import java.net.HttpURLConnection; import org.cactoos.text.JoinedText; import org.hamcrest.MatcherAssert; @@ -51,10 +50,10 @@ public final class TkRedirectTest { /** * TkRedirect can create a response with url string. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void createsRedirectResponseWithUrl() throws IOException { + public void createsRedirectResponseWithUrl() throws Exception { final String url = "/about"; MatcherAssert.assertThat( new RsPrint( @@ -74,10 +73,10 @@ public void createsRedirectResponseWithUrl() throws IOException { /** * TkRedirect can create a response with HTTP status code and url string. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void createsRedirectResponseWithUrlAndStatus() throws IOException { + public void createsRedirectResponseWithUrlAndStatus() throws Exception { final String url = "/"; MatcherAssert.assertThat( new RsPrint( @@ -99,10 +98,10 @@ public void createsRedirectResponseWithUrlAndStatus() throws IOException { /** * TkRedirect should carry on the query and the fragment. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void ignoresQueryAndFragmentOnEmptyUrl() throws IOException { + public void ignoresQueryAndFragmentOnEmptyUrl() throws Exception { final String target = "/the-target"; MatcherAssert.assertThat( new TkRedirect(target).act( diff --git a/src/test/java/org/takes/tk/TkSlf4jRemoteTest.java b/src/test/java/org/takes/tk/TkSlf4jRemoteTest.java index a8b5c193e..8d7c9a3c8 100644 --- a/src/test/java/org/takes/tk/TkSlf4jRemoteTest.java +++ b/src/test/java/org/takes/tk/TkSlf4jRemoteTest.java @@ -43,11 +43,11 @@ public final class TkSlf4jRemoteTest { /** * TkSlf4j can return an empty response body for {@link TkEmpty}. - * @throws IOException if some I/O problem occurred. + * @throws Exception if some I/O problem occurred. */ @Ignore @Test - public void returnsAnEmptyResponseBody() throws IOException { + public void returnsAnEmptyResponseBody() throws Exception { new FtRemote( new TkSlf4j(new TkEmpty()) ).exec( diff --git a/src/test/java/org/takes/tk/TkSlf4jTest.java b/src/test/java/org/takes/tk/TkSlf4jTest.java index 885b4d064..2e75b517d 100644 --- a/src/test/java/org/takes/tk/TkSlf4jTest.java +++ b/src/test/java/org/takes/tk/TkSlf4jTest.java @@ -36,28 +36,28 @@ public final class TkSlf4jTest { /** * TkSlf4j can log message. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void logsMessage() throws IOException { + public void logsMessage() throws Exception { new TkSlf4j(new TkText("test")).act(new RqFake()); } /** * TkSlf4j can log exception. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test(expected = IOException.class) - public void logsException() throws IOException { + public void logsException() throws Exception { new TkSlf4j(new TkFailure(new IOException(""))).act(new RqFake()); } /** * TkSlf4j can work with {@link TkEmpty}. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void logsEmptyMessage() throws IOException { + public void logsEmptyMessage() throws Exception { new TkSlf4j(new TkEmpty()).act(new RqFake()); } } diff --git a/src/test/java/org/takes/tk/TkSmartRedirectTest.java b/src/test/java/org/takes/tk/TkSmartRedirectTest.java index 2b0802e74..745834d10 100644 --- a/src/test/java/org/takes/tk/TkSmartRedirectTest.java +++ b/src/test/java/org/takes/tk/TkSmartRedirectTest.java @@ -23,7 +23,6 @@ */ package org.takes.tk; -import java.io.IOException; import org.hamcrest.MatcherAssert; import org.junit.Test; import org.takes.facets.hamcrest.HmHeader; @@ -37,10 +36,10 @@ public final class TkSmartRedirectTest { /** * TkRedirect should carry on the query and the fragment. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void redirectCarriesQueryAndFragment() throws IOException { + public void redirectCarriesQueryAndFragment() throws Exception { MatcherAssert.assertThat( new TkSmartRedirect("http://www.google.com/abc?b=2").act( new RqFake("GET", "/hi?a=1#test") @@ -54,10 +53,10 @@ public void redirectCarriesQueryAndFragment() throws IOException { /** * TkRedirect should carry on the query and the fragment. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void redirectCarriesQueryAndFragmentOnEmptyUrl() throws IOException { + public void redirectCarriesQueryAndFragmentOnEmptyUrl() throws Exception { MatcherAssert.assertThat( new TkSmartRedirect().act( new RqFake("GET", "/hey-you?f=1#xxx") diff --git a/src/test/java/org/takes/tk/TkTextTest.java b/src/test/java/org/takes/tk/TkTextTest.java index ae1a279ee..50e327729 100644 --- a/src/test/java/org/takes/tk/TkTextTest.java +++ b/src/test/java/org/takes/tk/TkTextTest.java @@ -23,7 +23,6 @@ */ package org.takes.tk; -import java.io.IOException; import org.cactoos.text.JoinedText; import org.hamcrest.MatcherAssert; import org.junit.Test; @@ -41,10 +40,10 @@ public final class TkTextTest { /** * TkText can create a text. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void createsTextResponse() throws IOException { + public void createsTextResponse() throws Exception { final String body = "hello, world!"; MatcherAssert.assertThat( new RsPrint(new TkText(body).act(new RqFake())), @@ -63,10 +62,10 @@ public void createsTextResponse() throws IOException { /** * TkText can print multiple times. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void printsResourceMultipleTimes() throws IOException { + public void printsResourceMultipleTimes() throws Exception { final String body = "hello, dude!"; final Take take = new TkText(body); MatcherAssert.assertThat( diff --git a/src/test/java/org/takes/tk/TkVerboseTest.java b/src/test/java/org/takes/tk/TkVerboseTest.java index 1921ba564..3ecc90bd0 100644 --- a/src/test/java/org/takes/tk/TkVerboseTest.java +++ b/src/test/java/org/takes/tk/TkVerboseTest.java @@ -42,10 +42,10 @@ public final class TkVerboseTest { /** * TkVerbose can extend not-found exception. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void extendsNotFoundException() throws IOException { + public void extendsNotFoundException() throws Exception { final Take take = new Take() { @Override public Response act(final Request request) throws IOException { diff --git a/src/test/java/org/takes/tk/TkVersionedTest.java b/src/test/java/org/takes/tk/TkVersionedTest.java index 031aa8f17..14c199e4c 100644 --- a/src/test/java/org/takes/tk/TkVersionedTest.java +++ b/src/test/java/org/takes/tk/TkVersionedTest.java @@ -23,7 +23,6 @@ */ package org.takes.tk; -import java.io.IOException; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.Test; @@ -38,10 +37,10 @@ public final class TkVersionedTest { /** * TkVersioned can add a header with version name. - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - public void attachesHeader() throws IOException { + public void attachesHeader() throws Exception { MatcherAssert.assertThat( new RsPrint( new TkVersioned(new TkEmpty()).act( diff --git a/src/test/java/org/takes/tk/TkWithHeadersTest.java b/src/test/java/org/takes/tk/TkWithHeadersTest.java index 226a3468d..5c27307ef 100644 --- a/src/test/java/org/takes/tk/TkWithHeadersTest.java +++ b/src/test/java/org/takes/tk/TkWithHeadersTest.java @@ -23,7 +23,6 @@ */ package org.takes.tk; -import java.io.IOException; import org.cactoos.text.JoinedText; import org.hamcrest.MatcherAssert; import org.junit.Test; @@ -39,10 +38,10 @@ public final class TkWithHeadersTest { /** * TkWithHeaders can add headers. - * @throws java.io.IOException If some problem inside + * @throws java.lang.Exception If some problem inside */ @Test - public void addHeaders() throws IOException { + public void addHeaders() throws Exception { final String host = "Host: www.example.com"; final String type = "Content-Type: text/xml"; MatcherAssert.assertThat(