1   /*
2    * 
3    * $Revision: 1.2 $
4    * $Date: 2004/06/20 12:18:40 $
5    *
6    * ====================================================================
7    * struts-it
8    * Copyright (C) 2004 - strutsit community
9    * 
10   * Licensed under the Apache License, Version 2.0 (the "License");
11   * you may not use this file except in compliance with the License.
12   * You may obtain a copy of the License at
13   * 
14   *      http://www.apache.org/licenses/LICENSE-2.0
15   * 
16   * Unless required by applicable law or agreed to in writing, software
17   * distributed under the License is distributed on an "AS IS" BASIS,
18   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19   * See the License for the specific language governing permissions and
20   * limitations under the License.
21   *
22   * created: 2004-06-05  Manfred Wolff
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      //------------------------------------- methods that belongs to the
52      // TestCase
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          // All methods starting with "test" will be executed in the test suite.
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         // must not be default
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 }