1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.juneau.httppart;
18
19 import static org.junit.jupiter.api.Assertions.*;
20
21 import org.apache.juneau.*;
22 import org.junit.jupiter.api.*;
23
24 class SchemaValidationException_Test extends TestBase {
25
26 @Test void a01_basic() {
27 var x = new SchemaValidationException("Test message");
28 assertNotNull(x);
29 assertTrue(x.getMessage().contains("Test message"));
30 }
31
32 @Test void a02_withArgs() {
33 var x = new SchemaValidationException("Test {0} {1}", "foo", "bar");
34 assertTrue(x.getMessage().contains("Test foo bar"));
35 }
36
37 @Test void a03_setMessage_fluentChaining() {
38 var x = new SchemaValidationException("Original");
39
40
41 SchemaValidationException result = x.setMessage("New message");
42 assertSame(x, result);
43 assertInstanceOf(SchemaValidationException.class, result);
44 assertTrue(result.getMessage().contains("New message"));
45 }
46
47 @Test void a04_getRootCause_single() {
48 var x = new SchemaValidationException("Root cause");
49
50
51 SchemaValidationException root = x.getRootCause();
52 assertSame(x, root);
53 assertInstanceOf(SchemaValidationException.class, root);
54 }
55
56 @Test void a05_getRootCause_nested() {
57 var cause = new SchemaValidationException("Cause");
58 var middle = new SchemaValidationException("Middle");
59 middle.initCause(cause);
60 var top = new SchemaValidationException("Top");
61 top.initCause(middle);
62
63
64 SchemaValidationException root = top.getRootCause();
65 assertSame(cause, root);
66 assertInstanceOf(SchemaValidationException.class, root);
67 assertTrue(root.getMessage().contains("Cause"));
68 }
69
70 @Test void a06_fluentChaining() {
71
72 var x = new SchemaValidationException("Initial")
73 .setMessage("Updated message");
74
75 assertTrue(x.getMessage().contains("Updated message"));
76 }
77 }