01: package jfb.tst.tools.activitymgr;
02:
03: import java.io.InputStream;
04: import java.util.Properties;
05:
06: import jfb.tools.activitymgr.core.ModelMgr;
07: import jfb.tst.tools.activitymgr.core.TaskTest;
08: import junit.framework.TestCase;
09: import junit.framework.TestResult;
10:
11: import org.apache.log4j.Logger;
12: import org.apache.log4j.PropertyConfigurator;
13:
14: public abstract class AbstractModelTestCase extends TestCase {
15:
16: /** Logger */
17: private static Logger log = Logger
18: .getLogger(AbstractModelTestCase.class);
19:
20: public static void main(String[] args) {
21: junit.swingui.TestRunner.run(TaskTest.class);
22: }
23:
24: protected void setUp() throws Exception {
25: // Initialisation des logs et chargement de la config
26: PropertyConfigurator.configure("cfg/log4j.properties");
27: Properties props = new Properties();
28: InputStream in = AbstractModelTestCase.class
29: .getResourceAsStream("tests.properties");
30: props.load(in);
31: in.close();
32:
33: // Préfixe de config à utiliser
34: String cfg = props.getProperty("dbconfig");
35: // Initialisation de la connexion à la base de données
36: String jdbcDriver = props.getProperty(cfg + "." + "driver");
37: String jdbcUrl = props.getProperty(cfg + "." + "url");
38: String jdbcUser = props.getProperty(cfg + "." + "user");
39: String jdbcPassword = props.getProperty(cfg + "." + "password");
40: ModelMgr.initDatabaseAccess(jdbcDriver, jdbcUrl, jdbcUser,
41: jdbcPassword);
42:
43: }
44:
45: /**
46: * @see junit.framework.Test#run(junit.framework.TestResult)
47: */
48: public void run(final TestResult testResult) {
49: log.error("");
50: log.error("");
51: log.error("");
52: log
53: .error("**********************************************************");
54: log.error("*** STARTING TEST : '" + getName() + "'");
55: log
56: .error("**********************************************************");
57: try {
58: super .run(testResult);
59: } finally {
60: log.error("Test '" + getName() + "' done.");
61: }
62: }
63:
64: protected void tearDown() throws Exception {
65: ModelMgr.closeDatabaseAccess();
66: }
67:
68: }
|