KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > torque > BaseRuntimeTestCase


1 package org.apache.torque;
2
3 /*
4  * Copyright 2001-2004 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 junit.framework.TestCase;
20
21 /**
22  * Base functionality to be extended by all Torque test cases. Test
23  * case implementations are used to automate unit testing via JUnit.
24  *
25  * @author <a HREF="mailto:seade@backstagetech.com.au">Scott Eade</a>
26  * @version $Id: BaseRuntimeTestCase.java,v 1.1 2005/03/19 06:25:27 tfischer Exp $
27  */

28 public abstract class BaseRuntimeTestCase extends TestCase
29 {
30     /** The path to the configuration file. */
31     private static final String JavaDoc CONFIG_FILE
32             = "target/test/rttest/Torque.properties";
33
34     /** Whether torque has been initialized. */
35     static boolean hasInitialized = false;
36
37     /**
38      * Creates a new instance.
39      */

40     public BaseRuntimeTestCase(String JavaDoc name)
41     {
42         super(name);
43     }
44
45     /**
46      * Initialize Torque on the first setUp(). Subclasses which override
47      * setUp() must call super.setUp() as their first action.
48      */

49     public void setUp()
50     {
51         synchronized (BaseRuntimeTestCase.class)
52         {
53             if (!hasInitialized)
54             {
55                 try
56                 {
57                     Torque.init(CONFIG_FILE);
58                     hasInitialized = true;
59                 }
60                 catch (Exception JavaDoc e)
61                 {
62                     fail("Couldn't initialize Torque: " + e.getMessage());
63                 }
64             }
65         }
66     }
67
68 }
69
Popular Tags