|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| package org.jconfig.error; |
|
6 |
| |
|
7 |
| import junit.framework.TestCase; |
|
8 |
| |
|
9 |
| import org.jconfig.Configuration; |
|
10 |
| import org.jconfig.ConfigurationManager; |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| public class ErrorHandlerTest extends TestCase { |
|
17 |
| |
|
18 |
| |
|
19 |
0
| public ErrorHandlerTest(String arg0) {
|
|
20 |
0
| super(arg0);
|
|
21 |
| } |
|
22 |
| |
|
23 |
0
| public static void main(String[] args) {
|
|
24 |
0
| junit.textui.TestRunner.run(ErrorHandlerTest.class);
|
|
25 |
| } |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
0
| protected void setUp() throws Exception {
|
|
31 |
0
| super.setUp();
|
|
32 |
| } |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
0
| protected void tearDown() throws Exception {
|
|
37 |
0
| super.tearDown();
|
|
38 |
| } |
|
39 |
| |
|
40 |
0
| public void testErrorHandler() {
|
|
41 |
0
| System.setProperty("jconfig.errorhandler","org.jconfig.error.MockErrorHandler");
|
|
42 |
0
| Configuration cfg = ConfigurationManager.getConfiguration("I do not exist");
|
|
43 |
0
| assertNotNull(cfg);
|
|
44 |
0
| MockErrorHandler handler = (MockErrorHandler)ErrorReporter.getErrorHandler();
|
|
45 |
0
| assertEquals("Problem while trying to read configuration. Returning new configuration.",handler.getMsg());
|
|
46 |
0
| System.setProperty("jconfig.errorhandler","blabla");
|
|
47 |
| } |
|
48 |
| } |