forked from jooby-project/jooby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIssue1349.java
More file actions
48 lines (40 loc) · 1.17 KB
/
Issue1349.java
File metadata and controls
48 lines (40 loc) · 1.17 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
package io.jooby;
import io.jooby.exception.StatusCodeException;
import io.jooby.junit.ServerTest;
import io.jooby.junit.ServerTestRunner;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class Issue1349 {
public static class App1349 extends Jooby {
{
error(IllegalAccessException.class, ((ctx, cause, statusCode) -> {
ctx.setResponseCode(statusCode);
ctx.send(cause.getMessage());
}));
get("/1349", ctx ->
something()
);
get("/1349/iae", ctx ->
throwsIAE()
);
}
private String throwsIAE() throws IllegalAccessException {
throw new IllegalAccessException("no-access");
}
public String something() {
throw new StatusCodeException(StatusCode.UNAUTHORIZED, "test");
}
}
@ServerTest
public void issue1349(ServerTestRunner runner) {
runner.use(App1349::new)
.ready(client -> {
client.get("/1349", rsp -> {
assertEquals(401, rsp.code());
});
client.get("/1349/iae", rsp -> {
assertEquals(500, rsp.code());
assertEquals("no-access", rsp.body().string());
});
});
}
}