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