1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.juneau.http.response;
18
19 import static org.apache.juneau.http.HttpResponses.*;
20 import static org.apache.juneau.http.response.NotImplemented.*;
21
22 import org.apache.juneau.*;
23 import org.apache.juneau.rest.annotation.*;
24 import org.apache.juneau.rest.mock.*;
25 import org.junit.jupiter.api.*;
26
27 class NotImplemented_Test extends TestBase {
28
29 @Rest
30 public static class A {
31 @RestGet
32 public void f1() throws NotImplemented {
33 throw new NotImplemented();
34 }
35 @RestGet
36 public void f2() throws NotImplemented {
37 throw new NotImplemented("foo {0}", "bar");
38 }
39 @RestGet
40 public void f3() throws NotImplemented {
41 throw new NotImplemented(new RuntimeException("baz"));
42 }
43 @RestGet
44 public void f4() throws NotImplemented {
45 throw new NotImplemented(new RuntimeException("baz"), "foo {0}", "bar");
46 }
47 @RestGet
48 public void f5() throws NotImplemented {
49 throw notImplemented().setHeader2("Foo", "bar");
50 }
51 @RestGet
52 public void f6() throws NotImplemented {
53 throw new NotImplemented("foo");
54 }
55 }
56
57 @Test void a01_basic() throws Exception {
58 var c = MockRestClient.create(A.class).ignoreErrors().noTrace().build();
59
60 c.get("/f1").run()
61 .assertStatus().asCode().is(STATUS_CODE)
62 .assertContent(REASON_PHRASE);
63 c.get("/f2").run()
64 .assertStatus().asCode().is(STATUS_CODE)
65 .assertContent("foo bar");
66 c.get("/f3").run()
67 .assertStatus().asCode().is(STATUS_CODE)
68 .assertContent("baz");
69 c.get("/f4").run()
70 .assertStatus().asCode().is(STATUS_CODE)
71 .assertContent("foo bar");
72 c.get("/f5").run()
73 .assertStatus().asCode().is(STATUS_CODE)
74 .assertContent(REASON_PHRASE)
75 .assertHeader("Foo").is("bar");
76 c.get("/f6").run()
77 .assertStatus().asCode().is(STATUS_CODE)
78 .assertContent("foo");
79 }
80 }