1 package org.e2etrace.config;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import java.io.IOException;
20
21 import org.e2etrace.config.PropertiesTraceConfig;
22 import org.e2etrace.trace.SimpleTraceStepId;
23
24
25 import junit.framework.TestCase;
26
27
28
29
30
31
32
33 public class PropertiesTraceConfigTest extends TestCase {
34
35 private static String TESTDATA_FILE = "e2etrace/config/PropertiesTraceConfigTest.properties";
36
37 public static void main(String[] args) {
38 junit.textui.TestRunner.run(PropertiesTraceConfigTest.class);
39 }
40
41
42
43
44
45
46 public void testLoadConfigFile() throws IOException {
47 PropertiesTraceConfig tc = new PropertiesTraceConfig();
48
49
50 tc.loadConfigFile(TESTDATA_FILE);
51
52
53 boolean ok = false;
54 try {
55 tc.loadConfigFile("NotExistent");
56 } catch (IOException ioe) {
57 ok = true;
58 }
59
60 if (!ok) {
61 fail("Expected an IOException!");
62 }
63
64 }
65
66
67
68
69
70
71
72 public void testIsTraceEnabledEtc() throws IOException {
73 PropertiesTraceConfig tc = new PropertiesTraceConfig();
74
75 tc.loadConfigFile(TESTDATA_FILE);
76
77 assertTrue("enabletrace should be true", tc.isTraceEnabled());
78 assertTrue("Trace step id1 should be true", tc
79 .isTraceEnabledForId(new SimpleTraceStepId("id1")));
80 assertFalse("Trace step id2 should be false", tc
81 .isTraceEnabledForId(new SimpleTraceStepId("id2")));
82 assertTrue("Undefined Trace step xxx should be true", tc
83 .isTraceEnabledForId(new SimpleTraceStepId("xxx")));
84 }
85
86 }