Skip to content

Commit

Permalink
#534 /shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Aug 31, 2023
1 parent 1a82b30 commit b0dccb8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/jpeek/web/Futures.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
10 changes: 6 additions & 4 deletions src/main/java/org/jpeek/web/TkApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand All @@ -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)
);
Expand All @@ -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(
Expand Down
6 changes: 6 additions & 0 deletions src/test/java/org/jpeek/web/TkAppTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"));
}
);
}
Expand All @@ -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"));
}

}
3 changes: 0 additions & 3 deletions src/test/java/org/jpeek/web/TkReportTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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(
Expand Down

0 comments on commit b0dccb8

Please sign in to comment.