1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package org.strutsit.chain;
25
26 import junit.framework.Test;
27 import junit.framework.TestCase;
28 import junit.framework.TestSuite;
29
30 import org.apache.commons.logging.Log;
31 import org.apache.commons.logging.LogFactory;
32 import org.strutsit.chain.configuration.PropertyReader;
33
34
35 /***
36 * Tests the PropertyReader class.
37 *
38 * @author <a href="mailto:wolff@struts-it.de">Manfred Wolff </a>
39 * @since JDK 1.4
40 * @version $Revision: 1.2 $
41 */
42 public class TestPropertyReader extends TestCase {
43
44 private static final String DEFAULT_NAME = "/chain-config.xml";
45
46 /***
47 * The logger for this class (commons-logging).
48 */
49 private static Log log = LogFactory.getLog(TestPropertyReader.class);
50
51
52
53 /***
54 * Defines the testcase name for JUnit.
55 *
56 * @param theName the testcase's name.
57 */
58 public TestPropertyReader(String theName) {
59 super(theName);
60 if (log.isTraceEnabled()) {
61 log.trace("TestPropertyReader -> START");
62 }
63 if (log.isTraceEnabled()) {
64 log.trace("enclosing_method -> END");
65 }
66 }
67
68 /***
69 * Start the tests.
70 *
71 * @param theArgs the arguments. Not used
72 */
73 public static void main(String[] theArgs) {
74 if (log.isTraceEnabled()) {
75 log.trace("main -> START");
76 }
77 junit.awtui.TestRunner
78 .main(new String[] { TestPropertyReader.class.getName() });
79 if (log.isTraceEnabled()) {
80 log.trace("main -> END");
81 }
82 }
83
84 /***
85 * @return a test suite (<code>TestSuite</code>) that includes all
86 * methods starting with "test"
87 */
88 public static Test suite() {
89
90 if (log.isTraceEnabled()) {
91 log.trace("suite -> START");
92 }
93 if (log.isTraceEnabled()) {
94 log.trace("suite -> END");
95 }
96 return new TestSuite(TestPropertyReader.class);
97 }
98
99 /***
100 * Nothing to be done.
101 */
102 public void setUp() {
103 if (log.isTraceEnabled()) {
104 log.trace("setUp -> START");
105 }
106 if (log.isTraceEnabled()) {
107 log.trace("setUp -> END");
108 }
109 }
110
111 /***
112 * Nothing to be done.
113 */
114 public void tearDown() {
115 if (log.isTraceEnabled()) {
116 log.trace("tearDown -> START");
117 }
118 if (log.isTraceEnabled()) {
119 log.trace("tearDown -> END");
120 }
121 }
122
123 /***
124 *
125 */
126 public void testReader() {
127
128 PropertyReader reader = PropertyReader.getInstance();
129 assertNotNull(reader);
130
131
132 String confName = reader.getConfName();
133 if (log.isInfoEnabled()) {
134 log.info(confName);
135 log.info(DEFAULT_NAME);
136 }
137 assertEquals("Wron confname.", DEFAULT_NAME.equals(confName), true);
138 }
139
140 }