1 /*
2 * Copyright (C) The JContainer Group. All rights reserved.
3 *
4 * This software is published under the terms of the JContainer
5 * Software License version 1.1, a copy of which has been included
6 * with this distribution in the LICENSE.txt file.
7 */
8 package org.jcontainer.dna;
9
10 import junit.framework.TestCase;
11
12 /***
13 *
14 * @author <a href="mailto:peter at realityforge.org">Peter Donald</a>
15 * @version $Revision: 1.2 $ $Date: 2003/09/23 08:10:14 $
16 */
17 public class ConfigurationExceptionTestCase
18 extends TestCase
19 {
20 public void testConfigurationExceptionConstruction()
21 throws Exception
22 {
23 final String message = "myMessage";
24 final String path = "/my/path";
25 final String location = "mylocation.xml:20";
26 final Throwable cause = new Throwable();
27 final ConfigurationException exception =
28 new ConfigurationException( message, path, location, cause );
29
30 assertEquals( "message", message, exception.getMessage() );
31 assertEquals( "path", path, exception.getPath() );
32 assertEquals( "location", location, exception.getLocation() );
33 assertEquals( "cause", cause, exception.getCause() );
34 }
35
36 public void testConfigurationExceptionConstructionWithNullCause()
37 throws Exception
38 {
39 final String message = "myMessage";
40 final String path = "/my/path";
41 final String location = "mylocation.xml:20";
42 final Throwable cause = null;
43 final ConfigurationException exception =
44 new ConfigurationException( message, path, location, cause );
45
46 assertEquals( "message", message, exception.getMessage() );
47 assertEquals( "path", path, exception.getPath() );
48 assertEquals( "location", location, exception.getLocation() );
49 assertEquals( "cause", cause, exception.getCause() );
50 }
51
52 public void testConfigurationExceptionConstructionWithNullKey()
53 throws Exception
54 {
55 final String message = "myMessage";
56 final String path = null;
57 final String location = "mylocation.xml:20";
58 final Throwable cause = new Throwable();
59 final ConfigurationException exception =
60 new ConfigurationException( message, path, location, cause );
61
62 assertEquals( "message", message, exception.getMessage() );
63 assertEquals( "path", path, exception.getPath() );
64 assertEquals( "location", location, exception.getLocation() );
65 assertEquals( "cause", cause, exception.getCause() );
66 }
67
68 public void testConfigurationExceptionConstructionWithNullMessage()
69 throws Exception
70 {
71 final String message = null;
72 final String path = "/my/path";
73 final String location = "mylocation.xml:20";
74 final Throwable cause = new Throwable();
75 final ConfigurationException exception =
76 new ConfigurationException( message, path, location, cause );
77
78 assertEquals( "message", message, exception.getMessage() );
79 assertEquals( "path", path, exception.getPath() );
80 assertEquals( "location", location, exception.getLocation() );
81 assertEquals( "cause", cause, exception.getCause() );
82 }
83
84 public void testConfigurationExceptionConstructionWithNullLocation()
85 throws Exception
86 {
87 final String message = "myMessage";
88 final String path = "/my/path";
89 final String location = null;
90 final Throwable cause = new Throwable();
91 final ConfigurationException exception =
92 new ConfigurationException( message, path, location, cause );
93
94 assertEquals( "message", message, exception.getMessage() );
95 assertEquals( "path", path, exception.getPath() );
96 assertEquals( "location", location, exception.getLocation() );
97 assertEquals( "cause", cause, exception.getCause() );
98 }
99
100 public void testConfigurationExceptionConstructionWith3ArgCtor()
101 throws Exception
102 {
103 final String message = "myMessage";
104 final String path = "/my/path";
105 final String location = "mylocation.xml:20";
106 final ConfigurationException exception =
107 new ConfigurationException( message, path, location );
108
109 assertEquals( "message", message, exception.getMessage() );
110 assertEquals( "path", path, exception.getPath() );
111 assertEquals( "location", location, exception.getLocation() );
112 assertEquals( "cause", null, exception.getCause() );
113 }
114
115 public void testConfigurationExceptionConstructionWith2ArgCtor()
116 throws Exception
117 {
118 final String message = "myMessage";
119 final Throwable cause = new Throwable();
120 final ConfigurationException exception =
121 new ConfigurationException( message, cause );
122
123 assertEquals( "message", message, exception.getMessage() );
124 assertEquals( "path", null, exception.getPath() );
125 assertEquals( "location", null, exception.getLocation() );
126 assertEquals( "cause", cause, exception.getCause() );
127 }
128
129 public void testConfigurationExceptionToString()
130 throws Exception
131 {
132 final String path = "/my/path";
133 final String location = "mylocation.xml:20";
134 final ConfigurationException exception =
135 new ConfigurationException( "myMessage", path, location );
136
137 final String expected =
138 "org.jcontainer.dna.ConfigurationException: myMessage" +
139 " - " + path +
140 " @ " + location;
141
142 assertEquals( expected, exception.toString() );
143 }
144
145 public void testConfigurationExceptionToStringWithNullPath()
146 throws Exception
147 {
148 final String location = "mylocation.xml:20";
149 final ConfigurationException exception =
150 new ConfigurationException( "myMessage", null, location );
151
152 final String expected =
153 "org.jcontainer.dna.ConfigurationException: myMessage" +
154 " @ " + location;
155
156 assertEquals( expected, exception.toString() );
157 }
158
159 public void testConfigurationExceptionToStringWithNullLocation()
160 throws Exception
161 {
162 final String path = "/my/path";
163 final ConfigurationException exception =
164 new ConfigurationException( "myMessage", path, null );
165
166 final String expected =
167 "org.jcontainer.dna.ConfigurationException: myMessage" +
168 " - " + path;
169
170 assertEquals( expected, exception.toString() );
171 }
172
173 public void testConfigurationExceptionToStringWithNullLocationAndPath()
174 throws Exception
175 {
176 final ConfigurationException exception =
177 new ConfigurationException( "myMessage", null, null );
178
179 final String expected =
180 "org.jcontainer.dna.ConfigurationException: myMessage";
181
182 assertEquals( expected, exception.toString() );
183 }
184
185 public void testConfigurationExceptionToStringWithEmptyPath()
186 throws Exception
187 {
188 final String location = "mylocation.xml:20";
189 final ConfigurationException exception =
190 new ConfigurationException( "myMessage", "", location );
191
192 final String expected =
193 "org.jcontainer.dna.ConfigurationException: myMessage" +
194 " @ " + location;
195
196 assertEquals( expected, exception.toString() );
197 }
198
199 public void testConfigurationExceptionToStringWithEmptyLocation()
200 throws Exception
201 {
202 final String path = "/my/path";
203 final ConfigurationException exception =
204 new ConfigurationException( "myMessage", path, "" );
205
206 final String expected =
207 "org.jcontainer.dna.ConfigurationException: myMessage" +
208 " - " + path;
209
210 assertEquals( expected, exception.toString() );
211 }
212
213 public void testConfigurationExceptionToStringWithEmptyLocationAndPath()
214 throws Exception
215 {
216 final ConfigurationException exception =
217 new ConfigurationException( "myMessage", "", "" );
218
219 final String expected =
220 "org.jcontainer.dna.ConfigurationException: myMessage";
221
222 assertEquals( expected, exception.toString() );
223 }
224 }
This page was automatically generated by Maven