This repository was archived by the owner on Mar 3, 2026. It is now read-only.
forked from jooby-project/jooby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathErrTest.java
More file actions
81 lines (61 loc) · 2.43 KB
/
ErrTest.java
File metadata and controls
81 lines (61 loc) · 2.43 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package org.jooby;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class ErrTest {
@Test
public void exceptionWithStatus() {
Err exception = new Err(Status.NOT_FOUND);
assertEquals(Status.NOT_FOUND.value(), exception.statusCode());
assertEquals("Not Found(404)", exception.getMessage());
}
@Test
public void exceptionWithIntStatus() {
Err exception = new Err(404);
assertEquals(Status.NOT_FOUND.value(), exception.statusCode());
assertEquals("Not Found(404)", exception.getMessage());
}
@Test
public void exceptionWithStatusAndCause() {
Exception cause = new IllegalArgumentException();
Err exception = new Err(Status.NOT_FOUND, cause);
assertEquals(Status.NOT_FOUND.value(), exception.statusCode());
assertEquals("Not Found(404)", exception.getMessage());
assertEquals(cause, exception.getCause());
}
@Test
public void exceptionWithIntStatusAndCause() {
Exception cause = new IllegalArgumentException();
Err exception = new Err(404, cause);
assertEquals(Status.NOT_FOUND.value(), exception.statusCode());
assertEquals("Not Found(404)", exception.getMessage());
assertEquals(cause, exception.getCause());
}
@Test
public void exceptionWithStatusAndMessage() {
Err exception = new Err(Status.NOT_FOUND, "GET/missing");
assertEquals(Status.NOT_FOUND.value(), exception.statusCode());
assertEquals("Not Found(404): GET/missing", exception.getMessage());
}
@Test
public void exceptionWithIntStatusAndMessage() {
Err exception = new Err(404, "GET/missing");
assertEquals(Status.NOT_FOUND.value(), exception.statusCode());
assertEquals("Not Found(404): GET/missing", exception.getMessage());
}
@Test
public void exceptionWithStatusCauseAndMessage() {
Exception cause = new IllegalArgumentException();
Err exception = new Err(Status.NOT_FOUND, "GET/missing", cause);
assertEquals(Status.NOT_FOUND.value(), exception.statusCode());
assertEquals("Not Found(404): GET/missing", exception.getMessage());
assertEquals(cause, exception.getCause());
}
@Test
public void exceptionWithIntStatusCauseAndMessage() {
Exception cause = new IllegalArgumentException();
Err exception = new Err(404, "GET/missing", cause);
assertEquals(Status.NOT_FOUND.value(), exception.statusCode());
assertEquals("(404): GET/missing", exception.getMessage());
assertEquals(cause, exception.getCause());
}
}