|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| |
|
19 |
| |
|
20 |
| |
|
21 |
| |
|
22 |
| package nu.xom.tests; |
|
23 |
| |
|
24 |
| import nu.xom.canonical.CanonicalizationException; |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| public class CanonicalizationExceptionTest extends XOMTestCase { |
|
36 |
| |
|
37 |
| |
|
38 |
| private CanonicalizationException ex; |
|
39 |
| private Exception cause; |
|
40 |
| |
|
41 |
| |
|
42 |
5
| public CanonicalizationExceptionTest(String name) {
|
|
43 |
5
| super(name);
|
|
44 |
| } |
|
45 |
| |
|
46 |
| |
|
47 |
5
| protected void setUp() {
|
|
48 |
5
| ex = new CanonicalizationException("message");
|
|
49 |
5
| cause = new Exception();
|
|
50 |
| } |
|
51 |
| |
|
52 |
| |
|
53 |
1
| public void testConstructor() {
|
|
54 |
1
| String message = "testing 1-2-3";
|
|
55 |
1
| CanonicalizationException ex = new CanonicalizationException(message);
|
|
56 |
1
| assertEquals(message, ex.getMessage());
|
|
57 |
| } |
|
58 |
| |
|
59 |
| |
|
60 |
1
| public void testInitCause() {
|
|
61 |
| |
|
62 |
1
| assertNull(ex.getCause());
|
|
63 |
1
| ex.initCause(cause);
|
|
64 |
1
| assertEquals(cause, ex.getCause());
|
|
65 |
| |
|
66 |
1
| try {
|
|
67 |
1
| ex.initCause(null);
|
|
68 |
0
| fail("Reinitialized cause over null");
|
|
69 |
| } |
|
70 |
| catch (IllegalStateException success) { |
|
71 |
1
| assertNotNull(success.getMessage());
|
|
72 |
| } |
|
73 |
| |
|
74 |
1
| try {
|
|
75 |
1
| ex.initCause(new Exception());
|
|
76 |
0
| fail("Reinitialized cause over null");
|
|
77 |
| } |
|
78 |
| catch (IllegalStateException success) { |
|
79 |
1
| assertNotNull(success.getMessage());
|
|
80 |
| } |
|
81 |
| |
|
82 |
| } |
|
83 |
| |
|
84 |
| |
|
85 |
1
| public void testNullInitCause() {
|
|
86 |
| |
|
87 |
1
| CanonicalizationException ex = new CanonicalizationException(null);
|
|
88 |
1
| ex.initCause(null);
|
|
89 |
1
| assertNull(ex.getCause());
|
|
90 |
| |
|
91 |
1
| try {
|
|
92 |
1
| ex.initCause(new Exception());
|
|
93 |
0
| fail("Reinitialized cause over null");
|
|
94 |
| } |
|
95 |
| catch (IllegalStateException success) { |
|
96 |
1
| assertNotNull(success.getMessage());
|
|
97 |
| } |
|
98 |
| |
|
99 |
1
| try {
|
|
100 |
1
| ex.initCause(null);
|
|
101 |
0
| fail("Reinitialized cause over null");
|
|
102 |
| } |
|
103 |
| catch (IllegalStateException success) { |
|
104 |
1
| assertNotNull(success.getMessage());
|
|
105 |
| } |
|
106 |
| |
|
107 |
| } |
|
108 |
| |
|
109 |
| |
|
110 |
1
| public void testSelfCause() {
|
|
111 |
| |
|
112 |
1
| try {
|
|
113 |
1
| ex.initCause(ex);
|
|
114 |
0
| fail("Allowed self-causation");
|
|
115 |
| } |
|
116 |
| catch (IllegalArgumentException success) { |
|
117 |
1
| assertNotNull(success.getMessage());
|
|
118 |
| } |
|
119 |
| |
|
120 |
| } |
|
121 |
| |
|
122 |
| |
|
123 |
1
| public void testGetMessage() {
|
|
124 |
1
| Exception ex = new CanonicalizationException("testing");
|
|
125 |
1
| assertEquals("testing", ex.getMessage());
|
|
126 |
| } |
|
127 |
| |
|
128 |
| } |