1 package org.apache.torque;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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 {
34 /*** The path to the configuration file. */
35 protected static final String CONFIG_FILE
36 = "src/test/TurbineResources.properties";
37
38 /*** Whether torque has been initialized. */
39 private static boolean hasInitialized = false;
40
41 /***
42 * Creates a new instance.
43 *
44 * @param name the name of the test case to run
45 */
46 public BaseTestCase(String name)
47 {
48 super(name);
49 }
50
51 /***
52 * Initialize Torque on the first setUp(). Subclasses which
53 * override setUp() must call super.setUp() as their first action.
54 */
55 public void setUp()
56 {
57 synchronized (BaseTestCase.class)
58 {
59 if (!hasInitialized)
60 {
61 try
62 {
63 Torque.init(CONFIG_FILE);
64 hasInitialized = true;
65 }
66 catch (Exception e)
67 {
68 fail("Couldn't initialize Torque: " + e.getMessage());
69 }
70 }
71 }
72 }
73 }