1 package org.apache.torque;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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:dlr@finemaltcoding.com">Daniel Rall</a>
26 * @author <a href="mailto:celkins@scardini.com">Christopher Elkins</a>
27 * @version $Id: BaseTestCase.java 239636 2005-08-24 12:38:09Z henning $
28 */
29 public abstract class BaseTestCase extends TestCase
30 {
31 /*** The path to the configuration file. */
32 private static final String CONFIG_FILE
33 = "src/test/TurbineResources.properties";
34
35 /*** Whether torque has been initialized. */
36 private static boolean hasInitialized = false;
37
38 /***
39 * Creates a new instance.
40 *
41 * @param name the name of the test case to run
42 */
43 public BaseTestCase(String name)
44 {
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 {
54 synchronized (BaseTestCase.class)
55 {
56 if (!hasInitialized)
57 {
58 try
59 {
60 Torque.init(CONFIG_FILE);
61 hasInitialized = true;
62 }
63 catch (Exception e)
64 {
65 fail("Couldn't initialize Torque: " + e.getMessage());
66 }
67 }
68 }
69 }
70 }