1   package org.apache.turbine.test;
2   
3   /*
4    * Copyright 2001-2005 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License")
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  import java.io.File;
20  import java.io.FileInputStream;
21  import java.io.FileNotFoundException;
22  import java.util.Properties;
23  
24  import junit.framework.TestCase;
25  
26  import org.apache.log4j.PropertyConfigurator;
27  
28  import org.apache.turbine.Turbine;
29  
30  /***
31   * Base functionality to be extended by all Apache Turbine test cases.  Test
32   * case implementations are used to automate testing via JUnit.
33   *
34   * @author <a href="mailto:celkins@scardini.com">Christopher Elkins</a>
35   * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
36   * @version $Id: BaseTestCase.java 264148 2005-08-29 14:21:04Z henning $
37   */
38  public abstract class BaseTestCase
39          extends TestCase
40  {
41      private static File log4jFile = new File("conf/test/Log4j.properties");
42  
43      public BaseTestCase(String name)
44              throws Exception
45      {
46          super(name);
47  
48          try
49          {
50              Properties p = new Properties();
51              p.load(new FileInputStream(log4jFile));
52              p.setProperty(Turbine.APPLICATION_ROOT_KEY, new File(".").getAbsolutePath());
53              PropertyConfigurator.configure(p);
54          }
55          catch (FileNotFoundException fnf)
56          {
57              System.err.println("Could not open Log4J configuration file "
58                      + log4jFile);
59          }
60      }
61  }
62