Lines 191-194
Link Here
|
191 |
// could do more here... |
191 |
// could do more here... |
192 |
} |
192 |
} |
193 |
|
193 |
|
|
|
194 |
/** |
195 |
* Check that UNKNOWN works. |
196 |
* @see "#30947" |
197 |
*/ |
198 |
public void testUnknownSeverity() throws Exception { |
199 |
|
200 |
// Simple exception is EXCEPTION. |
201 |
Throwable t = new IOException("unloc msg"); |
202 |
NbErrorManager.Exc x = err.createExc(t, ErrorManager.UNKNOWN); |
203 |
assertEquals(ErrorManager.EXCEPTION, x.getSeverity()); |
204 |
assertEquals("unloc msg", x.getMessage()); |
205 |
assertEquals("unloc msg", x.getLocalizedMessage()); |
206 |
assertTrue(!x.isLocalized()); |
207 |
|
208 |
// Same when there is unloc debug info attached. |
209 |
t = new IOException("unloc msg"); |
210 |
err.annotate(t, ErrorManager.UNKNOWN, "some debug info", null, null, null); |
211 |
x = err.createExc(t, ErrorManager.UNKNOWN); |
212 |
assertEquals(ErrorManager.EXCEPTION, x.getSeverity()); |
213 |
assertEquals("unloc msg", x.getMessage()); |
214 |
assertEquals("unloc msg", x.getLocalizedMessage()); |
215 |
assertTrue(!x.isLocalized()); |
216 |
|
217 |
// Nested exceptions don't necessarily change anything severity-wise. |
218 |
t = new IOException("unloc msg"); |
219 |
Throwable t2 = new IOException("unloc msg #2"); |
220 |
err.annotate(t, ErrorManager.UNKNOWN, null, null, t2, null); |
221 |
x = err.createExc(t, ErrorManager.UNKNOWN); |
222 |
assertEquals(ErrorManager.EXCEPTION, x.getSeverity()); |
223 |
assertEquals("unloc msg", x.getMessage()); |
224 |
assertEquals("unloc msg", x.getLocalizedMessage()); |
225 |
assertTrue(!x.isLocalized()); |
226 |
|
227 |
// But annotations at a particular severity level (usually localized) do |
228 |
// set the severity for the exception. |
229 |
t = new IOException("unloc msg"); |
230 |
err.annotate(t, ErrorManager.USER, null, "loc msg", null, null); |
231 |
x = err.createExc(t, ErrorManager.UNKNOWN); |
232 |
assertEquals(ErrorManager.USER, x.getSeverity()); |
233 |
assertEquals("unloc msg", x.getMessage()); |
234 |
assertEquals("loc msg", x.getLocalizedMessage()); |
235 |
assertTrue(x.isLocalized()); |
236 |
|
237 |
// And that works even if you are just rethrowing someone else's exception. |
238 |
t = new IOException("unloc msg"); |
239 |
t2 = new IOException("unloc msg #2"); |
240 |
err.annotate(t2, ErrorManager.USER, null, "loc msg", null, null); |
241 |
err.annotate(t, ErrorManager.UNKNOWN, null, null, t2, null); |
242 |
x = err.createExc(t, ErrorManager.UNKNOWN); |
243 |
assertEquals(ErrorManager.USER, x.getSeverity()); |
244 |
assertEquals("unloc msg", x.getMessage()); |
245 |
assertEquals("loc msg", x.getLocalizedMessage()); |
246 |
assertTrue(x.isLocalized()); |
247 |
// Almost the same test to mimic #31254: |
248 |
t2 = new IOException("loc msg"); |
249 |
err.annotate(t2, ErrorManager.USER, null, "loc msg", null, null); |
250 |
t = new IOException("loc msg"); |
251 |
err.annotate(t, ErrorManager.USER, null, null, t2, null); |
252 |
x = err.createExc(t, ErrorManager.UNKNOWN); |
253 |
assertEquals(ErrorManager.USER, x.getSeverity()); |
254 |
assertEquals("loc msg", x.getMessage()); |
255 |
assertEquals("loc msg", x.getLocalizedMessage()); |
256 |
assertTrue(x.isLocalized()); |
257 |
|
258 |
} |
259 |
|
194 |
} |
260 |
} |