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 19c2214 commit 1a82b30
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
11 changes: 11 additions & 0 deletions src/main/java/org/jpeek/web/Futures.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.cactoos.BiFunc;
import org.cactoos.Func;
import org.cactoos.Text;
Expand Down Expand Up @@ -170,4 +171,14 @@ public String asString() throws Exception {
).asString()
);
}

/**
* Shut it down.
* @return TRUE if terminated OK
* @throws InterruptedException If interrupted while waiting
*/
public boolean shutdown() throws InterruptedException {
this.service.shutdown();
return this.service.awaitTermination(1L, TimeUnit.SECONDS);
}
}
12 changes: 6 additions & 6 deletions src/test/java/org/jpeek/web/TkReportTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,16 @@ public final class TkReportTest {
@Test
@DisabledOnOs(OS.WINDOWS)
public void rendersEmptySvgBadge(@TempDir final File folder)
throws IOException {
throws IOException, InterruptedException {
final Futures futures = new Futures(
new Reports(folder.toPath())
);
new Assertion<>(
"Must render the badge",
XhtmlMatchers.xhtml(
new RsPrint(
new TkReport(
new AsyncReports(
new Futures(
new Reports(folder.toPath())
)
),
new AsyncReports(futures),
new Results()
).act(
new RqRegex.Fake(
Expand All @@ -68,6 +67,7 @@ public void rendersEmptySvgBadge(@TempDir final File folder)
),
XhtmlMatchers.hasXPath("//svg:svg")
).affirm();
futures.shutdown();
}

}

0 comments on commit 1a82b30

Please sign in to comment.