diff --git a/src/main/java/org/jpeek/web/Futures.java b/src/main/java/org/jpeek/web/Futures.java index 4a14d8cc..d24b180b 100644 --- a/src/main/java/org/jpeek/web/Futures.java +++ b/src/main/java/org/jpeek/web/Futures.java @@ -179,6 +179,6 @@ public String asString() throws Exception { */ public boolean shutdown() throws InterruptedException { this.service.shutdown(); - return this.service.awaitTermination(1L, TimeUnit.SECONDS); + return this.service.awaitTermination(16L, TimeUnit.SECONDS); } } diff --git a/src/main/java/org/jpeek/web/TkApp.java b/src/main/java/org/jpeek/web/TkApp.java index b50da825..48469e9d 100644 --- a/src/main/java/org/jpeek/web/TkApp.java +++ b/src/main/java/org/jpeek/web/TkApp.java @@ -68,9 +68,8 @@ public final class TkApp extends TkWrap { /** * Ctor. * @param home Home directory - * @throws IOException If fails */ - public TkApp(final Path home) throws IOException { + public TkApp(final Path home) { super(TkApp.make(home)); } @@ -97,9 +96,8 @@ public static void main(final String... args) throws IOException { * Ctor. * @param home Home directory * @return The take - * @throws IOException If fails */ - private static Take make(final Path home) throws IOException { + private static Take make(final Path home) { final Futures futures = new Futures( new Reports(home) ); @@ -112,6 +110,10 @@ private static Take make(final Path home) throws IOException { new TkForward( new TkFork( new FkRegex("/", new TkIndex()), + new FkRegex( + "/shutdown", + (Take) req -> new RsText(Boolean.toString(futures.shutdown())) + ), new FkRegex("/robots.txt", new TkText("")), new FkRegex("/mistakes", new TkMistakes()), new FkRegex( diff --git a/src/test/java/org/jpeek/web/TkAppTest.java b/src/test/java/org/jpeek/web/TkAppTest.java index c75a4468..0fa1c9f9 100644 --- a/src/test/java/org/jpeek/web/TkAppTest.java +++ b/src/test/java/org/jpeek/web/TkAppTest.java @@ -27,6 +27,7 @@ import com.jcabi.http.response.RestResponse; import java.net.HttpURLConnection; import java.nio.file.Path; +import org.hamcrest.Matchers; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; import org.llorllale.cactoos.matchers.Assertion; @@ -64,6 +65,10 @@ public void rendersOneReport(@TempDir final Path temp) throws Exception { .fetch() .as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_SEE_OTHER); + new JdkRequest(String.format("%s/shutdown", home)) + .fetch() + .as(RestResponse.class) + .assertBody(Matchers.equalTo("true")); } ); } @@ -88,6 +93,7 @@ public void pingsSimplePages(@TempDir final Path temp) throws Exception { new HmRsStatus(HttpURLConnection.HTTP_OK) ).affirm(); } + app.act(new RqFake("GET", "/shutdown")); } } diff --git a/src/test/java/org/jpeek/web/TkReportTest.java b/src/test/java/org/jpeek/web/TkReportTest.java index 27530803..f5cc4b29 100644 --- a/src/test/java/org/jpeek/web/TkReportTest.java +++ b/src/test/java/org/jpeek/web/TkReportTest.java @@ -27,8 +27,6 @@ import java.io.File; import java.io.IOException; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.DisabledOnOs; -import org.junit.jupiter.api.condition.OS; import org.junit.jupiter.api.io.TempDir; import org.llorllale.cactoos.matchers.Assertion; import org.takes.facets.fork.RqRegex; @@ -43,7 +41,6 @@ public final class TkReportTest { @Test - @DisabledOnOs(OS.WINDOWS) public void rendersEmptySvgBadge(@TempDir final File folder) throws IOException, InterruptedException { final Futures futures = new Futures(