forked from jooby-project/jooby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIssue2367.java
More file actions
45 lines (36 loc) · 1.18 KB
/
Copy pathIssue2367.java
File metadata and controls
45 lines (36 loc) · 1.18 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
package io.jooby.i2367;
import static org.junit.jupiter.api.Assertions.assertEquals;
import io.jooby.AccessLogHandler;
import io.jooby.exception.BadRequestException;
import io.jooby.junit.ServerTest;
import io.jooby.junit.ServerTestRunner;
public class Issue2367 {
@ServerTest
public void shouldAfterHandlerGetTheRightCode(ServerTestRunner runner) {
runner.define(app -> {
app.after((ctx, result, failure) -> {
ctx.send(
"statusCode: " + ctx.getResponseCode().value() + ", result: " + result + ", failure: "
+ failure.getClass().getSimpleName());
});
app.get("/2367", ctx -> {
throw new BadRequestException("intentional error");
});
}).ready(http -> {
http.get("/2367", rsp -> {
assertEquals("statusCode: 400, result: null, failure: BadRequestException", rsp.body().string());
});
});
}
@ServerTest
public void shouldLog404(ServerTestRunner runner) {
runner.define(app -> {
app.decorator(new AccessLogHandler());
app.assets("/2367/*", "/2367");
}).ready(http -> {
http.get("/2367/index.js", rsp -> {
assertEquals(404, rsp.code());
});
});
}
}