01: package org.apache.torque;
02:
03: /*
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "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 junit.framework.TestCase;
23:
24: /**
25: * Base functionality to be extended by all Torque test cases. Test
26: * case implementations are used to automate unit testing via JUnit.
27: *
28: * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
29: * @author <a href="mailto:celkins@scardini.com">Christopher Elkins</a>
30: * @version $Id: BaseTestCase.java 473821 2006-11-11 22:37:25Z tv $
31: */
32: public abstract class BaseTestCase extends TestCase {
33: /** The path to the configuration file. */
34: protected static final String CONFIG_FILE = "src/test/TurbineResources.properties";
35:
36: /** Whether torque has been initialized. */
37: private static boolean hasInitialized = false;
38:
39: /**
40: * Creates a new instance.
41: *
42: * @param name the name of the test case to run
43: */
44: public BaseTestCase(String name) {
45: super (name);
46: }
47:
48: /**
49: * Initialize Torque on the first setUp(). Subclasses which
50: * override setUp() must call super.setUp() as their first action.
51: */
52: public void setUp() {
53: synchronized (BaseTestCase.class) {
54: if (!hasInitialized) {
55: try {
56: Torque.init(CONFIG_FILE);
57: hasInitialized = true;
58: } catch (Exception e) {
59: fail("Couldn't initialize Torque: "
60: + e.getMessage());
61: }
62: }
63: }
64: }
65: }
|