-
-
Notifications
You must be signed in to change notification settings - Fork 201
Expand file tree
/
Copy pathIssue2452.java
More file actions
51 lines (45 loc) · 1.47 KB
/
Copy pathIssue2452.java
File metadata and controls
51 lines (45 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
* Jooby https://jooby.io
* Apache License Version 2.0 https://jooby.io/LICENSE.txt
* Copyright 2014 Edgar Espina
*/
package io.jooby.i2452;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.concurrent.CompletableFuture;
import io.jooby.ReactiveSupport;
import io.jooby.StatusCode;
import io.jooby.exception.StatusCodeException;
import io.jooby.junit.ServerTest;
import io.jooby.junit.ServerTestRunner;
import io.jooby.test.WebClient;
public class Issue2452 {
@ServerTest
public void shouldHandleCompletableFutureError(ServerTestRunner runner) {
runner
.define(
app -> {
app.use(ReactiveSupport.concurrent());
app.get(
"/2452",
ctx ->
CompletableFuture.supplyAsync(
() -> {
throw new StatusCodeException(StatusCode.NOT_FOUND);
}));
app.error(
(ctx, cause, code) -> {
ctx.setResponseCode(code);
ctx.send(cause.getClass().getSimpleName());
});
})
.ready(
(WebClient http) -> {
http.get(
"/2452",
rsp -> {
assertEquals("StatusCodeException", rsp.body().string());
assertEquals(StatusCode.NOT_FOUND.value(), rsp.code());
});
});
}
}