1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.xnap.util;
24
25 import java.util.Properties;
26
27 import junit.framework.TestCase;
28
29 import org.apache.log4j.spi.ThrowableInformation;
30 import org.xnap.plugin.Plugin;
31 import org.xnap.plugin.PluginInfo;
32 import org.xnap.plugin.PluginManager;
33
34 /***
35 * @author Steffen Pingel
36 */
37 public class UncaughtExceptionManagerTest extends TestCase {
38
39 public UncaughtExceptionManagerTest(String name)
40 {
41 super(name);
42 }
43
44 protected void setUp()
45 {
46 }
47
48 protected void tearDown()
49 {
50 }
51
52 public void testRemoveExceptionDescription()
53 {
54 String trace = "java.lang.ArrayIndexOutOfBoundsException: 0 >= 0\n"
55 + "\tat java.util.Vector.elementAt(Vector.java:431)\n";
56 String cleanTrace = "java.lang.ArrayIndexOutOfBoundsException\n"
57 + "\tat java.util.Vector.elementAt(Vector.java:431)\n";
58 assertEquals
59 (UncaughtExceptionManager.removeExceptionDescription
60 (trace, "java.lang.ArrayIndexOutOfBoundsException"),
61 cleanTrace);
62 }
63
64 public void testGetPlugin()
65 {
66 Properties props = new Properties();
67 props.put("Class-Name", "org.xnap.plugin.test.TestPlugin");
68 props.put("Name", "Test");
69 props.put("Version", "1.0.0");
70
71 PluginInfo info = new PluginInfo(props);
72 info.setEnabled(true);
73 PluginManager.getInstance().add(info);
74
75 String trace = "java.lang.RuntimeException\n"
76 + "\tat org.xnap.plugin.test.ClassName(ClassName.java:1)\n";
77 assertEquals(UncaughtExceptionManager.getPlugin(trace), "Test 1.0.0");
78
79 PluginManager.getInstance().remove(info);
80 }
81
82 }